From 8bc20933523e04fc682918df7a16b35fae172fef Mon Sep 17 00:00:00 2001 From: No0ne558 Date: Tue, 23 Dec 2025 02:38:00 -0800 Subject: [PATCH] Revert "Dev" --- .clang-tidy | 14 - CMakeLists.txt | 32 +- Testing/Temporary/CTestCostData.txt | 1 - config/reverse_ssh_daemon.conf | 26 + docs/REVERSE_SSH.md | 589 +++++++++++ docs/changelog.md | 283 ------ loader/loader_main.cc | 22 +- main/business/account.cc | 46 +- main/business/account.hh | 12 +- main/business/check.cc | 315 +++--- main/business/check.hh | 166 ++- main/business/customer.cc | 86 +- main/business/customer.hh | 40 +- main/business/employee.cc | 138 +-- main/business/employee.hh | 4 +- main/business/inventory.cc | 170 ++-- main/business/inventory.hh | 10 +- main/business/labor.cc | 144 +-- main/business/labor.hh | 6 +- main/business/sales.cc | 100 +- main/business/sales.hh | 8 +- main/business/tips.cc | 56 +- main/business/tips.hh | 8 +- main/data/admission.cc | 6 +- main/data/admission.hh | 4 +- main/data/archive.cc | 168 ++- main/data/archive.hh | 6 +- main/data/credit.cc | 338 +++--- main/data/credit.hh | 33 +- main/data/exception.cc | 50 +- main/data/exception.hh | 6 +- main/data/expense.cc | 130 +-- main/data/expense.hh | 12 +- main/data/license_hash.cc | 8 +- main/data/locale.cc | 60 +- main/data/locale.hh | 8 +- main/data/manager.cc | 1128 +++++++++++---------- main/data/manager.hh | 33 +- main/data/settings.cc | 521 +++++----- main/data/settings.hh | 153 +-- main/data/settings_enums.hh | 123 +-- main/data/system.cc | 148 +-- main/data/system.hh | 20 +- main/hardware/cdu.cc | 44 +- main/hardware/cdu.hh | 48 +- main/hardware/drawer.cc | 134 +-- main/hardware/drawer.hh | 8 +- main/hardware/printer.cc | 129 +-- main/hardware/printer.hh | 139 ++- main/hardware/remote_printer.cc | 34 +- main/hardware/remote_printer.hh | 2 +- main/hardware/terminal.cc | 109 +- main/hardware/terminal.hh | 52 +- main/ui/chart.cc | 14 +- main/ui/chart.hh | 2 +- main/ui/labels.cc | 88 +- main/ui/labels.hh | 4 +- main/ui/report.cc | 10 +- main/ui/report.hh | 18 +- main/ui/system_report.cc | 330 +++--- main/ui/system_salesmix.cc | 36 +- print/print_main.cc | 46 +- scripts/system/reverse-ssh-daemon.service | 33 + scripts/tools/vt_reverse_ssh | 304 ++++++ scripts/tools/vt_reverse_ssh_setup | 389 +++++++ scripts/tools/vt_ssh_security | 464 +++++++++ src/core/basic.hh | 4 +- src/core/crash_report.cc | 35 +- src/core/data_file.hh | 8 +- src/core/data_persistence_manager.cc | 9 +- src/core/data_persistence_manager.hh | 34 +- src/core/debug.cc | 44 +- src/core/debug.hh | 2 +- src/core/error_handler.cc | 8 +- src/core/image_data.hh | 2 +- src/core/list_utility.hh | 23 +- src/core/time_info.cc | 2 +- src/core/time_info.hh | 32 +- src/network/remote_link.cc | 4 +- src/network/remote_link.hh | 172 ++-- src/network/reverse_ssh_daemon.cc | 323 ++++++ src/network/reverse_ssh_service.cc | 560 ++++++++++ src/network/reverse_ssh_service.hh | 154 +++ src/network/socket.cc | 23 +- src/network/vt_ccq_pipe.cc | 22 +- src/utils/fntrace.hh | 11 +- src/utils/font_check.cc | 6 +- src/utils/input_validation.hh | 12 +- src/utils/modern_cpp_example.cc | 56 +- src/utils/safe_string_utils.hh | 4 +- src/utils/utility.cc | 15 +- src/utils/utility.hh | 30 +- src/utils/vt_enum_utils.hh | 11 +- src/utils/vt_json_config.cc | 14 +- src/utils/vt_json_config.hh | 12 +- src/utils/vt_logger.cc | 122 +-- src/utils/vt_logger.hh | 4 +- term/layer.cc | 108 +- term/layer.hh | 2 +- term/term_credit.cc | 4 +- term/term_credit_cheq.cc | 28 +- term/term_credit_mcve.cc | 26 +- term/term_dialog.cc | 79 +- term/term_dialog.hh | 2 +- term/term_main.cc | 4 +- term/term_view.cc | 430 ++++---- term/term_view.hh | 22 +- term/touch_screen.cc | 28 +- tests/unit/test_check.cc | 10 +- tests/unit/test_enhanced_logging.cc | 22 +- tests/unit/test_memory_modernization.cc | 31 +- version/main_print_version.cc | 6 +- zone/account_zone.cc | 17 +- zone/account_zone.hh | 32 +- zone/button_zone.cc | 81 +- zone/button_zone.hh | 150 +-- zone/cdu_zone.cc | 48 +- zone/cdu_zone.hh | 32 +- zone/chart_zone.cc | 2 +- zone/chart_zone.hh | 19 +- zone/check_list_zone.cc | 129 ++- zone/check_list_zone.hh | 40 +- zone/creditcard_list_zone.cc | 112 +- zone/creditcard_list_zone.hh | 28 +- zone/dialog_zone.cc | 406 ++++---- zone/dialog_zone.hh | 132 +-- zone/drawer_zone.cc | 137 +-- zone/drawer_zone.hh | 30 +- zone/expense_zone.cc | 82 +- zone/expense_zone.hh | 32 +- zone/form_zone.cc | 90 +- zone/form_zone.hh | 34 +- zone/hardware_zone.cc | 58 +- zone/hardware_zone.hh | 26 +- zone/inventory_zone.cc | 133 +-- zone/inventory_zone.hh | 130 +-- zone/labor_zone.cc | 76 +- zone/labor_zone.hh | 34 +- zone/layout_zone.cc | 18 +- zone/layout_zone.hh | 14 +- zone/login_zone.cc | 61 +- zone/login_zone.hh | 20 +- zone/merchant_zone.cc | 4 +- zone/merchant_zone.hh | 12 +- zone/order_zone.cc | 179 ++-- zone/order_zone.hh | 140 +-- zone/payment_zone.cc | 204 ++-- zone/payment_zone.hh | 28 +- zone/payout_zone.cc | 54 +- zone/payout_zone.hh | 22 +- zone/phrase_zone.cc | 4 +- zone/phrase_zone.hh | 12 +- zone/pos_zone.cc | 22 +- zone/pos_zone.hh | 200 ++-- zone/printer_zone.cc | 12 +- zone/printer_zone.hh | 28 +- zone/report_zone.cc | 176 ++-- zone/report_zone.hh | 48 +- zone/report_zone_quickbooks.cc | 4 +- zone/search_zone.cc | 4 +- zone/search_zone.hh | 16 +- zone/settings_zone.cc | 279 ++--- zone/settings_zone.hh | 176 ++-- zone/split_check_zone.cc | 76 +- zone/split_check_zone.hh | 22 +- zone/table_zone.cc | 155 +-- zone/table_zone.hh | 82 +- zone/user_edit_zone.cc | 86 +- zone/user_edit_zone.hh | 44 +- zone/video_zone.cc | 2 +- zone/video_zone.hh | 8 +- zone/zone.cc | 150 ++- zone/zone.hh | 64 +- zone/zone_object.cc | 22 +- zone/zone_object.hh | 6 +- 175 files changed, 8604 insertions(+), 6168 deletions(-) delete mode 100644 .clang-tidy delete mode 100644 Testing/Temporary/CTestCostData.txt create mode 100644 config/reverse_ssh_daemon.conf create mode 100644 docs/REVERSE_SSH.md mode change 100644 => 100755 loader/loader_main.cc create mode 100644 scripts/system/reverse-ssh-daemon.service create mode 100755 scripts/tools/vt_reverse_ssh create mode 100755 scripts/tools/vt_reverse_ssh_setup create mode 100755 scripts/tools/vt_ssh_security create mode 100644 src/network/reverse_ssh_daemon.cc create mode 100644 src/network/reverse_ssh_service.cc create mode 100644 src/network/reverse_ssh_service.hh diff --git a/.clang-tidy b/.clang-tidy deleted file mode 100644 index cfed86cd..00000000 --- a/.clang-tidy +++ /dev/null @@ -1,14 +0,0 @@ ---- -Checks: > - -*, - clang-analyzer-*, - bugprone-*, - -bugprone-easily-swappable-parameters, - performance-*, - -modernize-use-trailing-return-type, - -modernize-avoid-c-arrays, - -modernize-macro-to-enum, - modernize-use-nullptr, - modernize-use-override, - modernize-use-equals-default -HeaderFilterRegex: '^.*/(main|src|zone|tests)/.*' diff --git a/CMakeLists.txt b/CMakeLists.txt index eb80b69f..02ea648a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -419,6 +419,7 @@ add_library(vtcore src/core/error_handler.cc src/core/error_handler.hh src/core/crash_report.cc src/core/crash_report.hh src/network/remote_link.cc src/network/remote_link.hh + src/network/reverse_ssh_service.cc src/network/reverse_ssh_service.hh src/core/debug.cc src/core/debug.hh src/core/generic_char.cc src/core/generic_char.hh src/core/logger.cc src/core/logger.hh @@ -551,7 +552,9 @@ target_link_libraries(vt_print vtcore) add_executable(vt_cdu cdu/cdu_main.cc main/hardware/cdu_att.cc) target_link_libraries(vt_cdu vtcore) - +# Reverse SSH daemon +add_executable(reverse_ssh_daemon src/network/reverse_ssh_daemon.cc) +target_link_libraries(reverse_ssh_daemon vtcore) # Test executable to verify Catch2 integration if(BUILD_TESTING) @@ -585,7 +588,7 @@ install(CODE "file(MAKE_DIRECTORY \${CMAKE_INSTALL_PREFIX}/viewtouch/dat/crashre install(CODE "file(MAKE_DIRECTORY \${CMAKE_INSTALL_PREFIX}/viewtouch/bin/vtcommands)") install(CODE "file(MAKE_DIRECTORY \${CMAKE_INSTALL_PREFIX}/share/viewtouch/fonts)") -install(TARGETS vtpos vt_cdu vt_print vt_term vt_main +install(TARGETS vtpos vt_cdu vt_print vt_term vt_main reverse_ssh_daemon RUNTIME DESTINATION viewtouch/bin LIBRARY DESTINATION viewtouch/lib ARCHIVE DESTINATION viewtouch/lib/static) @@ -623,7 +626,30 @@ else() endif() install(PROGRAMS scripts/tools/vtcommands.pl DESTINATION viewtouch/bin/vtcommands) - +# Install reverse SSH daemon service, configuration, and management scripts +# Skip systemd service installation in CI environments (requires root permissions) +if(NOT DEFINED ENV{CI}) + install(PROGRAMS scripts/system/reverse-ssh-daemon.service DESTINATION /etc/systemd/system/) + message(STATUS "Installing reverse SSH daemon systemd service to /etc/systemd/system/") +else() + message(STATUS "Skipping systemd service installation (CI environment detected)") +endif() +install(PROGRAMS scripts/tools/vt_reverse_ssh DESTINATION viewtouch/bin/) +install(PROGRAMS scripts/tools/vt_ssh_security DESTINATION viewtouch/bin/) +install(PROGRAMS scripts/tools/vt_reverse_ssh_setup DESTINATION viewtouch/bin/) + +# Install reverse SSH configuration file +# Skip /etc/viewtouch/ installation in CI environments (requires root permissions) +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/config/reverse_ssh_daemon.conf") + if(NOT DEFINED ENV{CI}) + install(FILES config/reverse_ssh_daemon.conf DESTINATION /etc/viewtouch/ RENAME reverse_ssh.conf) + message(STATUS "Installing reverse SSH configuration file to /etc/viewtouch/reverse_ssh.conf") + else() + message(STATUS "Skipping /etc/viewtouch/ configuration file installation (CI environment detected)") + endif() +else() + message(WARNING "Reverse SSH configuration file not found: config/reverse_ssh_daemon.conf") +endif() #install(CODE "MESSAGE(\"Sample install message.\")") diff --git a/Testing/Temporary/CTestCostData.txt b/Testing/Temporary/CTestCostData.txt deleted file mode 100644 index ed97d539..00000000 --- a/Testing/Temporary/CTestCostData.txt +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/config/reverse_ssh_daemon.conf b/config/reverse_ssh_daemon.conf new file mode 100644 index 00000000..a2f69fba --- /dev/null +++ b/config/reverse_ssh_daemon.conf @@ -0,0 +1,26 @@ +# ViewTouch Reverse SSH Daemon Configuration +# Copy this file to /etc/viewtouch/reverse_ssh.conf and customize the settings + +# Management server details +management_server=management.viewtouch.com +management_port=22 +remote_user=viewtouch + +# Tunnel configuration +# Local port to expose (typically SSH port 22) +local_port=22 +# Remote port on management server (0 = auto-assign) +remote_port=0 + +# SSH authentication +ssh_key_path=/usr/viewtouch/ssh/reverse_ssh_key + +# Connection settings +reconnect_interval=30 +health_check_interval=60 +max_retries=10 + +# Daemon settings +log_file=/var/log/viewtouch/reverse_ssh_daemon.log +pid_file=/var/run/viewtouch/reverse_ssh_daemon.pid +daemonize=true diff --git a/docs/REVERSE_SSH.md b/docs/REVERSE_SSH.md new file mode 100644 index 00000000..28b7c57c --- /dev/null +++ b/docs/REVERSE_SSH.md @@ -0,0 +1,589 @@ +# ViewTouch Reverse SSH Tunnel + +This document describes the reverse SSH tunnel functionality in ViewTouch, which enables remote access to POS systems behind firewalls or NAT devices. + +## Overview + +Reverse SSH tunneling allows a device behind a firewall to initiate an outbound SSH connection to a management server, creating a secure tunnel that enables inbound connections back to the device. This is essential for remote support, monitoring, and management of ViewTouch POS systems. + +## Architecture + +ViewTouch provides two ways to implement reverse SSH tunnels: + +1. **Integrated Service**: Built into the main ViewTouch application (vt_main) +2. **Standalone Daemon**: Independent reverse SSH daemon (reverse_ssh_daemon) + +### Integrated Service + +The integrated service runs as part of the ViewTouch application and **always starts automatically** when ViewTouch starts. It is configured through the ViewTouch settings interface and automatically stops when the POS system shuts down. The service is always enabled and will attempt to establish reverse SSH tunnels using the configured parameters. + +### Standalone Daemon + +The standalone daemon runs independently of ViewTouch and can be managed via systemd. This is useful for scenarios where remote access is needed even when ViewTouch is not running. + +## Configuration + +### Integrated Service Configuration + +Configure reverse SSH settings through the ViewTouch settings interface: + +- **Enable Reverse SSH**: Enable/disable the reverse SSH tunnel +- **Management Server**: Hostname/IP of the management server +- **Management Port**: SSH port on the management server (default: 22) +- **Remote User**: SSH username on the management server +- **Local Port**: Local port to expose (typically 22 for SSH access) +- **Remote Port**: Port on management server for tunnel (0 = auto-assign) +- **SSH Key Path**: Path to SSH private key file +- **Reconnect Interval**: Seconds between reconnection attempts +- **Health Check Interval**: Seconds between health checks +- **Max Retries**: Maximum reconnection attempts before giving up + +### Standalone Daemon Configuration + +Edit `/etc/viewtouch/reverse_ssh.conf` (installed automatically with ViewTouch): + +```bash +# Management server details +management_server=management.viewtouch.com +management_port=22 +remote_user=viewtouch + +# Tunnel configuration +local_port=22 +remote_port=0 + +# SSH authentication +ssh_key_path=/usr/viewtouch/ssh/reverse_ssh_key + +# Connection settings +reconnect_interval=30 +health_check_interval=60 +max_retries=10 + +# Daemon settings +log_file=/var/log/viewtouch/reverse_ssh_daemon.log +pid_file=/var/run/viewtouch/reverse_ssh_daemon.pid +daemonize=true +``` + +## Setup Instructions + +### Option A: Using Your Own Computer as Management Server + +If you don't have a dedicated management server, you can use your own computer: + +#### 1. Make Your Computer Accessible +```bash +# Install SSH server if not already installed +sudo apt install openssh-server # Ubuntu/Debian +sudo dnf install openssh-server # Fedora/RHEL +sudo pacman -S openssh # Arch + +# Start and enable SSH service +sudo systemctl start sshd +sudo systemctl enable sshd + +# Find your public IP (if accessible from internet) +curl ifconfig.me +# OR +curl icanhazip.com +``` + +#### 2. Configure SSH Server +```bash +# Edit SSH config +sudo nano /etc/ssh/sshd_config + +# Ensure these settings: +PubkeyAuthentication yes +PasswordAuthentication no # For security +PermitTunnel yes +GatewayPorts yes + +# Restart SSH +sudo systemctl restart sshd +``` + +#### 3. Configure ViewTouch Reverse SSH +Set in `/etc/viewtouch/reverse_ssh.conf`: +```bash +management_server=your.public.ip.address +management_port=22 +remote_user=your_username +local_port=22 +remote_port=2222 # Or 0 for auto-assign +ssh_key_path=/usr/viewtouch/ssh/reverse_ssh_key +``` + +### Option B: Using Public Tunneling Services (Easier) + +For personal use without a public IP, use free tunneling services: + +#### Using Serveo (SSH-based): +```bash +# Start tunnel to serveo +ssh -R 80:localhost:22 serveo.net + +# This gives you a URL like: tcp://subdomain.serveo.net:xxxxx +# Configure ViewTouch to connect to: subdomain.serveo.net +``` + +#### Using Ngrok (if you prefer): +```bash +# Install ngrok +wget https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-amd64.tgz +tar xvf ngrok-v3-stable-linux-amd64.tgz + +# Start tunnel +./ngrok tcp 22 + +# This gives you: tcp://0.tcp.ngrok.io:xxxxx +# Configure ViewTouch to connect to: 0.tcp.ngrok.io +``` + +### 4. Configure ViewTouch for Your Setup + +#### For Personal Computer Setup: +```bash +# Edit the config +sudo nano /etc/viewtouch/reverse_ssh.conf + +# Example configuration: +management_server=your.home.ip.address # Your public IP +management_port=22 +remote_user=your_linux_username +local_port=22 +remote_port=2222 +ssh_key_path=/usr/viewtouch/ssh/reverse_ssh_key +``` + +#### For Serveo/Ngrok Services: +```bash +# Edit the config +sudo nano /etc/viewtouch/reverse_ssh.conf + +# For Serveo: +management_server=subdomain.serveo.net +management_port=22 +remote_user=serveo # Usually just 'serveo' + +# For Ngrok: +management_server=0.tcp.ngrok.io +management_port=xxxxx # The port ngrok gives you +remote_user=ngrok_user # Whatever user you set up +``` + +### 5. Generate SSH Key + +For both integrated and standalone configurations: + +```bash +# Using the management script (recommended) +sudo vt_reverse_ssh generate-key + +# Or manually +sudo mkdir -p /usr/viewtouch/ssh +sudo ssh-keygen -t ed25519 -f /usr/viewtouch/ssh/reverse_ssh_key -N '' -C "viewtouch-reverse-ssh-$(hostname)" +sudo chmod 600 /usr/viewtouch/ssh/reverse_ssh_key +sudo chmod 644 /usr/viewtouch/ssh/reverse_ssh_key.pub +``` + +### 2. Configure Management Server + +1. Copy the public key (`/usr/viewtouch/ssh/reverse_ssh_key.pub`) to your management server +2. Add it to the authorized_keys file of the remote user: + +```bash +# On management server +echo "public_key_content_here" >> ~/.ssh/authorized_keys +chmod 600 ~/.ssh/authorized_keys +``` + +3. Ensure the SSH server allows public key authentication and tunneling: + +```bash +# /etc/ssh/sshd_config on management server +PubkeyAuthentication yes +PasswordAuthentication no +PermitTunnel yes +GatewayPorts yes +``` + +### 3. Configure Firewall + +Ensure outbound SSH connections are allowed from the POS system to the management server. + +### 4. Start the Service + +#### Integrated Service (with ViewTouch) + +The service **always starts automatically** when ViewTouch starts and stops when ViewTouch shuts down. Configuration settings are used for connection parameters, but the service itself is always enabled. + +#### Standalone Daemon + +```bash +# Manual management +sudo vt_reverse_ssh start +sudo vt_reverse_ssh status +sudo vt_reverse_ssh stop + +# Systemd management +sudo systemctl enable reverse-ssh-daemon +sudo systemctl start reverse-ssh-daemon +sudo systemctl status reverse-ssh-daemon +``` + +## Usage + +### Testing Connection + +```bash +# Test SSH connection +sudo vt_reverse_ssh test + +# Check daemon status +sudo vt_reverse_ssh status + +# View configuration +sudo vt_reverse_ssh config +``` + +### Connecting to POS System + +Once the tunnel is established, connect from your computer: + +#### From Your Personal Computer (as management server): +```bash +# Connect to the ViewTouch system via the tunnel +ssh -p 2222 localhost + +# Or with specific user/key: +ssh -i ~/.ssh/viewtouch_key -p 2222 your_user@localhost +``` + +#### When Using Serveo/Ngrok: +```bash +# For Serveo - connect directly (serveo handles authentication) +ssh serveo@subdomain.serveo.net -p assigned_port + +# For Ngrok - connect to the ngrok endpoint +ssh -p assigned_port user@0.tcp.ngrok.io +``` + +#### Dynamic Port Assignment: +If using `remote_port=0` (auto-assign), check the assigned port: +```bash +# Check which port was assigned +sudo vt_reverse_ssh status +# Shows: "Tunnel active: server.com:XXXX -> localhost:22" + +# Then connect using that port +ssh -p XXXX localhost +``` + +### Monitoring + +- Check logs: `/var/log/viewtouch/reverse_ssh_daemon.log` +- Monitor tunnel status: `sudo vt_reverse_ssh status` +- View systemd status: `sudo systemctl status reverse-ssh-daemon` + +## Security Considerations + +### Key Management + +- Use strong SSH keys (Ed25519 recommended over RSA) +- Regularly rotate SSH keys using the security script +- Store private keys securely with proper permissions (600) +- Use different keys for different purposes + +### Network Security + +- Use firewall rules to restrict access to management servers only +- Consider using VPN in addition to SSH tunnels for additional security +- Regularly audit SSH access logs and connection attempts +- Use non-standard SSH ports when possible + +### Access Control + +- Use dedicated user accounts for remote access +- Implement proper sudo policies limiting remote user capabilities +- Monitor and log all remote access attempts +- Disable password authentication on both ends + +### SSH Security Tools + +ViewTouch provides security management tools: + +```bash +# Run full security audit +sudo vt_ssh_security audit + +# Rotate SSH keys +sudo vt_ssh_security rotate-key /usr/viewtouch/ssh/reverse_ssh_key + +# Harden SSH server configuration +sudo vt_ssh_security harden-ssh + +# Check and fix file permissions +sudo vt_ssh_security check-perms +sudo vt_ssh_security fix-perms + +# Generate secure SSH client configuration +sudo vt_ssh_security gen-mgmt-config +``` + +### Best Practices + +1. **Key Rotation**: Rotate SSH keys regularly, especially after security incidents +2. **Access Monitoring**: Monitor SSH logs for unauthorized access attempts +3. **Firewall Rules**: Restrict SSH access to known management servers only +4. **Updates**: Keep SSH software updated with latest security patches +5. **Backup Keys**: Maintain secure backups of SSH keys +6. **Principle of Least Privilege**: Limit what remote users can do on the system + +## Troubleshooting + +### Common Issues + +1. **Connection Refused** + - Check if SSH service is running on management server + - Verify firewall rules + - Confirm SSH key is properly installed + +2. **Authentication Failed** + - Verify SSH key is correct + - Check file permissions (600 for private key) + - Ensure authorized_keys has correct permissions + +3. **Tunnel Not Establishing** + - Check network connectivity + - Verify management server hostname/IP + - Review daemon logs for error messages + +### Log Files + +- ViewTouch integrated: `/var/log/viewtouch/viewtouch.log` +- Standalone daemon: `/var/log/viewtouch/reverse_ssh_daemon.log` +- System logs: `journalctl -u reverse-ssh-daemon` + +### Debug Mode + +Run daemon in foreground for debugging: + +```bash +sudo vt_reverse_ssh stop +sudo reverse_ssh_daemon -f -c /etc/viewtouch/reverse_ssh.conf +``` + +## Advanced Configuration + +### Custom SSH Options + +For advanced SSH configurations, modify the SSH command generation in the source code or create custom wrapper scripts. + +### Multiple Tunnels + +Configure multiple reverse SSH daemons for different services (SSH, HTTP, etc.) by creating separate configuration files and systemd services. + +### Port Forwarding + +The reverse SSH tunnel can forward additional ports: + +```bash +# Forward additional ports in the SSH command +ssh -R 2222:localhost:22 -R 8080:localhost:80 user@management-server +``` + +## API Integration + +The reverse SSH service can be integrated with monitoring systems via the status reporting functionality. The service provides health status and tunnel information that can be queried programmatically. + +## Multiple Location Management + +### Identifying Different Locations + +When multiple ViewTouch systems connect to your management computer, you need ways to distinguish them: + +#### 1. **Location-Based Configuration Files** +```bash +# Each location gets its own config file +/etc/viewtouch/reverse_ssh.conf # Default +/etc/viewtouch/reverse_ssh_downtown.conf # Downtown location +/etc/viewtouch/reverse_ssh_mall.conf # Mall location +/etc/viewtouch/reverse_ssh_airport.conf # Airport location +``` + +#### 2. **Port-Based Separation** +Each location uses a different port on your management server: +- Downtown: `ssh -p 2222 localhost` +- Mall: `ssh -p 2223 localhost` +- Airport: `ssh -p 2224 localhost` + +#### 3. **Location Names in Logs** +```bash +sudo vt_reverse_ssh_setup status +# Output: +# Ngrok tunnel active for downtown: tcp://0.tcp.ngrok.io:2222 +# Ngrok tunnel active for mall: tcp://0.tcp.ngrok.io:2223 +# Ngrok tunnel active for airport: tcp://0.tcp.ngrok.io:2224 +``` + +#### 4. **Custom Hostnames (Advanced)** +For dedicated servers, use different subdomains: +- `downtown.yourcompany.com:22` +- `mall.yourcompany.com:22` +- `airport.yourcompany.com:22` + +### Best Practices for Multiple Locations + +1. **Use descriptive names**: `downtown_main`, `mall_foodcourt`, `airport_terminal2` +2. **Document port assignments**: Keep a list of which port belongs to which location +3. **Regular monitoring**: Use `vt_reverse_ssh_setup status` to check all tunnels +4. **Organized configs**: Each location's config file contains its specific settings +5. **Backup configurations**: Save your tunnel configurations for quick recovery + +### Example Multi-Location Workflow + +```bash +# Initial setup for three locations +sudo vt_reverse_ssh_setup ngrok downtown_restaurant +sudo vt_reverse_ssh_setup ngrok mall_foodcourt +sudo vt_reverse_ssh_setup ngrok airport_terminal + +# Daily monitoring +sudo vt_reverse_ssh_setup status + +# Troubleshooting specific location +sudo vt_reverse_ssh_setup stop downtown_restaurant +sudo vt_reverse_ssh_setup ngrok downtown_restaurant + +# Emergency access +ssh -p 2222 localhost # Downtown +ssh -p 2223 localhost # Mall +ssh -p 2224 localhost # Airport +``` + +## Alternative Approaches for Personal Use + +### When You Don't Have a Management Server + +#### Option 1: Use Your Own Computer +- Turn your personal computer into a temporary management server +- Requires your computer to be accessible from the internet +- Best for technical users who can configure their own SSH server + +#### Option 2: Public Tunneling Services +**Serveo** (Free, SSH-based): +```bash +# Start tunnel (gives you subdomain.serveo.net:port) +ssh -R 80:localhost:22 serveo.net +``` + +**Ngrok** (Free tier available): +```bash +# Download and start +./ngrok tcp 22 +# Gives you: tcp://0.tcp.ngrok.io:port +``` + +**LocalTunnel** or **Cloudflare Tunnel** are other alternatives. + +#### Option 3: Commercial Services +- **Tailscale** or **ZeroTier** for mesh networking +- **AWS Lightsail**, **DigitalOcean Droplet** as personal management server +- **VPN services** with port forwarding + +### Quick Personal Setup (Automated) + +ViewTouch provides an automated setup script that supports **multiple locations**: + +```bash +# Easy setup with ngrok (recommended) +sudo vt_reverse_ssh_setup ngrok + +# For multiple locations, specify location names: +sudo vt_reverse_ssh_setup ngrok downtown_restaurant +sudo vt_reverse_ssh_setup ngrok mall_location +sudo vt_reverse_ssh_setup ngrok airport_store + +# Each location gets its own tunnel and configuration + +# Alternative: Use your own computer as server +sudo vt_reverse_ssh_setup personal downtown_restaurant +sudo vt_reverse_ssh_setup personal mall_location + +# Check status for all locations +sudo vt_reverse_ssh_setup status + +# Stop specific location +sudo vt_reverse_ssh_setup stop downtown_restaurant + +# Stop all locations +sudo vt_reverse_ssh_setup stop +``` + +### Managing Multiple Locations + +When you have multiple ViewTouch systems connecting to your computer: + +1. **Use descriptive location names** for each setup +2. **Each location gets separate config files** (`/etc/viewtouch/reverse_ssh_[location].conf`) +3. **Monitor all tunnels** with `vt_reverse_ssh_setup status` +4. **Connect to specific locations** using their assigned ports + +#### Example Multi-Location Setup: + +```bash +# Terminal 1: Setup downtown restaurant +sudo vt_reverse_ssh_setup ngrok downtown +# Gets port 2222, config: reverse_ssh_downtown.conf + +# Terminal 2: Setup mall location +sudo vt_reverse_ssh_setup ngrok mall +# Gets port 2223, config: reverse_ssh_mall.conf + +# Check all tunnels +sudo vt_reverse_ssh_setup status +# Shows: downtown (port 2222), mall (port 2223) + +# Connect to downtown location +ssh -p 2222 localhost + +# Connect to mall location +ssh -p 2223 localhost +``` + +### Manual Setup (Advanced) + +If you prefer manual setup: + +```bash +# 1. Install ngrok +wget https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-amd64.tgz +tar xvf ngrok-v3-stable-linux-amd64.tgz + +# 2. Start ngrok tunnel +./ngrok tcp 22 & +# Note the assigned address: tcp://0.tcp.ngrok.io:XXXXX + +# 3. Configure ViewTouch +sudo nano /etc/viewtouch/reverse_ssh.conf +# Set: management_server=0.tcp.ngrok.io +# Set: management_port=XXXXX (the port ngrok gave you) + +# 4. Start ViewTouch +sudo /usr/viewtouch/bin/vtpos + +# 5. Connect back +ssh -p XXXXX localhost +``` + +## Support + +For support with reverse SSH tunnel configuration: + +1. Check the logs for error messages +2. Verify network connectivity +3. Test SSH connection manually +4. Review firewall configurations +5. Contact ViewTouch support with log excerpts diff --git a/docs/changelog.md b/docs/changelog.md index 11f71c7d..693734d8 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -7,184 +7,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [Unreleased] ### Changed -- **Macro → Enum: Zone Types (2025-12-23)** - - Replaced `ZONE_*` zone type `#define` macros with a single `enum ZoneType` preserving all identifiers and numeric values - - Improves type safety and discoverability while maintaining full backward compatibility (implicit conversion to `int` where needed) - - **Files modified**: `zone/pos_zone.hh` - - **Impact**: No functional change; build and all tests remain green (40/40) - -- **Macro → Enum: Print Modes (2025-12-23)** - - Replaced `PRINT_*` style `#define` macros with `enum PrintModeFlags` in `printer.hh` - - Removed duplicated `PRINT_*` macros from `report.hh` and included `printer.hh` instead - - Preserved all bitmask values for backward compatibility with existing flag operations - - **Files modified**: `main/hardware/printer.hh`, `main/ui/report.hh` - - **Impact**: No functional change; build and all tests remain green (40/40) - -- **Macro → Enum: Receipt Constants (2025-12-23)** - - Converted receipt copy selection constants to `enum ReceiptCopy` (`RECEIPT_PICK`, `RECEIPT_CUSTOMER`, `RECEIPT_MERCHANT`) in `credit.hh` - - Converted receipt printing options to `enum ReceiptPrintMode` (`RECEIPT_NONE`, `RECEIPT_SEND`, `RECEIPT_FINALIZE`, `RECEIPT_BOTH`) in `settings.hh` - - Preserved numeric values and identifiers for compatibility with existing code paths and bitwise checks - - **Files modified**: `main/data/credit.hh`, `main/data/settings.hh` - - **Impact**: No functional change; build and all tests remain green (40/40) - -- **Enum Usage: Settings Formats (PriceRounding, MeasureSystem, DateFormat, NumberFormat, TimeFormat) (2025-12-23)** - - Completed migration of user-facing format settings to type-safe enums with display helpers - - Added `MeasureSystemType` enum (Standard/Metric) and `GetMeasureSystemDisplayName`, `GetAllMeasureSystems` helpers - - Added `GetPriceRoundingDisplayName` and `GetAllPriceRoundingOptions` helpers for `PriceRoundingType` - - Added `GetAllDateFormats` and `GetAllNumberFormats` helpers to complete existing enums - - Fixed enum value mismatches: Updated TimeFormat, DateFormat, NumberFormat to match actual #define values (1-based, not 0-based) - - Replaced legacy array-based cycling with enum-driven approach using `vt::GetEnumValues` for all five settings types - - Removed legacy `RoundingName/Value`, `MeasureSystemName/Value`, `DateFormatName/Value`, `NumberFormatName/Value`, `TimeFormatName/Value` arrays - - **Files modified**: `main/data/settings_enums.hh`, `main/data/settings.cc`, `main/data/settings.hh`, `zone/settings_zone.cc` - - **Impact**: Behavior unchanged; build and all tests remain green (40/40) - -- **Enum Usage: ReceiptPrintType (2025-12-23)** - - Updated receipt printing logic to use `ReceiptPrintType` via `vt::IntToEnum` instead of bitmask checks - - Conditions now compare against `OnSend`/`OnFinalize`/`OnBoth` for clarity and type-safety - - Replaced legacy arrays `ReceiptPrintName`/`ReceiptPrintValue` with enum-driven helpers and switching logic - - **Files modified**: `main/business/check.cc`, `zone/payment_zone.cc`, `zone/settings_zone.cc`, `main/data/settings.cc`, `main/data/settings.hh` - - **Impact**: Behavior unchanged; tests remain 40/40 passing - -- **Enum Usage: DrawerPrintType (2025-12-23)** - - Converted drawer print options to enum-driven flow: added `DrawerPrintType` and display helpers - - Removed legacy `DrawerPrintName`/`DrawerPrintValue` arrays; UI display/cycle now uses enum values - - Updated drawer print execution paths to use `DrawerPrintType` instead of macros/arrays - - **Files modified**: `main/data/settings_enums.hh`, `main/data/settings.hh`, `main/data/settings.cc`, `zone/settings_zone.cc`, `zone/drawer_zone.cc` - - **Impact**: Behavior unchanged; build and all tests remain green (40/40) - -- **Enum Usage: DrawerModeType (2025-12-23)** - - Migrated drawer mode selection to `DrawerModeType` with enum display helpers - - Removed legacy `DrawerModeName`/`DrawerModeValue` arrays; settings UI now cycles via enum values using `vt::GetEnumValues` - - Preserved numeric values for compatibility with persisted settings and existing logic - - **Files modified**: `main/data/settings_enums.hh`, `main/data/settings.cc`, `zone/settings_zone.cc` - - **Impact**: Behavior unchanged; build and all tests remain green (40/40) - -- **Macro → Enum: Printer Protocol (2025-12-23)** - - Replaced `PRINTER_*` protocol macros with scoped `enum class PrinterProtocol` and an explicit `ToInt` helper - - Updated remote printer command writes to use enum values instead of macros - - **Files modified**: `src/network/remote_link.hh`, `main/hardware/remote_printer.cc` - - **Impact**: Behavior unchanged; build and all tests remain green (40/40) - -- **Macro → Enum: Server/Op/Window Protocols (2025-12-23)** - - Converted legacy `SERVER_*`, `MODE_*`, and `WINFRAME_*` macros into scoped enums: `ServerProtocol`, `OperationMode`, and `WindowFrame` - - Added `ToInt(...)` helpers and adjusted bitmask composition for window frame flags - - Resolved X11 macro collisions by prefixing enum values (e.g., `SrvButtonPress`, `OpNone`, `FrameMove`) - - Updated send/receive sites in terminal and term modules to use typed enums - - Cleaned up lingering legacy macro references in debug strings, comments, and locale strings - - **Files modified**: `src/network/remote_link.hh`, `main/hardware/terminal.cc`, `term/layer.cc`, `term/term_view.cc`, `term/term_dialog.cc`, `src/core/debug.cc`, `main/data/locale.cc` - - **Impact**: Behavior unchanged; build and all tests remain green (40/40) - -### Fixed -- **Static Analysis Cleanups (2025-12-23)** - - Addressed clang-tidy findings: removed branch-clone in DList merge, added self-assignment guard to `Str`, corrected rounding and narrowing in `test_check`, fixed archive header error handling, and cleaned crash reporting/tests for empty-catch/pointer warnings - - Suppressed analyzer padding noise for large `Settings`/`Terminal` classes and tightened enum underlying types in terminal hardware definitions - - Impact: No behavior change; builds/tests remain green (40/40) -- **Duplicate Branch Cleanup in settings.cc (2025-12-23)** - - Consolidated repeated branch bodies flagged by clang-tidy (bugprone-branch-clone) - - **CouponInfo::Applies methods**: Merged duplicate `retval = 0` assignments by combining conditions with logical OR - - **CouponInfo::AppliesItem**: Unified duplicate return value assignments by grouping related conditions - - **Count methods** (DiscountCount, CouponCount, CreditCardCount, CompCount, MealCount): Replaced four-way if-else chains with single compound conditions - - Pattern changed from: `if (A && B) count++; else if (A && C) count++; ...` - - To: `if ((A || D) && (B || C)) count++;` - - **Authorize method validation**: Combined duplicate `authorize_method = CCAUTH_NONE` assignments - - **Files modified**: `main/data/settings.cc` - - **Impact**: Clearer control flow, reduced code duplication, all 40 tests passing - -- **Critical Bugprone Fixes (2025-12-23)** - - Fixed empty catch blocks that were hiding errors in BackTraceFunction (fntrace.hh) - - Added error logging with `std::fprintf(stderr, ...)` to track memory corruption issues - - Changed from silently ignoring to logging warnings while still preventing crashes - - Fixed narrowing conversion warnings that could cause data loss - - **Order count conversions** (manager.cc lines 2858, 2860): Fixed int→short narrowing when parsing ItemQTY/ProductQTY - - Added bounds checking: `static_cast(std::min(atoi(value), 32767))` - - Prevents overflow when order quantities exceed short range - - **Socket read conversion** (manager.cc line 3264): Fixed ssize_t→int narrowing for read() return - - Changed to: `ssize_t read_result = read(...); bytes_read = static_cast(std::min(read_result, static_cast(INT_MAX)))` - - Prevents data loss when read returns values larger than INT_MAX - - **Files modified**: `src/utils/fntrace.hh`, `main/data/manager.cc` - - **Impact**: Improved error visibility and prevented potential data corruption from type conversions - -- **Logging System Test Failure (2025-12-23)** - - Fixed persistent "Log File Output" test failure to achieve 40/40 passing tests - - **Root cause**: Test directory `/tmp/viewtouch_test_logs` was shared across all tests, causing log accumulation and initialization conflicts - - **Solution**: - - Modified "Log File Output" test to use dedicated directory `/tmp/viewtouch_test_logs_file_output` - - Fixed structured logger initialization to support both async (production) and synchronous (test) modes - - Added per-SECTION shutdown calls to properly reinitialize logger between test sections - - Changed `spdlog::shutdown()` to `spdlog::drop_all()` in `Shutdown()` to allow logger reinitialization within the same process - - Set JSON sink pattern to `"%v"` instead of empty string to ensure JSON output is written - - Changed structured log file from truncate to append mode to preserve test output - - **Files modified**: - - `src/utils/vt_logger.cc`: - - Created separate `structured_logger_` for JSON-only output - - Initialize both main and structured loggers with proper async/sync configuration based on test mode - - Enhanced `Flush()` to flush both logger instances - - Replaced `spdlog::shutdown()` with `spdlog::drop_all()` for proper cleanup - - `tests/unit/test_enhanced_logging.cc`: - - Use unique test directory to isolate test from other logging tests - - Added `#include ` for debug output (later removed) - - Call `Shutdown()` at end of each SECTION to enable proper reinitialization - - **Impact**: All 40 tests now pass consistently; logging system properly writes structured JSON and human-readable logs to separate files - -### Added -- **Duplicate Branch Cleanup (2025-12-22)** - - Removed duplicated branch bodies flagged by clang-tidy (bugprone-branch-clone) - - **Files modified**: - - `main/data/manager.cc`: - - Consolidated `EndSystem()` after `fork()` for error/parent paths - - Merged repeated `ProcessRemoteOrderEntry()` else-if branches into a single combined condition - - `zone/button_zone.cc`: - - Merged duplicate `Signal()` send branches in `ConditionalZone::Touch` - - Unified `KillSystemZone::Render()` to a single `RenderZone` call - - Grouped `MessageButtonZone::Signal` cases by behavior to avoid repeated bodies - - Combined `FASTFOOD`/`SELFORDER` cases in `ConditionalZone::EvalExp` - - `zone/dialog_zone.cc`: - - Consolidated keyboard handling to map key codes to a single `Signal()` path (prevents repeated return branches) - - `zone/creditcard_list_zone.cc`: - - Replaced repeated switch branches in `GetDB()` with direct mapping - - **Impact**: Clearer control flow, less chance of divergence and maintenance errors - -- **Duplicate Branch Cleanup (2025-12-23)** - - Continued removing duplicated branch bodies flagged by clang-tidy (bugprone-branch-clone) - - **Files modified**: - - `zone/check_list_zone.cc`: - - Merged `search` and `nextsearch` cases in `CheckEditZone::Signal()` into a single shared implementation - - Unified `CheckListZone::Signal()` handling for `search`/`nextsearch` by computing offsets and start employee - - Factored `is_open_like` boolean in `CheckListZone::Render()` for time display clarity - - `zone/dialog_zone.cc`: - - `CreditCardDialog::Keyboard()`: Mapped key inputs to actions (voice, print) with unified return paths - - `OpenTabDialog::Keyboard()`: Collapsed repeated `Signal()` branches using a single command mapping; tab cycling remains explicit - - `zone/login_zone.cc`: - - `LoginZone::Keyboard()`: Unified non-digit key handling to a single `Signal()` path - - `LogoutZone::Keyboard()`: Unified mapping of backspace/cancel to a single `Signal()` path - - `zone/report_zone.cc`: - - `ReportZone::Keyboard()`: Mapped navigation keys to a `delta` for page changes; unified control flow - - `ReadZone::Keyboard()`: Same `delta` mapping for navigation; unified returns - - `zone/search_zone.cc`: - - `SearchZone::Keyboard()`: Merged identical Enter/Escape handling into one branch - - `zone/drawer_zone.cc`: - - `DrawerManageZone::Keyboard()`: Collapsed navigation to a `delta` with early returns for other keys - - **Impact**: Reduced duplication and simplified search control flow - -- **Missing Default Cases in Switch Statements (2025-12-22)** - - Added default cases to 3 switch statements that were missing them (bugprone-switch-missing-default-case) - - **Files modified**: - - `main/data/manager.cc` (line 1555): Added default case to X11 event type switch - - `zone/zone.cc` (lines 535, 554): Added default cases to page size and type switches with safe fallback values - - `zone/dialog_zone.cc` (lines 181, 201): Added default cases to dialog action type switches - - **Impact**: Improved code safety by ensuring all switch statements have explicit handling for unexpected values - - **Note**: This addresses potential issues where unhandled enumeration values could lead to uninitialized variables or unexpected behavior - -### Changed -- **C-Array Modernization (2025-12-23)** - - Converted fixed-size C-style buffers to `std::array` in manager.cc - - **Details**: - - Replaced `font_spec_with_dpi[256]`, `font_spec[256]`, `font_family[256]`, and local `line[256]` with `std::array` - - Updated calls to use `.data()` and `.size()` with `snprintf`, `fgets`, `strcmp`, and `strncpy` - - Preserved existing behavior and ABI by returning `const char*` via `.data()` - - **Files modified**: `main/data/manager.cc` - - **Impact**: Safer buffer handling with compile-time bounds, no behavior changes; all tests pass - - **Editor Settings Button Split and Password Function Removal (2025-12-XX)** - **Split Editor Settings**: Separated "Editor Settings" functionality into two distinct buttons for better organization - **Editor Settings** button (`ZONE_DEVELOPER`) now contains only: @@ -234,108 +56,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Maintains all existing functionality while significantly improving visual clarity - **Files modified**: `main/ui/system_salesmix.cc` -### Fixed -- **Narrowing Conversion Safety Fixes (12-22-2025)** - - Applied bugprone-narrowing-conversions fixes to prevent type conversion bugs and unintended value changes - - **Key Fixes**: - - [manager.cc#L2969](main/data/manager.cc#L2969): Changed `float interm = atof(cost)` to `double` (atof returns double, not float) - - [manager.cc#L3088-3089](main/data/manager.cc#L3088-L3089): Changed strlen result variables from `int` to `size_t` for proper unsigned handling - - [zone.cc#L1274](zone/zone.cc#L1274): Added explicit `static_cast` for Page size assignment - - [zone.cc#L1496](zone/zone.cc#L1496): Added explicit `static_cast` for strlen result assignment - - [user_edit_zone.cc#L739](zone/user_edit_zone.cc#L739): Added explicit `static_cast` for FormField Set() call with int parameter - - **Impact**: Eliminated clang-tidy bugprone-narrowing-conversions warnings across core files; improved type safety and prevented potential data loss from implicit conversions - - **Verification**: Build successful, all 40 tests passing - - **Files modified**: `main/data/manager.cc`, `zone/zone.cc`, `zone/user_edit_zone.cc` - -- **Comprehensive C-Array Modernization in manager.cc (12-22-2025)** - - Applied clang-tidy modernize-avoid-c-arrays fixes to convert all remaining C-style buffers to std::array - - **Scope**: Complete modernization of manager.cc focusing on: - - Terminal parsing and dynamic terminal management (SetTermInfo, OpenDynTerminal, CloseDynTerminal, CloneDynTerminal) - - Remote order processing (ProcessRemoteOrder, SendRemoteOrderResult, GetCCData, FindCCData) - - Socket request handling (ProcessSocketRequest, ReadSocketRequest) - - Background command/report execution (RunUserCommand, UserCount, RunReport) - - System startup resource loading (StartSystem resource file paths and format buffers) - - **Key Conversions**: - - Terminal info buffers: `termtype`, `printhost`, `printmodl`, `numdrawers` → std::array with .data() access - - Remote order KV parsing: `key`, `value`, `StoreNum`, `cardnum`, `camount`, `cn` → std::array with safe string ops - - Socket request buffers: `request`, `result_str`, `str` → std::array with proper size tracking - - Message/format buffers: `msg`, `report_name`, `report_from`, `report_to` → std::array with .data()/.size() - - System path buffers: All FullPath calls now use `.data()` for C API compatibility - - **Legacy API Compatibility**: Maintained compatibility with existing function signatures expecting raw pointers by using `.data()` and `.size()` methods - - **Verification**: Build successful with no new errors or warnings; existing tests remain passing - - **Impact**: Improved memory safety with compile-time bounds checking, eliminated remaining clang-tidy modernize-avoid-c-arrays warnings in manager.cc - - **Files modified**: `main/data/manager.cc` (extensive conversion throughout multiple function families) - -- **Extended C++ Modernizations - Phase 2 (12-22-2025)** - - Applied clang-tidy-driven fixes: modernize-use-auto, modernize-deprecated-headers, modernize-redundant-void-arg, modernize-loop-convert, modernize-return-braced-init-list, modernize-use-default-member-init, modernize-raw-string-literal - - Highlights: auto for new/cast allocations; errno.h → cerrno in [zone/zone.cc](zone/zone.cc) and [main/data/manager.cc](main/data/manager.cc); removed redundant void args in [main/data/manager.cc](main/data/manager.cc); range-based for loops in [main/data/manager.cc](main/data/manager.cc), [main/data/settings.cc](main/data/settings.cc), [term/term_dialog.cc](term/term_dialog.cc); braced init returns in [src/utils/safe_string_utils.hh](src/utils/safe_string_utils.hh); default member init in [src/utils/fntrace.hh](src/utils/fntrace.hh); raw string literal formatting in [main/data/manager.cc](main/data/manager.cc) - - Verification: Build successful; Tests 40/40 passing - - Impact: 28 files modified, 182 insertions, 184 deletions -- **Additional C++ Modernizations (12-22-2025)** - - Applied targeted modernization fixes to improve code quality and C++ compliance - - **modernize-use-using**: Replaced 3 C-style typedef declarations with modern using aliases - - Converted function pointer typedefs in [main/data/manager.hh](main/data/manager.hh): - - `typedef void (* TimeOutFn)()` → `using TimeOutFn = void (*)()` - - `typedef void (* InputFn)()` → `using InputFn = void (*)()` - - `typedef int (* WorkFn)()` → `using WorkFn = int (*)()` - - Benefits: Clearer syntax, better readability, consistent with modern C++ style - - **modernize-macro-to-enum**: Converted 6 VERSION macros to constexpr constants - - `ACCOUNT_VERSION`, `ACCOUNT_ENTRY_VERSION` in [main/business/account.hh](main/business/account.hh) - - `CHECK_VERSION` in [main/business/check.hh](main/business/check.hh) - - `CUSTOMER_VERSION` in [main/business/customer.hh](main/business/customer.hh) - - `WORK_VERSION` in [main/business/labor.hh](main/business/labor.hh) - - `SALES_ITEM_VERSION` in [main/business/sales.hh](main/business/sales.hh) - - `TIP_VERSION` in [main/business/tips.hh](main/business/tips.hh) - - Benefits: Type safety, proper scoping, debugger-friendly, no preprocessor pollution - - **modernize-use-nodiscard**: Applied [[nodiscard]] attributes to functions with important return values - - Automatically applied using clang-tidy --fix across entire codebase - - Affected headers: [src/core/time_info.hh](src/core/time_info.hh), [src/utils/utility.hh](src/utils/utility.hh), [src/utils/vt_logger.hh](src/utils/vt_logger.hh), [main/hardware/terminal.hh](main/hardware/terminal.hh), and others - - Prevents accidental ignoring of return values (e.g., IsEmpty(), Count(), Search()) - - Benefits: Compile-time warnings when important return values are discarded, fewer bugs - - **Verification**: - - Build: Successful with no errors - - Tests: 40/40 passing - - Impact: 15 files modified, 81 insertions(+), 81 deletions(-) - - **Remaining opportunities**: 2,065 trailing-return-type suggestions (stylistic), 794 macro-to-enum candidates (requires careful refactoring), 178 C-array suggestions - -- **Comprehensive nullptr Modernization (12-22-2025)** - - **Complete C++ Modernization**: Replaced all `NULL` pointer literals with modern C++ `nullptr` across the entire codebase - - **Scope**: 123 files modified with ~3,413 insertions and 3,427 deletions - - **Coverage**: - - `zone/` directory: 58 files modernized (completed first with ~1,640 lines changed) - - `main/` directory: 30 files (1,217+ NULL occurrences replaced) - - `term/` directory: 8 files (106+ NULL occurrences replaced) - - `src/` directory: 24 files (7+ NULL occurrences replaced) - - `loader/` and `cdu/` directories: 1 file each - - **Methodology**: - - Initial clang-tidy analysis identified 1,332+ NULL occurrences across the codebase - - Applied `modernize-use-nullptr` check with `-fix` and `-fix-errors` flags to all source files - - Automated fixes applied in batches (zone → main → term → src → loader/cdu) - - Manual fixes for 6 edge cases (header default parameters, complex expressions) - - Fixed header guard bug in `zone/form_zone.hh` (mismatch between `#ifndef _FORM_ZONE_HH` and `#define FORM_ZONE_HH`) - - **Verification**: - - Build: Successful (all targets built cleanly) - - Tests: 40/40 passing after all changes - - NULL in code: 0 occurrences remaining (only in comments, excluded from conversion) - - **Benefits**: - - Improved type safety: `nullptr` has type `std::nullptr_t` instead of integer 0 - - Better overload resolution: eliminates ambiguity in function calls with pointer/integer overloads - - Clearer intent: `nullptr` explicitly indicates pointer context - - Modern C++ compliance: aligns codebase with C++11+ standards - - **Files modified**: All 123 modified files tracked in version control, including comprehensive changes across `zone/`, `main/`, `term/`, `src/`, `loader/`, and `cdu/` directories - -- **Clang-tidy & static analysis fixes (12-21-2025)** - - Performed a focused `clang-tidy` and `clang-analyzer` triage and applied multiple correctness, safety, and style fixes across the codebase. - - Key actions: - - **Project config:** Added a project `.clang-tidy` file to scope checks to project headers and prioritize the most valuable diagnostics (clang-analyzer, bugprone, performance, modernize-use-override). - - **Override audit:** Applied `modernize-use-override` conservatively across many `zone/*.hh` headers and other types where safe; examples include `zone/printer.hh`, `zone/cdu_zone.hh`, `zone/report_zone.hh`, `zone/dialog_zone.hh`, `zone/button_zone.hh`, `zone/account_zone.hh`, `zone/chart_zone.hh`, `zone/drawer_zone.hh`, and `zone/creditcard_list_zone.hh`. Incorrect or non-matching `override` annotations were removed during iterative fixes. - - **Safety & style fixes:** Replaced common issues reported by clang-tidy (e.g., removed reserved identifier header guards, `bzero` → `memset`, use `= default` for trivial destructors where appropriate) and fixed several small logic/warning cases found while making changes. - - **Incremental approach:** Changes were applied file-by-file in small commits; each change was followed by a build and unit test run to limit regressions. - - Status: - - Build and tests verified after edits: **40/40 tests passing** after nullptr modernization and logging fixes - - Zone header audit and follow-up analyzer passes complete. Representative files modified include `main/business/check.cc`, `src/network/socket.cc`, many headers under `main/`, `src/`, and `zone/`, plus the newly added `.clang-tidy`. - - ### Fixed - **Build System Compilation Errors and Warnings (12-13-2025)** - Fixed critical build failures caused by compiler warnings being treated as errors @@ -707,9 +427,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - `CMakeLists.txt` ### Removed -- **Reverse SSH Tunnel Removal (2025-12-21)** - - **Removal**: Removed the Reverse SSH subsystem (service implementation, standalone daemon, management scripts, systemd unit, configuration files, and documentation). - - **Notes**: Also removed related settings fields and build/install rules; implementation relied on the system OpenSSH client and was removed to simplify the codebase. - **Texture Loading System Removal (2025-12-XX)** - **Removal**: Completely removed all texture loading and management systems - **Implementation**: diff --git a/loader/loader_main.cc b/loader/loader_main.cc old mode 100644 new mode 100755 index 6750aaa1..fbaabc72 --- a/loader/loader_main.cc +++ b/loader/loader_main.cc @@ -439,8 +439,8 @@ XtAppContext InitializeDisplay(int argc, char **argv) XtToolkitInitialize(); XtAppContext app = XtCreateApplicationContext(); - Dis = XtOpenDisplay(app, nullptr, nullptr, nullptr, nullptr, 0, &argc, argv); - if (Dis == nullptr) + Dis = XtOpenDisplay(app, NULL, NULL, NULL, NULL, 0, &argc, argv); + if (Dis == NULL) { logmsg(LOG_ERR, "Unable to open display\n"); ExitLoader(); @@ -451,7 +451,7 @@ XtAppContext InitializeDisplay(int argc, char **argv) ColorWhite = WhitePixel(Dis, screen_no); loaderFont = XftFontOpenName(Dis, screen_no, FONT_NAME); - if (loaderFont == nullptr) + if (loaderFont == NULL) { logmsg(LOG_ERR, "Unable to load font\n"); ExitLoader(); @@ -478,7 +478,7 @@ Widget OpenStatusBox(XtAppContext app) { (String)"mappedWhenManaged", False }, }; - Widget shell = XtAppCreateShell("Welcome to POS", nullptr, + Widget shell = XtAppCreateShell("Welcome to POS", NULL, applicationShellWidgetClass, Dis, args, XtNumber(args)); XtRealizeWidget(shell); @@ -489,8 +489,8 @@ Widget OpenStatusBox(XtAppContext app) XftColorAllocName(Dis, DefaultVisual(Dis, screen_no), DefaultColormap(Dis, screen_no), "white", &xftWhite); - XtAddEventHandler(shell, ExposureMask, FALSE, ExposeCB, nullptr); - XtAddEventHandler(shell, KeyPressMask, FALSE, KeyPressCB, nullptr); + XtAddEventHandler(shell, ExposureMask, FALSE, ExposeCB, NULL); + XtAddEventHandler(shell, KeyPressMask, FALSE, KeyPressCB, NULL); return shell; } @@ -502,7 +502,7 @@ bool WriteArgList(const int argc, char* argv[]) std::ofstream fout(COMMAND_FILE, std::fstream::trunc); if (!fout.is_open()) { - std::cout << msg_base + "error while opening file '" + COMMAND_FILE + "'" << '\n'; + std::cout << msg_base + "error while opening file '" + COMMAND_FILE + "'" << std::endl; return false; } @@ -517,7 +517,7 @@ bool WriteArgList(const int argc, char* argv[]) if (ret != 0) { std::cout << msg_base + "error while modifying permissions for file '" - << COMMAND_FILE << "'" << '\n'; + << COMMAND_FILE << "'" << std::endl; return false; } return true; @@ -611,7 +611,7 @@ int main(int argc, genericChar* argv[]) { std::cout << viewtouch::get_project_name() << " " << viewtouch::get_version_info() - << '\n'; + << std::endl; exit(1); } } @@ -620,7 +620,7 @@ int main(int argc, genericChar* argv[]) // the system if (!WriteArgList(argc, argv)) { - std::cout << "Error while writing argument file for vt_main" << '\n'; + std::cout << "Error while writing argument file for vt_main" << std::endl; return 1; } @@ -655,7 +655,7 @@ int main(int argc, genericChar* argv[]) // Read Status Messages XtAppAddInput(appContext, SocketNo, (XtPointer) XtInputReadMask, - (XtInputCallbackProc) SocketInputCB, nullptr); + (XtInputCallbackProc) SocketInputCB, NULL); XEvent event; for (;;) diff --git a/main/business/account.cc b/main/business/account.cc index 96f31b65..02ed5f67 100644 --- a/main/business/account.cc +++ b/main/business/account.cc @@ -137,7 +137,7 @@ Account::Account(const char* path, int no, const genericChar* namestr) Account *Account::Copy() { FnTrace("Account::Copy()"); - auto *newAccount = new Account(); + Account *newAccount = new Account(); newAccount->number = number; newAccount->name.Set(name); @@ -322,7 +322,7 @@ AccountDB::AccountDB() // be set in manager.cc->StartSystem() low_acct_num = 1000; high_acct_num = 9999; - curr_item = nullptr; + curr_item = NULL; } // Member Functions @@ -333,12 +333,12 @@ int AccountDB::GetAccountNumber(int number) int retval = ACCOUNT_FIRST_NUMBER; Account *my_account = account_list.Head(); - while (my_account != nullptr) + while (my_account != NULL) { if ((my_account->number > number) && (my_account->number > retval)) { - my_account = nullptr; // exit the loop + my_account = NULL; // exit the loop } else { @@ -370,11 +370,11 @@ int AccountSort(Account *acct1, Account *acct2) int AccountDB::RemoveBlank() { FnTrace("AccountDB::RemoveBlank()"); - Account *nextAcct = nullptr; + Account *nextAcct = NULL; Account *currAcct = account_list.Head(); int count = 0; - while (currAcct != nullptr) + while (currAcct != NULL) { nextAcct = currAcct->next; if (currAcct->IsBlank()) @@ -418,7 +418,7 @@ int AccountDB::Save() Account *currAcct = account_list.Head(); RemoveBlank(); - while (currAcct != nullptr) + while (currAcct != NULL) { Save(currAcct, 0); currAcct = currAcct->next; @@ -458,11 +458,11 @@ int AccountDB::Load(const char* path) return 1; DIR *dp = opendir(pathname.Value()); - if (dp == nullptr) + if (dp == NULL) return 1; // Error - can't find directory int no = 0; - struct dirent *record = nullptr; + struct dirent *record = NULL; do { record = readdir(dp); @@ -472,7 +472,7 @@ int AccountDB::Load(const char* path) no = atoi(name); if (no > 0) { - auto *my_account = new Account(no); + Account *my_account = new Account(no); if (my_account->Load(pathname.Value())) ReportError("Error loading account"); else @@ -489,7 +489,7 @@ int AccountDB::Load(const char* path) int AccountDB::Add(Account *my_account) { FnTrace("AccountDB::Add()"); - if (my_account == nullptr) + if (my_account == NULL) return 1; Account *list = AccountListEnd(); @@ -502,7 +502,7 @@ int AccountDB::Add(Account *my_account) int AccountDB::AddDefault(Account *my_account) { FnTrace("AccountDB::AddDefault()"); - if (my_account == nullptr) + if (my_account == NULL) return 1; Account *list = DefaultListEnd(); @@ -539,10 +539,10 @@ int AccountDB::Purge() Account *AccountDB::FindByNumber(int no) { FnTrace("AccountDB::FindByNumber()"); - for (Account *my_account = AccountList(); my_account != nullptr; my_account = my_account->next) + for (Account *my_account = AccountList(); my_account != NULL; my_account = my_account->next) if (my_account->number == no) return my_account; - return nullptr; + return NULL; } Account *AccountDB::FindByRecord(int rec_num) @@ -550,14 +550,14 @@ Account *AccountDB::FindByRecord(int rec_num) FnTrace("AccountDB::FindByRecord()"); int count = 0; Account *my_account = account_list.Head(); - Account *return_acct = nullptr; + Account *return_acct = NULL; - while (my_account != nullptr) + while (my_account != NULL) { if (count == rec_num) { return_acct = my_account; - my_account = nullptr; // exit the loop + my_account = NULL; // exit the loop } else { @@ -575,12 +575,12 @@ int AccountDB::FindRecordByNumber(int num) int record = -1; // -1 indicates record was not found Account *currAccount = account_list.Head(); - while (currAccount != nullptr) + while (currAccount != NULL) { if (currAccount->number == num) { record = count; - currAccount = nullptr; // exit the loop + currAccount = NULL; // exit the loop } else { @@ -600,18 +600,18 @@ int AccountDB::FindRecordByWord(const genericChar* word, int record) if (record > 0) { - while ((curr_rec <= record) && (currAcct != nullptr)) + while ((curr_rec <= record) && (currAcct != NULL)) { currAcct = currAcct->next; curr_rec += 1; } } - while (currAcct != nullptr) + while (currAcct != NULL) { if (currAcct->Search(word)) { retval = curr_rec; - currAcct = nullptr; // end the loop + currAcct = NULL; // end the loop } else { @@ -654,7 +654,7 @@ int IsValidAccountNumber(Terminal *term, int number) Account *AccountDB::Next() { FnTrace("AccountDB::Next()"); - if (curr_item == nullptr) + if (curr_item == NULL) curr_item = account_list.Head(); else curr_item = curr_item->next; diff --git a/main/business/account.hh b/main/business/account.hh index eea2259d..2e6ecc4d 100644 --- a/main/business/account.hh +++ b/main/business/account.hh @@ -18,8 +18,8 @@ * Account handling class objects */ -#ifndef ACCOUNT_HH -#define ACCOUNT_HH +#ifndef _ACCOUNT_HH +#define _ACCOUNT_HH #include "terminal.hh" #include "utility.hh" @@ -27,9 +27,9 @@ #include -constexpr int ACCOUNT_VERSION = 1; -constexpr int ACCOUNT_ENTRY_VERSION = 1; -constexpr int ACCOUNT_FIRST_NUMBER = 1000; // no account number should be below this +#define ACCOUNT_VERSION 1 +#define ACCOUNT_ENTRY_VERSION 1 +#define ACCOUNT_FIRST_NUMBER 1000 // no account number should be below this /**** Types ****/ class InputDataFile; @@ -52,7 +52,7 @@ public: // Member Functions int Read(InputDataFile &df, [[maybe_unused]] int version); int Write(OutputDataFile &df, [[maybe_unused]] int version); - [[nodiscard]] int Search(const std::string &word) const; + int Search(const std::string &word) const; }; class Account diff --git a/main/business/check.cc b/main/business/check.cc index 6eeee9c6..b7aa8d0a 100644 --- a/main/business/check.cc +++ b/main/business/check.cc @@ -28,7 +28,6 @@ #include "data_file.hh" #include "system.hh" #include "settings.hh" -#include "main/data/settings_enums.hh" #include "data_persistence_manager.hh" #include "inventory.hh" #include "labels.hh" @@ -45,7 +44,6 @@ #include #include #include -#include #include #include #include @@ -62,7 +60,7 @@ static const genericChar* EmptyStr = ""; -const genericChar* CheckStatusName[] = { "Open", "Closed", "Voided", nullptr }; +const genericChar* CheckStatusName[] = { "Open", "Closed", "Voided", NULL }; int CheckStatusValue[] = { CHECK_OPEN, CHECK_CLOSED, CHECK_VOIDED, -1 }; int tender_order[] = { @@ -698,7 +696,7 @@ int Check::SendWorkOrder(Terminal *term, int printer_target, int reprint) auto report = std::make_unique(); Printer *printer = term->FindPrinter(printer_target); - int retval = PrintWorkOrder(term, report.get(), printer_target, reprint, nullptr, printer); + int retval = PrintWorkOrder(term, report.get(), printer_target, reprint, NULL, printer); if (report->is_complete && printer != nullptr && retval == 0) retval = report->FormalPrint(printer); @@ -713,7 +711,7 @@ int Check::SendWorkOrder(Terminal *term, int printer_target, int reprint) if (altprinter && altprinter != printer) { retval = PrintWorkOrder(term, report.get(), printer_target, reprint, - nullptr, altprinter); + NULL, altprinter); if (report->is_complete && retval == 0) retval = report->FormalPrint(altprinter); } @@ -747,7 +745,7 @@ int Check::SetOrderStatus(SubCheck *subCheck, int set_status) if (! (thisOrder->status & set_status)) { change = 1; - thisOrder->status = static_cast(static_cast(thisOrder->status) | set_status); + thisOrder->status |= set_status; } Order *mod = thisOrder->modifier_list; @@ -756,7 +754,7 @@ int Check::SetOrderStatus(SubCheck *subCheck, int set_status) if (!(mod->status & set_status)) { change = 1; - mod->status = static_cast(static_cast(mod->status) | set_status); + mod->status |= set_status; } mod = mod->next; } @@ -766,7 +764,7 @@ int Check::SetOrderStatus(SubCheck *subCheck, int set_status) if (all_subchecks == 1) subCheck = subCheck->next; else - subCheck = nullptr; + subCheck = NULL; } return change; @@ -796,7 +794,7 @@ int Check::ClearOrderStatus(SubCheck *subCheck, int clear_status) if (thisOrder->status & clear_status) { change = 1; - thisOrder->status = static_cast(static_cast(thisOrder->status) & ~clear_status); + thisOrder->status &= ~clear_status; } Order *mod = thisOrder->modifier_list; @@ -805,7 +803,7 @@ int Check::ClearOrderStatus(SubCheck *subCheck, int clear_status) if (mod->status & clear_status) { change = 1; - mod->status = static_cast(static_cast(mod->status) & ~clear_status); + mod->status &= ~clear_status; } mod = mod->next; } @@ -815,7 +813,7 @@ int Check::ClearOrderStatus(SubCheck *subCheck, int clear_status) if (all_subchecks == 1) subCheck = subCheck->next; else - subCheck = nullptr; + subCheck = NULL; } return change; @@ -826,7 +824,7 @@ int Check::FinalizeOrders(Terminal *term, int reprint) FnTrace("Check::FinalizeOrders()"); Settings *settings = &MasterSystem->settings; SubCheck *subCheck = SubList(); - Printer *printer = nullptr; + Printer *printer = NULL; int change = 0; int result = 0; @@ -859,13 +857,8 @@ int Check::FinalizeOrders(Terminal *term, int reprint) { change = SetOrderStatus(subCheck, ORDER_SENT); subCheck->ConsolidateOrders(); - if (change) { - if (auto receipt_mode = vt::IntToEnum(settings->receipt_print)) { - if (*receipt_mode == ReceiptPrintType::OnSend || *receipt_mode == ReceiptPrintType::OnBoth) { - subCheck->PrintReceipt(term, this, printer); - } - } - } + if (change && (settings->receipt_print & RECEIPT_SEND)) + subCheck->PrintReceipt(term, this, printer); subCheck = subCheck->next; } @@ -896,7 +889,7 @@ int Check::Settle(Terminal *term) if (e == nullptr) return 1; - Drawer *d = nullptr; + Drawer *d = NULL; if (! IsTraining()) { d = term->FindDrawer(); @@ -933,7 +926,7 @@ int Check::Close(Terminal *term) return 1; } - Drawer *d = nullptr; + Drawer *d = NULL; if (!IsTraining()) { d = term->FindDrawer(); @@ -1025,8 +1018,6 @@ int Check::GetStatus() case CHECK_VOIDED: ++total_voided; break; - default: - break; } } @@ -1190,9 +1181,14 @@ int Check::PrintWorkOrder(Terminal *term, Report *report, int printer_id, int re // Bar video - check if bar portion was served served_for_target = (flags & CF_BAR_SERVED); } + else if (printer_id == PRINTER_KITCHEN1 || printer_id == PRINTER_KITCHEN2) + { + // Kitchen video - check if kitchen portion was served + served_for_target = (flags & CF_KITCHEN_SERVED); + } else { - // Kitchen and other video targets - check if kitchen portion was served + // Default/other video targets - check if kitchen portion was served served_for_target = (flags & CF_KITCHEN_SERVED); } @@ -1204,9 +1200,14 @@ int Check::PrintWorkOrder(Terminal *term, Report *report, int printer_id, int re // Bar video - clear bar served flag flags &= ~CF_BAR_SERVED; } + else if (printer_id == PRINTER_KITCHEN1 || printer_id == PRINTER_KITCHEN2) + { + // Kitchen video - clear kitchen served flag + flags &= ~CF_KITCHEN_SERVED; + } else { - // Kitchen and other video targets - clear kitchen served flag + // Default/other video targets - clear kitchen served flag flags &= ~CF_KITCHEN_SERVED; } // Also clear CF_SHOWN so the check can be displayed again @@ -1255,12 +1256,12 @@ int Check::PrintWorkOrder(Terminal *term, Report *report, int printer_id, int re } Employee *employee = sys->user_db.FindByID(user_owner); - genericChar str[STRLENGTH] = {'\0'}; - genericChar str1[STRLENGTH] = {'\0'}; - genericChar str2[STRLENGTH] = {'\0'}; - genericChar cststr[STRLENGTH] = {'\0'}; - genericChar ordstr[STRLENGTH] = {'\0'}; - genericChar tmpstr[STRLENGTH] = {'\0'}; + genericChar str[STRLENGTH]; + genericChar str1[STRLENGTH]; + genericChar str2[STRLENGTH]; + genericChar cststr[STRLENGTH]; + genericChar ordstr[STRLENGTH]; + genericChar tmpstr[STRLENGTH]; int pwidth = 80; int kitchen_mode = 0; if (rzone != nullptr) @@ -1341,34 +1342,37 @@ int Check::PrintWorkOrder(Terminal *term, Report *report, int printer_id, int re } vt_safe_string::safe_concat(str, STRLENGTH, term->Translate("Delivery")); break; - default: - break; case CHECK_CATERING: + if (!date.IsSet() || (date <= now)) + { + vt_safe_string::safe_copy(str, STRLENGTH, term->Translate(WAITSTR)); + vt_safe_string::safe_concat(str, STRLENGTH, " "); + } + vt_safe_string::safe_concat(str, STRLENGTH, term->Translate("Catering")); + break; case CHECK_DINEIN: + if (!date.IsSet() || (date <= now)) + { + vt_safe_string::safe_copy(str, STRLENGTH, term->Translate(WAITSTR)); + vt_safe_string::safe_concat(str, STRLENGTH, " "); + } + vt_safe_string::safe_concat(str, STRLENGTH, GlobalTranslate("Here")); + break; case CHECK_TOGO: - case CHECK_CALLIN: if (!date.IsSet() || (date <= now)) { vt_safe_string::safe_copy(str, STRLENGTH, term->Translate(WAITSTR)); vt_safe_string::safe_concat(str, STRLENGTH, " "); } - switch(CustomerType()) + vt_safe_string::safe_concat(str, STRLENGTH, GlobalTranslate("To Go")); + break; + case CHECK_CALLIN: + if (!date.IsSet() || (date <= now)) { - case CHECK_CATERING: - vt_safe_string::safe_concat(str, STRLENGTH, term->Translate("Catering")); - break; - case CHECK_DINEIN: - vt_safe_string::safe_concat(str, STRLENGTH, GlobalTranslate("Here")); - break; - case CHECK_TOGO: - vt_safe_string::safe_concat(str, STRLENGTH, GlobalTranslate("To Go")); - break; - case CHECK_CALLIN: - vt_safe_string::safe_concat(str, STRLENGTH, GlobalTranslate("Pick Up")); - break; - default: - break; + vt_safe_string::safe_copy(str, STRLENGTH, term->Translate(WAITSTR)); + vt_safe_string::safe_concat(str, STRLENGTH, " "); } + vt_safe_string::safe_concat(str, STRLENGTH, GlobalTranslate("Pick Up")); break; } snprintf(str1, static_cast(pwidth), "%s", str); @@ -1647,9 +1651,9 @@ int Check::PrintDeliveryOrder(Report *report, int pwidth) FnTrace("Check::PrintDeliveryOrder()"); int retval = 0; Settings *settings = &MasterSystem->settings; - SubCheck *subcheck = nullptr; - Order *order = nullptr; - Employee *employee = nullptr; + SubCheck *subcheck = NULL; + Order *order = NULL; + Employee *employee = NULL; char ordstr[STRLONG] = ""; [[maybe_unused]] char tmpstr[STRLONG] = ""; // Reserved for future use char str1[STRLONG] = ""; @@ -2039,9 +2043,14 @@ int Check::MakeReport(Terminal *term, Report *report, int show_what, int video_t // Bar video - check if bar portion was served served_for_target = (flags & CF_BAR_SERVED); } + else if (video_target == PRINTER_KITCHEN1 || video_target == PRINTER_KITCHEN2) + { + // Kitchen video - check if kitchen portion was served + served_for_target = (flags & CF_KITCHEN_SERVED); + } else { - // Kitchen and other video targets - check if kitchen portion was served + // Default/other video targets - check if kitchen portion was served served_for_target = (flags & CF_KITCHEN_SERVED); } @@ -2053,9 +2062,14 @@ int Check::MakeReport(Terminal *term, Report *report, int show_what, int video_t // Bar video - clear bar served flag flags &= ~CF_BAR_SERVED; } + else if (video_target == PRINTER_KITCHEN1 || video_target == PRINTER_KITCHEN2) + { + // Kitchen video - clear kitchen served flag + flags &= ~CF_KITCHEN_SERVED; + } else { - // Kitchen and other video targets - clear kitchen served flag + // Default/other video targets - clear kitchen served flag flags &= ~CF_KITCHEN_SERVED; } // Also clear CF_SHOWN so the check can be displayed again @@ -2287,7 +2301,7 @@ int Check::MakeReport(Terminal *term, Report *report, int show_what, int video_t if (video_target == PRINTER_DEFAULT) { - Drawer *d = nullptr; + Drawer *d = NULL; if (archive && archive->DrawerList()) d = archive->DrawerList()->FindBySerial(sc->drawer_id); else if (sys && sys->DrawerList()) @@ -2633,8 +2647,8 @@ SubCheck *Check::NextOpenSubCheck(SubCheck *sc) sc = current_sub; if (sc == nullptr || SubList() == nullptr) { - current_sub = nullptr; - return nullptr; + current_sub = NULL; + return NULL; } int loop = 0; @@ -2647,8 +2661,8 @@ SubCheck *Check::NextOpenSubCheck(SubCheck *sc) // page. If we just keep looping from check to check, always // returning to the beginning, then we'll never get back to // the table page. So if we're at the last subcheck in the - // list, return nullptr; - return nullptr; + // list, return NULL; + return NULL; } else { @@ -2667,24 +2681,24 @@ SubCheck *Check::NextOpenSubCheck(SubCheck *sc) } while (loop < 2); - current_sub = nullptr; - return nullptr; + current_sub = NULL; + return NULL; } TimeInfo *Check::TimeClosed() { FnTrace("Check::TimeClosed()"); - SubCheck *best = nullptr; + SubCheck *best = NULL; for (SubCheck *sc = SubList(); sc != nullptr; sc = sc->next) { if (sc->status == CHECK_OPEN) - return nullptr; + return NULL; if (best == nullptr || best->settle_time < sc->settle_time) best = sc; } if (best == nullptr) - return nullptr; + return NULL; else return &best->settle_time; } @@ -2718,9 +2732,6 @@ int Check::SeatsUsed() int seats[32]; int i; - const int bits_per_int = static_cast(sizeof(int) * 8); - const int max_bits = bits_per_int * static_cast(sizeof(seats) / sizeof(int)); - for (i = 0; i < (int)(sizeof(seats)/sizeof(int)); ++i) seats[i] = 0; @@ -2728,11 +2739,11 @@ int Check::SeatsUsed() for (Order *order = sc->OrderList(); order != nullptr; order = order->next) { s = order->seat; - if (s >= max_bits) + if (s >= (int)(sizeof(seats)*8)) continue; - s1 = s / bits_per_int; - s2 = 1 << (s % bits_per_int); + s1 = s / (sizeof(int)*8); + s2 = 1 << (s % (sizeof(int)*8)); if (!(seats[s1] & s2)) { ++count; @@ -2812,8 +2823,8 @@ const genericChar* Check::PaymentSummary(Terminal *term) case TENDER_COMP: comp = 1; break; case TENDER_EMPLOYEE_MEAL: emeal = 1; break; case TENDER_GIFT: gift = 1; break; - case TENDER_CHARGE_CARD: - case TENDER_CREDIT_CARD: + case TENDER_CHARGE_CARD: credit = 1; break; + case TENDER_CREDIT_CARD: credit = 1; break; case TENDER_DEBIT_CARD: credit = 1; break; case TENDER_ACCOUNT: account = 1; break; case TENDER_CHARGE_ROOM: room = payptr->tender_id; break; @@ -2935,7 +2946,7 @@ int Check::CustomerType(int set) FnTrace("Check::CustomerType()"); if (set >= 0) - type = static_cast(set); + type = set; return type; } @@ -3268,9 +3279,9 @@ SubCheck::SubCheck() SubCheck *SubCheck::Copy(Settings *settings) { FnTrace("SubCheck::Copy(Settings)"); - auto *sc = new SubCheck(); + SubCheck *sc = new SubCheck(); if (sc == nullptr) - return nullptr; + return NULL; sc->status = status; sc->number = number; @@ -3283,10 +3294,10 @@ SubCheck *SubCheck::Copy(Settings *settings) sc->check_type = check_type; for (Order *order = OrderList(); order != nullptr; order = order->next) - sc->Add(order->Copy(), nullptr); + sc->Add(order->Copy(), 0); for (Payment *payptr = PaymentList(); payptr != nullptr; payptr = payptr->next) - sc->Add(payptr->Copy(), nullptr); + sc->Add(payptr->Copy(), 0); sc->FigureTotals(settings); return sc; @@ -3311,10 +3322,10 @@ std::unique_ptr SubCheck::CopyUnique(Settings *settings) sc->check_type = check_type; for (Order *order = OrderList(); order != nullptr; order = order->next) - sc->Add(order->Copy(), nullptr); + sc->Add(order->Copy(), 0); for (Payment *payptr = PaymentList(); payptr != nullptr; payptr = payptr->next) - sc->Add(payptr->Copy(), nullptr); + sc->Add(payptr->Copy(), 0); sc->FigureTotals(settings); return sc; @@ -3338,10 +3349,10 @@ int SubCheck::Copy(SubCheck *sc, Settings *settings, int restore) check_type = sc->check_type; for (Order *order = sc->OrderList(); order != nullptr; order = order->next) - Add(order->Copy(), nullptr); + Add(order->Copy(), 0); for (Payment *payptr = sc->PaymentList(); payptr != nullptr; payptr = payptr->next) - Add(payptr->Copy(), nullptr); + Add(payptr->Copy(), 0); if (settings) FigureTotals(settings); @@ -3381,7 +3392,7 @@ int SubCheck::Read(Settings *settings, InputDataFile &infile, int version) ReportError(str); return error; } - if (Add(order.release(), nullptr)) + if (Add(order.release(), 0)) { ReportError(GlobalTranslate("Error in adding order")); } @@ -3407,7 +3418,7 @@ int SubCheck::Read(Settings *settings, InputDataFile &infile, int version) { return error; } - if (Add(pmnt.release(), nullptr)) + if (Add(pmnt.release(), 0)) { ReportError(GlobalTranslate("Error in adding payment")); } @@ -3472,7 +3483,7 @@ int SubCheck::Write(OutputDataFile &outfile, int version) int SubCheck::Add(Order *order, Settings *settings) { FnTrace("SubCheck::Add(Order, Settings)"); - Order *ptr = nullptr; + Order *ptr = NULL; int added = 0; if (order == nullptr) @@ -3493,7 +3504,7 @@ int SubCheck::Add(Order *order, Settings *settings) { if (ptr->IsEqual(order)) { - ptr->count = static_cast(ptr->count + order->count); + ptr->count += order->count; delete order; added = 1; } @@ -3546,7 +3557,7 @@ int SubCheck::Add(Payment *pmnt, Settings *settings) if (tt == TENDER_COMP || tt == TENDER_EMPLOYEE_MEAL || tt == TENDER_DISCOUNT) { - Remove(ptr, nullptr); + Remove(ptr, 0); delete ptr; } else if (tt == TENDER_COUPON) @@ -3554,7 +3565,7 @@ int SubCheck::Add(Payment *pmnt, Settings *settings) if ((pmnt->flags & TF_APPLY_EACH) == 0 && (ptr->flags & TF_APPLY_EACH) == 0) { - Remove(ptr, nullptr); + Remove(ptr, 0); delete ptr; } } @@ -3568,7 +3579,7 @@ int SubCheck::Add(Payment *pmnt, Settings *settings) Payment *ptr = FindPayment(tt); if (ptr) { - Remove(ptr, nullptr); + Remove(ptr, 0); delete ptr; } } @@ -3634,7 +3645,7 @@ int SubCheck::Purge(int restore) delete paymnt->credit; else MasterSystem->cc_exception_db->Add(paymnt->credit); - paymnt->credit = nullptr; + paymnt->credit = NULL; } paymnt = paymnt->next; } @@ -3657,14 +3668,14 @@ Order *SubCheck::RemoveCount(Order *order, int count) FnTrace("SubCheck::RemoveCount()"); if (order == nullptr) - return nullptr; + return NULL; if (order->count > count) { Order *ptr = order->Copy(); - order->count = static_cast(order->count - count); + order->count -= count; order->FigureCost(); - ptr->count = static_cast(count); + ptr->count = count; ptr->FigureCost(); return ptr; } @@ -3704,7 +3715,7 @@ int SubCheck::CancelPayments(Terminal *term) int change = 0; Payment *payptr = PaymentList(); Settings *settings = term->GetSettings(); - Credit *credit = nullptr; // just to save some typing + Credit *credit = NULL; // just to save some typing while (payptr) { @@ -3717,7 +3728,7 @@ int SubCheck::CancelPayments(Terminal *term) if (credit->IsAuthed()) MasterSystem->cc_exception_db->Add(term, credit->Copy()); } - Remove(payptr, nullptr); + Remove(payptr, 0); delete payptr; // delete payptr also deletes credit change = 1; } @@ -3766,8 +3777,8 @@ int SubCheck::FigureTotals(Settings *settings) { FnTrace("SubCheck::FigureTotals()"); DList coupons; - Payment *discount = nullptr; // ptr to discount payment - Payment *gratuity = nullptr; // ptr to auto gratuity amount + Payment *discount = NULL; // ptr to discount payment + Payment *gratuity = NULL; // ptr to auto gratuity amount Order *order; CouponInfo *coupon; int max_change = 0; @@ -3833,7 +3844,7 @@ int SubCheck::FigureTotals(Settings *settings) case TENDER_CHANGE: case TENDER_OVERAGE: case TENDER_MONEY_LOST: - Remove(payptr, nullptr); + Remove(payptr, 0); delete payptr; break; case TENDER_GRATUITY: @@ -3903,10 +3914,16 @@ int SubCheck::FigureTotals(Settings *settings) max_change += payptr->value; break; case TENDER_CAPTURED_TIP: + balance += payptr->value; + break; case TENDER_CHARGED_TIP: + balance += payptr->value; + break; case TENDER_CREDIT_CARD_FEE_DOLLAR: + balance += payptr->value; // Add dollar fee to total instead of subtracting payment + break; case TENDER_CREDIT_CARD_FEE_PERCENT: - balance += payptr->value; + balance += payptr->value; // Add percentage fee to total instead of subtracting payment break; default: payment += payptr->value; @@ -4080,16 +4097,16 @@ int SubCheck::FigureTotals(Settings *settings) per = 10000; Flt f = (Flt) food_discount * (1.0 - PercentToFlt(per)); - food_sales += static_cast(lround(f)); + food_sales += (int) (f + .5); f = (Flt) alcohol_discount * (1.0 - PercentToFlt(per)); - alcohol_sales += static_cast(lround(f)); + alcohol_sales += (int) (f + .5); f = (Flt) room_discount * (1.0 - PercentToFlt(per)); - room_sales += static_cast(lround(f)); + room_sales += (int) (f + .5); f = (Flt) merchandise_discount * (1.0 - PercentToFlt(per)); - merchandise_sales += static_cast(lround(f)); + merchandise_sales += (int) (f + .5); discount->value = ((food_no_discount + food_discount) - food_sales) + @@ -4229,9 +4246,9 @@ int SubCheck::FigureTotals(Settings *settings) if (current_tax_revenue > 0) { // Distribute fees proportionally across all revenue bases - int fee_to_food = static_cast(lround((Flt)credit_card_fee_total * (Flt)food_tax_revenue / (Flt)current_tax_revenue)); - int fee_to_alcohol = static_cast(lround((Flt)credit_card_fee_total * (Flt)alcohol_tax_revenue / (Flt)current_tax_revenue)); - int fee_to_room = static_cast(lround((Flt)credit_card_fee_total * (Flt)room_tax_revenue / (Flt)current_tax_revenue)); + int fee_to_food = (int)((Flt)credit_card_fee_total * (Flt)food_tax_revenue / (Flt)current_tax_revenue + 0.5); + int fee_to_alcohol = (int)((Flt)credit_card_fee_total * (Flt)alcohol_tax_revenue / (Flt)current_tax_revenue + 0.5); + int fee_to_room = (int)((Flt)credit_card_fee_total * (Flt)room_tax_revenue / (Flt)current_tax_revenue + 0.5); int fee_to_merchandise = credit_card_fee_total - fee_to_food - fee_to_alcohol - fee_to_room; food_tax_revenue += fee_to_food; @@ -4277,9 +4294,16 @@ int SubCheck::FigureTotals(Settings *settings) if(currFamily != SALESGROUP_BEVERAGE) drinksOnly = false; } - // PST calculation - alcohol_tax doesn't affect food_tax_revenue parameter choice - total_tax_PST = settings->FigurePST(food_tax_revenue, - SystemTime, drinksOnly, PST_tax); + if (alcohol_tax == 0) + { + total_tax_PST = settings->FigurePST((food_tax_revenue + alcohol_tax_revenue), + SystemTime, drinksOnly, PST_tax); + } + else + { + total_tax_PST = settings->FigurePST(food_tax_revenue, + SystemTime, drinksOnly, PST_tax); + } total_tax_HST = settings->FigureHST((food_tax_revenue + alcohol_tax_revenue), SystemTime, HST_tax); @@ -4441,7 +4465,7 @@ int SubCheck::SettleTab(Terminal *term, int payment_type, int /*payment_id*/, in { FnTrace("SubCheck::SettleTab()"); int retval = 0; - Payment *paymnt = nullptr; + Payment *paymnt = NULL; if (payment_type == TENDER_CREDIT_CARD || payment_type == TENDER_DEBIT_CARD) return retval; @@ -4490,8 +4514,8 @@ int SubCheck::ConsolidateOrders(Settings *settings, int relaxed) o2->modifier_list == nullptr && strcmp(thisOrder->item_name.Value(), o2->item_name.Value()) == 0) { - Remove(o2, nullptr); - thisOrder->count = static_cast(thisOrder->count + o2->count); + Remove(o2, 0); + thisOrder->count += o2->count; delete o2; } o2 = ptr; @@ -4524,7 +4548,7 @@ int SubCheck::ConsolidatePayments(Settings *settings) tt == p2->tender_type && payptr->flags == p2->flags && payptr->drawer_id == p2->drawer_id && payptr->user_id == p2->user_id) { - Remove(p2, nullptr); + Remove(p2, 0); payptr->amount += p2->amount; delete p2; } @@ -4702,7 +4726,7 @@ int SubCheck::PrintReceipt(Terminal *term, Check *check, Printer *printer, Drawe else vt_safe_string::safe_format(str1, 64, "%s %d", term->Translate("Drawer"), drawer->number); - Employee *cashier = nullptr; + Employee *cashier = NULL; if (settle_user > 0) cashier = sys->user_db.FindByID(settle_user); else @@ -4794,7 +4818,7 @@ int SubCheck::PrintReceipt(Terminal *term, Check *check, Printer *printer, Drawe if (pennies) tc += -pennies->amount; - Payment *pay = nullptr; + Payment *pay = NULL; // check for and print coupons, discounts, and comps if (PaymentList()) { @@ -4994,9 +5018,10 @@ int SubCheck::PrintReceipt(Terminal *term, Check *check, Printer *printer, Drawe printer->LineFeed(8); } //PRINT TICKETS - for(auto ord : tickets) + for(std::list::iterator loi=tickets.begin();loi!=tickets.end();++loi) { - int count=ord->count; + Order* ord=*loi; + int count=ord->count; SalesItem* si=ord->Item(items); for(i=0;inext) if (payptr->credit) return payptr->credit; - return nullptr; + return NULL; } int SubCheck::IsEqual(SubCheck *sc) @@ -5576,7 +5601,7 @@ static int adjust_cost(int cost, Flt tax, int type, Settings *settings, Terminal inclusive = settings->tax_inclusive[type]; // use global default if (inclusive) //return int(cost/(1.0+tax) + tax); // for round-up - return static_cast(lround(cost/(1.0+tax))); // for rounding + return int(cost/(1.0+tax) + 0.5); // for rounding return cost; } @@ -5599,13 +5624,13 @@ Order::Order(Settings *settings, SalesItem *item, Terminal *term, int price) call_order = item->call_order; allow_increase = item->allow_increase; ignore_split = item->ignore_split; - next = nullptr; - fore = nullptr; - parent = nullptr; + next = NULL; + fore = NULL; + parent = NULL; count = 1; status = 0; cost = 0; - modifier_list = nullptr; + modifier_list = NULL; user_id = 0; page_id = 0; seat = 0; @@ -5642,13 +5667,13 @@ Order::Order(const genericChar* name, int price) call_order = 4; allow_increase = 1; ignore_split = 0; - next = nullptr; - fore = nullptr; - parent = nullptr; + next = NULL; + fore = NULL; + parent = NULL; count = 1; status = 0; cost = 0; - modifier_list = nullptr; + modifier_list = NULL; qualifier = QUALIFIER_NONE; user_id = 0; page_id = 0; @@ -5679,7 +5704,7 @@ Order::~Order() Order *Order::Copy() { FnTrace("Order::Copy()"); - auto *order = new Order; + Order *order = new Order; if (order == nullptr) return nullptr; @@ -5878,9 +5903,9 @@ int Order::Remove(Order *order) order->next->fore = order->fore; if (order->fore) order->fore->next = order->next; - order->next = nullptr; - order->fore = nullptr; - order->parent = nullptr; + order->next = NULL; + order->fore = NULL; + order->parent = NULL; FigureCost(); return 0; @@ -6115,8 +6140,6 @@ int Order::CanDiscount(int discount_alcohol, Payment *payment) case TENDER_COUPON: retval = !(sales_type & SALES_NO_DISCOUNT); break; - default: - break; } } return retval; @@ -6148,7 +6171,7 @@ int Order::IsEqual(Order *order) return 0; } - if (strcmp(item_name.Value(), order->item_name.Value()) != 0) + if (strcmp(item_name.Value(), order->item_name.Value())) return 0; // if this is a By the Pound order, then we don't want @@ -6178,7 +6201,7 @@ int Order::IsEmployeeMeal(int set) int retval = employee_meal; if (set >= 0) - employee_meal = static_cast(set); + employee_meal = set; return retval; } @@ -6189,7 +6212,7 @@ int Order::IsReduced(int set) int retval = is_reduced; if (set >= 0) - is_reduced = static_cast(set); + is_reduced = set; return retval; } @@ -6294,7 +6317,7 @@ Payment::Payment(int tender, int pid, int pflags, int pamount) , value(0) , amount(pamount) , tender_id(pid) - , tender_type(static_cast(tender)) + , tender_type(tender) , flags(pflags) , drawer_id(0) , credit(nullptr) @@ -6317,11 +6340,11 @@ Payment::~Payment() Payment *Payment::Copy() { FnTrace("Payment::Copy()"); - auto *payptr = new Payment; + Payment *payptr = new Payment; if (payptr == nullptr) { ReportError("Can't copy payment"); - return nullptr; + return NULL; } payptr->value = value; @@ -6391,7 +6414,7 @@ genericChar* Payment::Description(Settings *settings, genericChar* str) if (tender_type == TENDER_CREDIT_CARD && credit != nullptr) { - vt_safe_string::safe_format(str, 128, "Credit Card (%s)", credit->CreditTypeName(nullptr, 1)); + vt_safe_string::safe_format(str, 128, "Credit Card (%s)", credit->CreditTypeName(NULL, 1)); return str; } @@ -6488,7 +6511,7 @@ int Payment::SetBatch(const char* termid, const char* batch) FnTrace("Payment::SetBatch()"); int retval = 1; - if (credit != nullptr && strcmp(termid, credit->TermID()) != 0) + if (credit != nullptr && strcmp(termid, credit->TermID())) retval = credit->SetBatch(atol(batch), termid); return retval; diff --git a/main/business/check.hh b/main/business/check.hh index 9f5b8150..58c04468 100644 --- a/main/business/check.hh +++ b/main/business/check.hh @@ -18,8 +18,8 @@ * Definition of check management classes */ -#ifndef CHECK_HH -#define CHECK_HH +#ifndef _CHECK_HH +#define _CHECK_HH #include "utility.hh" #include "list_utility.hh" @@ -28,55 +28,29 @@ #include /**** Module Definitions & Global Data ****/ -constexpr int CHECK_VERSION = 25; +#define CHECK_VERSION 25 // Check Status -enum class CheckStatus : std::uint8_t { - Open = 1, - Closed = 2, - Voided = 3 -}; - -// Backward-compatible constexpr shims -constexpr int CHECK_OPEN = static_cast(CheckStatus::Open); -constexpr int CHECK_CLOSED = static_cast(CheckStatus::Closed); -constexpr int CHECK_VOIDED = static_cast(CheckStatus::Voided); +#define CHECK_OPEN 1 +#define CHECK_CLOSED 2 +#define CHECK_VOIDED 3 // Check Type -enum class CheckType : std::uint8_t { - Restaurant = 1, // normal check - has table location - Takeout = 2, // take out order - has phone number - Bar = 3, // drink from bar - no guest count or table - Merchandise = 4, // merchandise sale - no guest count or table - Delivery = 5, - Catering = 6, - Hotel = 7, - Retail = 8, - FastFood = 9, - SelfOrder = 10, // customer self-service order - no login required - DineIn = 11, // dine-in order (restored original value for backward compatibility) - ToGo = 12, // take-out order (restored original value for backward compatibility) - CallIn = 13, // call-in order (restored original value for backward compatibility) - SelfDineIn = 14, // customer self-service dine-in order - SelfTakeOut = 15 // customer self-service take-out order -}; - -// Backward-compatible constexpr shims -constexpr int CHECK_RESTAURANT = static_cast(CheckType::Restaurant); -constexpr int CHECK_TAKEOUT = static_cast(CheckType::Takeout); -constexpr int CHECK_BAR = static_cast(CheckType::Bar); -constexpr int CHECK_MERCHANDISE = static_cast(CheckType::Merchandise); -constexpr int CHECK_DELIVERY = static_cast(CheckType::Delivery); -constexpr int CHECK_CATERING = static_cast(CheckType::Catering); -constexpr int CHECK_HOTEL = static_cast(CheckType::Hotel); -constexpr int CHECK_RETAIL = static_cast(CheckType::Retail); -constexpr int CHECK_FASTFOOD = static_cast(CheckType::FastFood); -constexpr int CHECK_SELFORDER = static_cast(CheckType::SelfOrder); -constexpr int CHECK_DINEIN = static_cast(CheckType::DineIn); -constexpr int CHECK_TOGO = static_cast(CheckType::ToGo); -constexpr int CHECK_CALLIN = static_cast(CheckType::CallIn); -constexpr int CHECK_SELFDINEIN = static_cast(CheckType::SelfDineIn); -constexpr int CHECK_SELFTAKEOUT = static_cast(CheckType::SelfTakeOut); +#define CHECK_RESTAURANT 1 // normal check - has table location +#define CHECK_TAKEOUT 2 // take out order - has phone number +#define CHECK_BAR 3 // drink from bar - no guest count or table +#define CHECK_MERCHANDISE 4 // merchandise sale - no guest count or table +#define CHECK_DELIVERY 5 +#define CHECK_CATERING 6 +#define CHECK_HOTEL 7 +#define CHECK_RETAIL 8 +#define CHECK_FASTFOOD 9 +#define CHECK_SELFORDER 10 // customer self-service order - no login required +#define CHECK_DINEIN 11 // dine-in order (restored original value for backward compatibility) +#define CHECK_TOGO 12 // take-out order (restored original value for backward compatibility) +#define CHECK_CALLIN 13 // call-in order (restored original value for backward compatibility) +#define CHECK_SELFDINEIN 14 // customer self-service dine-in order +#define CHECK_SELFTAKEOUT 15 // customer self-service take-out order // Check Flags #define CF_PRINTED 1 // Has been sent to the kitcen at least once @@ -208,13 +182,13 @@ public: int Add(std::unique_ptr o); // Modern C++ version int Remove(Order *o); // Removes a modifier order int FigureCost(); // Totals up order - genericChar* Description(Terminal *t, genericChar* buffer = nullptr); // Returns string with order description - genericChar* PrintDescription( genericChar* str=nullptr, short int pshort = 0 ); // Returns string with printed order description + genericChar* Description(Terminal *t, genericChar* buffer = NULL); // Returns string with order description + genericChar* PrintDescription( genericChar* str=NULL, short int pshort = 0 ); // Returns string with printed order description int IsEntree(); // boolean - is this item an "Entree"? int FindPrinterID(Settings *settings); // PrinterID (based on family) for order SalesItem *Item(ItemDB *db); // Returns menu item this order points to int PrintStatus(Terminal *t, int printer_id, int reprint = 0, int flag_sent = ORDER_SENT); // Returns 0-don't print, 1-print, 2-notify only - genericChar* Seat(Settings *settings, genericChar* buffer = nullptr); // Returns string with order's seat + genericChar* Seat(Settings *settings, genericChar* buffer = NULL); // Returns string with order's seat int IsModifier(); // Boolean - Is this order a modifier? int CanDiscount(int discount_alcohol, Payment *p); // Boolean - Does this discount apply? int Finalize(); // Finalizes order @@ -223,7 +197,7 @@ public: int IsReduced(int set = -1); int VideoTarget(Settings *settings); // returns the video target for this order int AddQualifier(const char* qualifier_str); - int CalculateTax(Settings *settings, Terminal *term = nullptr); // Calculate tax for this order + int CalculateTax(Settings *settings, Terminal *term = NULL); // Calculate tax for this order }; class Payment @@ -249,7 +223,7 @@ public: Payment *Copy(); // Returns exact copy of payment object int Read(InputDataFile &df, int version); // Reads payment from a file int Write(OutputDataFile &df, int version); // Write payment to a file - genericChar* Description(Settings *settings, genericChar* str = nullptr); // Returns description of discount + genericChar* Description(Settings *settings, genericChar* str = NULL); // Returns description of discount int Priority(); // Sorting priority (higher goes 1st) int Suppress(); // Boolean - Should payment be shown? int IsDiscount(); // Boolean - Is payment a discount? @@ -316,12 +290,12 @@ public: Payment *PaymentListEnd() { return payment_list.Tail(); } int PaymentCount() { return payment_list.Count(); } - [[nodiscard]] const Order *OrderList() const { return order_list.Head(); } - [[nodiscard]] const Order *OrderListEnd() const { return order_list.Tail(); } + const Order *OrderList() const { return order_list.Head(); } + const Order *OrderListEnd() const { return order_list.Tail(); } - [[nodiscard]] const Payment *PaymentList() const { return payment_list.Head(); } - [[nodiscard]] const Payment *PaymentListEnd() const { return payment_list.Tail(); } - [[nodiscard]] int PaymentCount() const { return payment_list.Count(); } + const Payment *PaymentList() const { return payment_list.Head(); } + const Payment *PaymentListEnd() const { return payment_list.Tail(); } + int PaymentCount() const { return payment_list.Count(); } int TotalTax() { @@ -342,13 +316,13 @@ public: SubCheck *Copy(Settings *settings); // Creates a subcheck copy std::unique_ptr CopyUnique(Settings *settings); // Modern C++ version returning unique_ptr - int Copy(SubCheck *sc, Settings *settings = nullptr, int restore = 0); // Copies the contents of a subcheck + int Copy(SubCheck *sc, Settings *settings = NULL, int restore = 0); // Copies the contents of a subcheck int Read(Settings *settings, InputDataFile &df, int version); // Reads subcheck from file int Write(OutputDataFile &df, int version); // Writes subcheck to file - int Add(Order *o, Settings *settings = nullptr); // Adds an order - recalculates if settings are given - int Add(Payment *p, Settings *settings = nullptr); // Adds a payment - recalculates if settings are given - int Remove(Order *o, Settings *settings = nullptr); // Removes an order - recalculates if settings are given - int Remove(Payment *p, Settings *settings = nullptr); // Removes a payment - recalculates if settings are given + int Add(Order *o, Settings *settings = NULL); // Adds an order - recalculates if settings are given + int Add(Payment *p, Settings *settings = NULL); // Adds a payment - recalculates if settings are given + int Remove(Order *o, Settings *settings = NULL); // Removes an order - recalculates if settings are given + int Remove(Payment *p, Settings *settings = NULL); // Removes a payment - recalculates if settings are given int Purge(int restore = 0); // Removes all payments & orders Order *RemoveOne(Order *o); // Removes one order & returns it Order *RemoveCount(Order *o, int count = 1); @@ -358,13 +332,13 @@ public: int FigureTotals(Settings *settings); // Totals costs & payments int TabRemain(); int SettleTab(Terminal *term, int payment_type, int payment_id, int payment_flags); - int ConsolidateOrders(Settings *settings = nullptr, int relaxed = 0); // Combines like orders - recalculates if settings are given - int ConsolidatePayments(Settings *settings = nullptr); // Combines like payments - recalculates if settings are given + int ConsolidateOrders(Settings *settings = NULL, int relaxed = 0); // Combines like orders - recalculates if settings are given + int ConsolidatePayments(Settings *settings = NULL); // Combines like payments - recalculates if settings are given int FinalizeOrders(); // Makes all ordered items final int Void(); // Voids check int SeatsUsed(); // number of seats with orders int PrintReceipt(Terminal *t, Check *c, Printer *p, - Drawer *d = nullptr, int open_drawer = 0); // Prints receipt + Drawer *d = NULL, int open_drawer = 0); // Prints receipt int ReceiptReport(Terminal *t, Check *c, Drawer *d, Report *r); // Makes report of receipt const genericChar* StatusString(Terminal *t); // Returns string with subcheck status (Open, Closed, Voided, etc.) int IsSeatOnCheck(int seat); // Boolean - Are any of the orders for this seat? @@ -382,7 +356,7 @@ public: int OrderCount(int seat = -1); // Returns number of orders for seat int OrderPage(Order *o, int lines_per_page, int seat = -1); // Returns page order would appear on Payment *NewPayment(int type, int id, int flags, int amount); // Creates a new order for this subcheck and returns it - Credit *CurrentCredit(); // Returns creditcard info for this subcheck (or nullptr if there is none) + Credit *CurrentCredit(); // Returns creditcard info for this subcheck (or NULL if there is none) int IsEqual(SubCheck *sc); // Boolean - Are both subchecks the same? int IsTaxExempt(); int IsBalanced(); @@ -434,7 +408,7 @@ public: // Constructors Check(); - Check(Settings *settings, int customer_type, Employee *e = nullptr); + Check(Settings *settings, int customer_type, Employee *e = NULL); // Destructor ~Check(); @@ -442,9 +416,9 @@ public: SubCheck *SubList() { return sub_list.Head(); } SubCheck *SubListEnd() { return sub_list.Tail(); } int SubCount() { return sub_list.Count(); } - [[nodiscard]] const SubCheck *SubList() const { return sub_list.Head(); } - [[nodiscard]] const SubCheck *SubListEnd() const { return sub_list.Tail(); } - [[nodiscard]] int SubCount() const { return sub_list.Count(); } + const SubCheck *SubList() const { return sub_list.Head(); } + const SubCheck *SubListEnd() const { return sub_list.Tail(); } + int SubCount() const { return sub_list.Count(); } Check *Copy(Settings *settings); int Load(Settings *settings, const genericChar* filename); // Loads check from file @@ -475,19 +449,19 @@ public: int flag_sent = ORDER_SENT); // returns # of orders to be printed int SendWorkOrder(Terminal *term, int printer_target, int reprint); int PrintWorkOrder(Terminal *term, Report *report, int printer_id, int reprint, - ReportZone *rzone = nullptr, Printer *printer = nullptr); + ReportZone *rzone = NULL, Printer *printer = NULL); int PrintDeliveryOrder(Report *report, int pwidth = 80); int PrintCustomerInfo(Printer *printer, int mode); int PrintCustomerInfoReport(Report *report, int mode, int columns = 1, int pwidth = 40); int ListOrdersForReport(Terminal *term, Report *report); int MakeReport(Terminal *t, Report *r, int show_what = CHECK_DISPLAY_ALL, - int video_target = PRINTER_DEFAULT, ReportZone *rzone = nullptr); // makes report showing all subchecks + int video_target = PRINTER_DEFAULT, ReportZone *rzone = NULL); // makes report showing all subchecks int HasOpenTab(); - [[nodiscard]] int IsEmpty() const; // boolean - is check blank? - [[nodiscard]] int IsTraining() const; // boolean - is this a training check? + int IsEmpty() const; // boolean - is check blank? + int IsTraining() const; // boolean - is this a training check? int EntreeCount(int seat); // counts total entrees at seat SubCheck *FirstOpenSubCheck(int seat = -1); // returns 1st open subcheck (by seat if needed) - sets current_sub - SubCheck *NextOpenSubCheck(SubCheck *sc = nullptr); // returns next open subcheck in check - sets current_sub + SubCheck *NextOpenSubCheck(SubCheck *sc = NULL); // returns next open subcheck in check - sets current_sub TimeInfo *TimeClosed(); // returns ptr to time closed int WhoGetsSale(Settings *settings); // returns user_id of server int SecondsOpen(); // total number of seconds open @@ -507,30 +481,30 @@ public: int IsToGo(); int IsForHere(); int CustomerType(int set = -1); - const genericChar* Table(const genericChar* set = nullptr); // FIX - name not general enough + const genericChar* Table(const genericChar* set = NULL); // FIX - name not general enough int Guests(int guests = -1); int CallCenterID(int set = -1); int CustomerID(int set = -1); - const genericChar* LastName(const genericChar* set = nullptr); - const genericChar* FirstName(const genericChar* set = nullptr); - genericChar* FullName(genericChar* dest = nullptr); - const genericChar* Company(const genericChar* set = nullptr); - const genericChar* Address(const genericChar* set = nullptr); - const genericChar* Address2(const genericChar* set = nullptr); - const genericChar* CrossStreet(const genericChar* set = nullptr); - const genericChar* City(const genericChar* set = nullptr); - const genericChar* State(const genericChar* set = nullptr); - const genericChar* Postal(const genericChar* set = nullptr); - const genericChar* Vehicle(const genericChar* set = nullptr); - const genericChar* CCNumber(const genericChar* set = nullptr); - const genericChar* CCExpire(const genericChar* set = nullptr); - const genericChar* License(const genericChar* set = nullptr); - const genericChar* Comment(const genericChar* set = nullptr); - const genericChar* PhoneNumber(const genericChar* set = nullptr); - const genericChar* Extension(const genericChar* set = nullptr); - TimeInfo *Date(TimeInfo *set = nullptr); - TimeInfo *CheckIn(TimeInfo *timevar = nullptr); - TimeInfo *CheckOut(TimeInfo *timevar = nullptr); + const genericChar* LastName(const genericChar* set = NULL); + const genericChar* FirstName(const genericChar* set = NULL); + genericChar* FullName(genericChar* dest = NULL); + const genericChar* Company(const genericChar* set = NULL); + const genericChar* Address(const genericChar* set = NULL); + const genericChar* Address2(const genericChar* set = NULL); + const genericChar* CrossStreet(const genericChar* set = NULL); + const genericChar* City(const genericChar* set = NULL); + const genericChar* State(const genericChar* set = NULL); + const genericChar* Postal(const genericChar* set = NULL); + const genericChar* Vehicle(const genericChar* set = NULL); + const genericChar* CCNumber(const genericChar* set = NULL); + const genericChar* CCExpire(const genericChar* set = NULL); + const genericChar* License(const genericChar* set = NULL); + const genericChar* Comment(const genericChar* set = NULL); + const genericChar* PhoneNumber(const genericChar* set = NULL); + const genericChar* Extension(const genericChar* set = NULL); + TimeInfo *Date(TimeInfo *set = NULL); + TimeInfo *CheckIn(TimeInfo *timevar = NULL); + TimeInfo *CheckOut(TimeInfo *timevar = NULL); }; /**** General Functions ****/ diff --git a/main/business/customer.cc b/main/business/customer.cc index 8dc37e38..21e99c7c 100644 --- a/main/business/customer.cc +++ b/main/business/customer.cc @@ -19,7 +19,7 @@ */ #include -#include +#include #include #include "customer.hh" #include "data_file.hh" @@ -39,8 +39,8 @@ CustomerInfo::CustomerInfo(int new_type) { FnTrace("CustomerInfo::CustomerInfo()"); - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; // Don't worry about type. See the explanation in the // NewCustomerInfo() comment. @@ -67,7 +67,8 @@ CustomerInfo::CustomerInfo(int new_type) } CustomerInfo::~CustomerInfo() -= default; +{ +} int CustomerInfo::IsBlank() { @@ -315,7 +316,7 @@ const genericChar* CustomerInfo::LastName(const char* set) { FnTrace("CustomerInfo::LastName()"); - if (set != nullptr) + if (set != NULL) lastname.Set(set); return lastname.Value(); @@ -325,7 +326,7 @@ const genericChar* CustomerInfo::FirstName(const char* set) { FnTrace("CustomerInfo::FirstName()"); - if (set != nullptr) + if (set != NULL) firstname.Set(set); return firstname.Value(); @@ -335,7 +336,7 @@ const genericChar* CustomerInfo::Company(const char* set) { FnTrace("CustomerInfo::Company()"); - if (set != nullptr) + if (set != NULL) company.Set(set); return company.Value(); @@ -345,7 +346,7 @@ const genericChar* CustomerInfo::PhoneNumber(const char* set) { FnTrace("CustomerInfo::PhoneNumber()"); - if (set != nullptr) + if (set != NULL) phone.Set(set); return phone.Value(); @@ -355,7 +356,7 @@ const genericChar* CustomerInfo::Extension(const char* set) { FnTrace("CustomerInfo::Extension()"); - if (set != nullptr) + if (set != NULL) extension.Set(set); return extension.Value(); @@ -365,7 +366,7 @@ const genericChar* CustomerInfo::Address(const char* set) { FnTrace("CustomerInfo::Address()"); - if (set != nullptr) + if (set != NULL) address.Set(set); return address.Value(); @@ -375,7 +376,7 @@ const genericChar* CustomerInfo::Address2(const char* set) { FnTrace("CustomerInfo::Address2()"); - if (set != nullptr) + if (set != NULL) address2.Set(set); return address2.Value(); @@ -385,7 +386,7 @@ const genericChar* CustomerInfo::CrossStreet(const char* set) { FnTrace("CustomerInfo::CrossStreet()"); - if (set != nullptr) + if (set != NULL) cross_street.Set(set); return cross_street.Value(); @@ -395,7 +396,7 @@ const genericChar* CustomerInfo::City(const char* set) { FnTrace("CustomerInfo::City()"); - if (set != nullptr) + if (set != NULL) city.Set(set); return city.Value(); @@ -405,7 +406,7 @@ const genericChar* CustomerInfo::State(const char* set) { FnTrace("CustomerInfo::State()"); - if (set != nullptr) + if (set != NULL) state.Set(set); return state.Value(); @@ -415,7 +416,7 @@ const genericChar* CustomerInfo::Postal(const char* set) { FnTrace("CustomerInfo::Postal()"); - if (set != nullptr) + if (set != NULL) postal.Set(set); return postal.Value(); @@ -425,7 +426,7 @@ const genericChar* CustomerInfo::License(const char* set) { FnTrace("CustomerInfo::License()"); - if (set != nullptr) + if (set != NULL) license.Set(set); return license.Value(); @@ -435,7 +436,7 @@ const genericChar* CustomerInfo::CCNumber(const char* set) { FnTrace("CustomerInfo::CCNumber()"); - if (set != nullptr) + if (set != NULL) cc_number.Set(set); return cc_number.Value(); @@ -445,7 +446,7 @@ const genericChar* CustomerInfo::CCExpire(const char* set) { FnTrace("CustomerInfo::CCExpire()"); - if (set != nullptr) + if (set != NULL) cc_expire.Set(set); return cc_expire.Value(); @@ -455,7 +456,7 @@ const genericChar* CustomerInfo::Comment(const char* set) { FnTrace("CustomerInfo::Comment()"); - if (set != nullptr) + if (set != NULL) comment.Set(set); return comment.Value(); @@ -465,7 +466,7 @@ const genericChar* CustomerInfo::Vehicle(const char* set) { FnTrace("CustomerInfo::Vehicle()"); - if (set != nullptr) + if (set != NULL) vehicle.Set(set); return vehicle.Value(); @@ -483,7 +484,8 @@ CustomerInfoDB::CustomerInfoDB() } CustomerInfoDB::~CustomerInfoDB() -= default; +{ +} int CustomerInfoDB::RemoveBlank() { @@ -491,7 +493,7 @@ int CustomerInfoDB::RemoveBlank() int retval = 1; CustomerInfo *customer = customers.Head(); - while (customer != nullptr) + while (customer != NULL) { if (customer->IsBlank()) { @@ -516,7 +518,7 @@ int CustomerInfoDB::Count() int count = 0; CustomerInfo *customer = customers.Head(); - while (customer != nullptr) + while (customer != NULL) { count += 1; customer = customer->next; @@ -531,10 +533,10 @@ int CustomerInfoDB::Save(const genericChar* filepath) int retval = 1; CustomerInfo *customer = customers.Head(); - if (filepath != nullptr) + if (filepath != NULL) pathname.Set(filepath); - while (customer != nullptr) + while (customer != NULL) { if (customer->id < 0) customer->id = NextID(); @@ -562,7 +564,7 @@ int CustomerInfoDB::Load(const genericChar* filepath) FnTrace("CustomerInfoDB::Load()"); int retval = 0; DIR *dp; - struct dirent *record = nullptr; + struct dirent *record = NULL; genericChar buffer[STRLONG]; if (filepath) @@ -572,7 +574,7 @@ int CustomerInfoDB::Load(const genericChar* filepath) return 1; dp = opendir(pathname.Value()); - if (dp == nullptr) + if (dp == NULL) return 1; // Error - can't find directory do @@ -584,7 +586,7 @@ int CustomerInfoDB::Load(const genericChar* filepath) if (strncmp("customer_", name, 9) == 0) { vt_safe_string::safe_format(buffer, STRLONG, "%s/%s", pathname.Value(), name); - auto *custinfo = new CustomerInfo(); + CustomerInfo *custinfo = new CustomerInfo(); if (custinfo->Load(buffer)) ReportError("Error loading customer"); else @@ -606,8 +608,8 @@ CustomerInfo *CustomerInfoDB::NewCustomer(int type) { FnTrace("CustomerInfoDB::NewCustomer()"); - auto *ci = new CustomerInfo(type); - if (ci != nullptr) + CustomerInfo *ci = new CustomerInfo(type); + if (ci != NULL) { Add(ci); ci->SetFileName(pathname.Value()); @@ -642,18 +644,18 @@ int CustomerInfoDB::Remove(CustomerInfo *customer) CustomerInfo *CustomerInfoDB::FindByID(int customer_id) { FnTrace("CustomerInfoDB::FindByID()"); - CustomerInfo *retval = nullptr; + CustomerInfo *retval = NULL; CustomerInfo *customer = customers.Head(); if (customer_id < 0) return retval; - while (customer != nullptr) + while (customer != NULL) { if (customer_id == customer->id) { retval = customer; - customer = nullptr; + customer = NULL; } else customer = customer->next; @@ -665,21 +667,21 @@ CustomerInfo *CustomerInfoDB::FindByID(int customer_id) CustomerInfo *CustomerInfoDB::FindByString(const genericChar* search_string, int start) { FnTrace("CustomerInfoDB::FindByString()"); - CustomerInfo *retval = nullptr; + CustomerInfo *retval = NULL; CustomerInfo *customer = customers.Head(); - CustomerInfo *first_customer = nullptr; + CustomerInfo *first_customer = NULL; int done = 0; if (start > -1) { - while (customer != nullptr && customer->id <= start) + while (customer != NULL && customer->id <= start) customer = customer->next; - if (customer == nullptr) + if (customer == NULL) customer = customers.Head(); } first_customer = customer; - while (customer != nullptr && done != 1) + while (customer != NULL && done != 1) { if (customer->Search(search_string)) { @@ -689,7 +691,7 @@ CustomerInfo *CustomerInfoDB::FindByString(const genericChar* search_string, int else { customer = customer->next; - if (customer == nullptr) + if (customer == NULL) customer = customers.Head(); if (customer == first_customer) done = 1; @@ -702,15 +704,15 @@ CustomerInfo *CustomerInfoDB::FindByString(const genericChar* search_string, int CustomerInfo *CustomerInfoDB::FindBlank() { FnTrace("CustomerInfoDB::FindBlank()"); - CustomerInfo *retval = nullptr; + CustomerInfo *retval = NULL; CustomerInfo *customer = customers.Tail(); - while (customer != nullptr) + while (customer != NULL) { if (customer->IsBlank()) { retval = customer; - customer = nullptr; + customer = NULL; } else { diff --git a/main/business/customer.hh b/main/business/customer.hh index 87bfb436..3db44806 100644 --- a/main/business/customer.hh +++ b/main/business/customer.hh @@ -18,13 +18,13 @@ * Implementation of customer infomation module */ -#ifndef CUSTOMER_HH -#define CUSTOMER_HH +#ifndef _CUSTOMER_HH +#define _CUSTOMER_HH #include "list_utility.hh" #include "utility.hh" -constexpr int CUSTOMER_VERSION = 14; +#define CUSTOMER_VERSION 14 /**** Types ****/ @@ -97,22 +97,22 @@ public: virtual int Type() { return type; } virtual int CustomerID() { return id; } virtual int Guests(int set = -1); - virtual const genericChar* LastName(const char* set = nullptr); - virtual const genericChar* FirstName(const char* set = nullptr); - virtual const genericChar* Company(const char* set = nullptr); - virtual const genericChar* PhoneNumber(const char* set = nullptr); - virtual const genericChar* Extension(const char* set = nullptr); - virtual const genericChar* Address(const char* set = nullptr); - virtual const genericChar* Address2(const char* set = nullptr); - virtual const genericChar* CrossStreet(const char* set = nullptr); - virtual const genericChar* City(const char* set = nullptr); - virtual const genericChar* State(const char* set = nullptr); - virtual const genericChar* Postal(const char* set = nullptr); - virtual const genericChar* License(const char* set = nullptr); - virtual const genericChar* CCNumber(const char* set = nullptr); - virtual const genericChar* CCExpire(const char* set = nullptr); - virtual const genericChar* Comment(const char* set = nullptr); - virtual const genericChar* Vehicle(const char* set = nullptr); + virtual const genericChar* LastName(const char* set = NULL); + virtual const genericChar* FirstName(const char* set = NULL); + virtual const genericChar* Company(const char* set = NULL); + virtual const genericChar* PhoneNumber(const char* set = NULL); + virtual const genericChar* Extension(const char* set = NULL); + virtual const genericChar* Address(const char* set = NULL); + virtual const genericChar* Address2(const char* set = NULL); + virtual const genericChar* CrossStreet(const char* set = NULL); + virtual const genericChar* City(const char* set = NULL); + virtual const genericChar* State(const char* set = NULL); + virtual const genericChar* Postal(const char* set = NULL); + virtual const genericChar* License(const char* set = NULL); + virtual const genericChar* CCNumber(const char* set = NULL); + virtual const genericChar* CCExpire(const char* set = NULL); + virtual const genericChar* Comment(const char* set = NULL); + virtual const genericChar* Vehicle(const char* set = NULL); virtual int Search(const char* word); }; @@ -138,7 +138,7 @@ public: CustomerInfo *CustomerListEnd() { return customers.Tail(); } int Count(); - int Save(const genericChar* filepath = nullptr); + int Save(const genericChar* filepath = NULL); int Save(CustomerInfo *customer); int Load(const genericChar* filepath); CustomerInfo *NewCustomer(int customer_type); diff --git a/main/business/employee.cc b/main/business/employee.cc index 8b4a887b..5e3b13a3 100644 --- a/main/business/employee.cc +++ b/main/business/employee.cc @@ -43,14 +43,14 @@ const char* JobName[] = { "No Job", "Dishwasher", "Busperson", "Line Cook", "Prep Cook", "Chef", "Cashier", "Server", "Server/Cashier", "Bartender", "Host/Hostess", - "Bookkeeper", "Supervisor", "Assistant Manager", "Manager", nullptr}; + "Bookkeeper", "Supervisor", "Assistant Manager", "Manager", NULL}; int JobValue[] = { JOB_NONE, JOB_DISHWASHER, JOB_BUSPERSON, JOB_COOK, JOB_COOK2, JOB_COOK3, JOB_CASHIER, JOB_SERVER, JOB_SERVER2, JOB_BARTENDER, JOB_HOST, JOB_BOOKKEEPER, JOB_MANAGER, JOB_MANAGER2, JOB_MANAGER3, -1}; const char* PayRateName[] = { - "Hour", "Day", "Week", "Month", nullptr}; + "Hour", "Day", "Week", "Month", NULL}; int PayRateValue[] = { PERIOD_HOUR, PERIOD_DAY, PERIOD_WEEK, PERIOD_MONTH, -1}; @@ -145,8 +145,8 @@ static int UserIdCompare(const void *u1, const void *u2) JobInfo::JobInfo() { FnTrace("JobInfo::JobInfo()"); - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; job = 0; starting_page = -1; curr_starting_page = -1; @@ -199,7 +199,7 @@ UserDB::UserDB() super_user = new Employee; if (super_user) { - auto *j = new JobInfo; + JobInfo *j = new JobInfo; j->job = JOB_SUPERUSER; super_user->Add(j); super_user->system_name.Set("Super User"); @@ -211,7 +211,7 @@ UserDB::UserDB() developer = new Employee; if (developer) { - auto *j = new JobInfo; + JobInfo *j = new JobInfo; j->job = JOB_DEVELOPER; developer->Add(j); developer->system_name.Set("Editor"); @@ -219,8 +219,8 @@ UserDB::UserDB() developer->training = 1; } - name_array = nullptr; - id_array = nullptr; + name_array = NULL; + id_array = NULL; } // Destructor @@ -262,8 +262,8 @@ int UserDB::Load(const char* file) return 1; } - auto *e = new Employee; - if (e == nullptr) + Employee *e = new Employee; + if (e == NULL) { ReportError("Couldn't create employee record"); return 1; @@ -307,18 +307,18 @@ int UserDB::Add(Employee *e) { FnTrace("UserDB::Add(Employee)"); - if (e == nullptr) + if (e == NULL) return 1; if (name_array) { free(name_array); - name_array = nullptr; + name_array = NULL; } if (id_array) { free(id_array); - id_array = nullptr; + id_array = NULL; } if (e->id <= 0) @@ -333,18 +333,18 @@ int UserDB::Remove(Employee *e) { FnTrace("UserDB::Remove(Employee)"); - if (e == nullptr) + if (e == NULL) return 1; if (name_array) { free(name_array); - name_array = nullptr; + name_array = NULL; } if (id_array) { free(id_array); - id_array = nullptr; + id_array = NULL; } return user_list.Remove(e); @@ -357,12 +357,12 @@ int UserDB::Purge() if (name_array) { free(name_array); - name_array = nullptr; + name_array = NULL; } if (id_array) { free(id_array); - id_array = nullptr; + id_array = NULL; } user_list.Purge(); @@ -372,7 +372,7 @@ int UserDB::Purge() int UserDB::Init(LaborDB *db) { FnTrace("UserDB::Init()"); - for (Employee *e = UserList(); e != nullptr; e = e->next) + for (Employee *e = UserList(); e != NULL; e = e->next) e->last_job = db->CurrentJob(e); return 0; } @@ -380,7 +380,7 @@ int UserDB::Init(LaborDB *db) Employee *UserDB::FindByID(int user_id) { FnTrace("UserDB::FindByID()"); - for (Employee *e = UserList(); e != nullptr; e = e->next) + for (Employee *e = UserList(); e != NULL; e = e->next) { if (e->id == user_id) return e; @@ -391,7 +391,7 @@ Employee *UserDB::FindByID(int user_id) else if (super_user && super_user->id == user_id) return super_user; - return nullptr; + return NULL; } Employee *UserDB::FindByKey(int key) @@ -400,23 +400,23 @@ Employee *UserDB::FindByKey(int key) if (developer && key == developer->key) return developer; - for (Employee *e = UserList(); e != nullptr; e = e->next) + for (Employee *e = UserList(); e != NULL; e = e->next) if (e->key == key) return e; if (super_user && super_user->key == key) return super_user; - return nullptr; + return NULL; } Employee *UserDB::FindByName(const char* name) { FnTrace("UserDB::FindByName()"); - for (Employee *e = UserList(); e != nullptr; e = e->next) + for (Employee *e = UserList(); e != NULL; e = e->next) if (StringCompare(e->system_name.Value(), name) == 0) return e; - return nullptr; + return NULL; } Employee *UserDB::NameSearch(const std::string &name, Employee *user) @@ -426,11 +426,11 @@ Employee *UserDB::NameSearch(const std::string &name, Employee *user) return nullptr; if (user) - for (Employee *e = user->next; e != nullptr; e = e->next) + for (Employee *e = user->next; e != NULL; e = e->next) if (StringCompare(e->system_name.Value(), name, static_cast(name.size())) == 0) return e; - for (Employee *e = UserList(); e != nullptr; e = e->next) + for (Employee *e = UserList(); e != NULL; e = e->next) if (StringCompare(e->system_name.Value(), name, static_cast(name.size())) == 0) return e; return nullptr; @@ -448,7 +448,7 @@ int UserDB::FindRecordByWord(Terminal *t, const std::string &word, int active, i int len = static_cast(word.size()); Employee **array = NameArray(); - if (array == nullptr) + if (array == NULL) return -1; int record = 0, loop = 0; @@ -502,11 +502,11 @@ Employee *UserDB::FindByRecord(Terminal *t, int record, int active) { FnTrace("UserDB::FindByRecord()"); if (record < 0) - return nullptr; + return NULL; Employee **array = NameArray(); - if (array == nullptr) - return nullptr; + if (array == NULL) + return NULL; for (int i = 0; i < UserCount(); ++i) { @@ -518,7 +518,7 @@ Employee *UserDB::FindByRecord(Terminal *t, int record, int active) return e; } } - return nullptr; + return NULL; } int UserDB::FindUniqueID() @@ -528,7 +528,7 @@ int UserDB::FindUniqueID() for (;;) { Employee *e = FindByID(new_id); - if (e == nullptr) + if (e == NULL) return new_id; ++new_id; } @@ -541,7 +541,7 @@ int UserDB::FindUniqueKey() for (;;) { Employee *e = FindByKey(new_key); - if (e == nullptr) + if (e == NULL) return new_key; ++new_key; } @@ -550,7 +550,7 @@ int UserDB::FindUniqueKey() int UserDB::ListReport(Terminal *t, int active, Report *r) { FnTrace("UserDB::ListReport()"); - if (r == nullptr) + if (r == NULL) return 1; LaborDB *ldb = &(t->system_data->labor_db); @@ -612,7 +612,7 @@ int UserDB::UserCount(Terminal *t, int active) { FnTrace("UserDB::UserCount()"); int count = 0; - for (Employee *e = UserList(); e != nullptr; e = e->next) + for (Employee *e = UserList(); e != NULL; e = e->next) if (e->Show(t, active)) ++count; return count; @@ -621,8 +621,8 @@ int UserDB::UserCount(Terminal *t, int active) Employee *UserDB::NextUser(Terminal *term, Employee *employee, int active) { FnTrace("UserDB::NextUser()"); - if (employee == nullptr || UserList() == nullptr) - return nullptr; + if (employee == NULL || UserList() == NULL) + return NULL; if (employee == super_user || employee == developer) return NextUser(term, UserListEnd(), active); @@ -632,26 +632,26 @@ Employee *UserDB::NextUser(Terminal *term, Employee *employee, int active) Employee *em = employee->next; while (em != employee) { - if (em == nullptr) + if (em == NULL) { em = UserList(); ++count; if (count > 2) - return nullptr; + return NULL; } if ((em->active == active || active < 0) && em->CanEnterSystem(s)) return em; em = em->next; } - return nullptr; + return NULL; } Employee *UserDB::ForeUser(Terminal *t, Employee *e, int active) { FnTrace("UserDB::ForeUser()"); - if (e == nullptr || UserListEnd() == nullptr) - return nullptr; + if (e == NULL || UserListEnd() == NULL) + return NULL; if (e == super_user || e == developer) return ForeUser(t, UserList(), active); @@ -661,18 +661,18 @@ Employee *UserDB::ForeUser(Terminal *t, Employee *e, int active) Employee *em = e->fore; while (em != e) { - if (em == nullptr) + if (em == NULL) { em = UserListEnd(); ++count; if (count > 2) - return nullptr; + return NULL; } if ((em->active == active || active < 0) && em->CanEnterSystem(s)) return em; em = em->fore; } - return nullptr; + return NULL; } int UserDB::ChangePageID(int old_id, int new_id) @@ -682,8 +682,8 @@ int UserDB::ChangePageID(int old_id, int new_id) return 0; // no changes int changes = 0; - for (Employee *e = UserList(); e != nullptr; e = e->next) - for (JobInfo *j = e->JobList(); j != nullptr; j = j->next) + for (Employee *e = UserList(); e != NULL; e = e->next) + for (JobInfo *j = e->JobList(); j != NULL; j = j->next) if (j->starting_page == old_id) { ++changes; @@ -712,7 +712,7 @@ Employee *UserDB::NewUser() e = new Employee; if (e) { - auto *j = new JobInfo; + JobInfo *j = new JobInfo; if (j) { e->Add(j); @@ -722,7 +722,7 @@ Employee *UserDB::NewUser() { // Memory allocation failed for JobInfo delete e; - e = nullptr; + e = NULL; fprintf(stderr, "ERROR: Failed to allocate JobInfo in NewUser()\n"); } } @@ -737,17 +737,17 @@ Employee *UserDB::NewUser() Employee *UserDB::KeyConflict(Employee *server) { FnTrace("UserDB::KeyConflict()"); - for (Employee *e = UserList(); e != nullptr; e = e->next) + for (Employee *e = UserList(); e != NULL; e = e->next) if (e != server && e->key == server->key) return e; // key conflict - return nullptr; // no conflicts + return NULL; // no conflicts } Employee **UserDB::NameArray(int resort) { FnTrace("UserDB::NameArray()"); int users = UserCount(); - if (name_array == nullptr) + if (name_array == NULL) { resort = 1; name_array = (Employee **)calloc(sizeof(Employee *), users); @@ -771,7 +771,7 @@ Employee **UserDB::IdArray(int resort) { FnTrace("UserDB::IdArray()"); int users = UserCount(); - if (id_array == nullptr) + if (id_array == NULL) { resort = 1; id_array = (Employee **)calloc(sizeof(Employee *), users); @@ -780,7 +780,7 @@ Employee **UserDB::IdArray(int resort) if (resort) { int i = 0; - for (Employee *e = UserList(); e != nullptr; e = e->next) + for (Employee *e = UserList(); e != NULL; e = e->next) id_array[i++] = e; qsort(id_array, users, sizeof(Employee *), UserIdCompare); @@ -794,8 +794,8 @@ Employee **UserDB::IdArray(int resort) Employee::Employee() { FnTrace("Employee::Employee()"); - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; id = 0; employee_no = 0; training = 1; // new employee default to training mode @@ -855,7 +855,7 @@ int Employee::Read(InputDataFile &df, int version) ReportError("Unexpected end of Job data in Employee record"); return 1; } - auto *j = new JobInfo; + JobInfo *j = new JobInfo; j->Read(df, version); if (version <= 7) j->dept_code = dept_code; @@ -887,7 +887,7 @@ int Employee::Write(OutputDataFile &df, int version) error += df.Write(active, 1); error += df.Write(JobCount()); - for (JobInfo *j = JobList(); j != nullptr; j = j->next) + for (JobInfo *j = JobList(); j != NULL; j = j->next) error += j->Write(df, version); return error; } @@ -908,14 +908,14 @@ JobInfo *Employee::FindJobByType(int job) { FnTrace("Employee::FindJobByType()"); JobInfo *jinfo = JobList(); - JobInfo *retval = nullptr; + JobInfo *retval = NULL; - while (jinfo != nullptr) + while (jinfo != NULL) { if (jinfo->job == job) { retval = jinfo; - jinfo = nullptr; + jinfo = NULL; } else jinfo = jinfo->next; @@ -933,19 +933,19 @@ JobInfo *Employee::FindJobByNumber(int no) const char* Employee::JobTitle(Terminal *t) { FnTrace("Employee::JobTitle()"); - JobInfo *j = nullptr; - const char* retval = nullptr; + JobInfo *j = NULL; + const char* retval = NULL; if (last_job > 0) { j = FindJobByType(last_job); - if (j == nullptr) + if (j == NULL) j = JobList(); } else j = JobList(); - if (j == nullptr) + if (j == NULL) retval = t->Translate(UnknownStr); else retval = j->Title(t); @@ -963,7 +963,7 @@ int Employee::StartingPage() { FnTrace("Employee::StartingPage()"); JobInfo *j = FindJobByType(current_job); - if (j == nullptr) + if (j == NULL) return -1; else if (j->curr_starting_page != j->starting_page) return j->curr_starting_page; @@ -977,7 +977,7 @@ int Employee::SetStartingPage(int spage_id) int retval = 1; JobInfo *j = FindJobByType(current_job); - if (j != nullptr) + if (j != NULL) { retval = 1; j->curr_starting_page = spage_id; @@ -1056,7 +1056,7 @@ int Employee::Show(Terminal *t, int act) if (act >= 0 && active != act) return 0; - for (JobInfo *j = JobList(); j != nullptr; j = j->next) + for (JobInfo *j = JobList(); j != NULL; j = j->next) if (j->job != JOB_NONE && ((1 << j->job) & t->job_filter) == 0) return 1; return (t->job_filter == 0); diff --git a/main/business/employee.hh b/main/business/employee.hh index 48e7b681..e634f571 100644 --- a/main/business/employee.hh +++ b/main/business/employee.hh @@ -18,8 +18,8 @@ * Employee information classes */ -#ifndef EMPLOYEE_HH -#define EMPLOYEE_HH +#ifndef _EMPLOYEE_HH +#define _EMPLOYEE_HH #include "utility.hh" #include "list_utility.hh" diff --git a/main/business/inventory.cc b/main/business/inventory.cc index 5a31b1c4..ade98707 100644 --- a/main/business/inventory.cc +++ b/main/business/inventory.cc @@ -46,7 +46,7 @@ const char* PurchaseUnitName[] = { "Volume - Ounce", "Volume - Pint", "Volume - Quart", "Volume - Gallon", "Weight - Gram", "Weight - Kilogram", - "Volume - Mililiter", "Volume - Liter", nullptr}; + "Volume - Mililiter", "Volume - Liter", NULL}; int PurchaseUnitValue[] = { COUNT_SINGLE, COUNT_DOZEN, COUNT_GROSS, WEIGHT_OUNCE, WEIGHT_POUND, @@ -60,7 +60,7 @@ const char* RecipeUnitName[] = { "Volume - Dram", "Volume - TSP", "Volume - TBS", "Volume - Ounce", "Volume - Cup", "Volume - Pint", "Volume - Quart", "Weight - Gram", "Weight - Kilogram", - "Volume - Mililiter", "Volume - Liter", nullptr}; + "Volume - Mililiter", "Volume - Liter", NULL}; int RecipeUnitValue[] = { COUNT_SINGLE, WEIGHT_DASH, WEIGHT_OUNCE, @@ -217,7 +217,7 @@ char* UnitAmount::Description(char* str) { FnTrace("UnitAmount::Description()"); static genericChar buffer[256]; - if (str == nullptr) + if (str == NULL) str = buffer; str[0] = '\0'; @@ -254,7 +254,7 @@ char* UnitAmount::Measurement( char* str) { FnTrace("UnitAmount::Measurement()"); static genericChar buffer[16]; - if (str == nullptr) + if (str == NULL) str = buffer; str[0] = '\0'; @@ -320,8 +320,8 @@ UnitAmount &UnitAmount::operator-= (UnitAmount &ua) // Constructor Product::Product() { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; cost = 0; id = 0; } @@ -368,8 +368,8 @@ int Product::DoesVendorHave(int vendor_id) // Constructor RecipePart::RecipePart() { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; part_id = 0; } @@ -408,8 +408,8 @@ int RecipePart::Write(OutputDataFile &df, int version) // Constructor Recipe::Recipe() { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; prepare_time = 0; id = 0; in_menu = 0; @@ -440,7 +440,7 @@ int Recipe::Read(Inventory *inv, InputDataFile &df, int version) { if (df.end_of_file) return 1; - auto *rp = new RecipePart; + RecipePart *rp = new RecipePart; error += rp->Read(inv, df, version); Add(rp); } @@ -464,7 +464,7 @@ int Recipe::Write(OutputDataFile &df, int version) error += serving.Write(df, 1); error += df.Write(PartCount()); - for (RecipePart *rp = PartList(); rp != nullptr; rp = rp->next) + for (RecipePart *rp = PartList(); rp != NULL; rp = rp->next) rp->Write(df, version); return error; } @@ -540,8 +540,8 @@ int Recipe::RemoveIngredient(int part_id, UnitAmount &ua) // Constructor Vendor::Vendor() { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; id = 0; } @@ -618,7 +618,7 @@ int Inventory::Load(const char* file) return 1; } - auto *pr = new Product; + Product *pr = new Product; error += pr->Read(df, version); Add(pr); } @@ -632,7 +632,7 @@ int Inventory::Load(const char* file) return 1; } - auto *rc = new Recipe; + Recipe *rc = new Recipe; error += rc->Read(this, df, version); Add(rc); } @@ -646,7 +646,7 @@ int Inventory::Load(const char* file) return 1; } - auto *v = new Vendor; + Vendor *v = new Vendor; error += v->Read(df, version); Add(v); } @@ -668,15 +668,15 @@ int Inventory::Save() int error = 0; error += df.Write(ProductCount()); - for (Product *pr = ProductList(); pr != nullptr; pr = pr->next) + for (Product *pr = ProductList(); pr != NULL; pr = pr->next) error += pr->Write(df, 7); error += df.Write(RecipeCount()); - for (Recipe *rc = RecipeList(); rc != nullptr; rc = rc->next) + for (Recipe *rc = RecipeList(); rc != NULL; rc = rc->next) error += rc->Write(df, 7); error += df.Write(VendorCount()); - for (Vendor *v = VendorList(); v != nullptr; v = v->next) + for (Vendor *v = VendorList(); v != NULL; v = v->next) error += v->Write(df, 7); return error; @@ -685,7 +685,7 @@ int Inventory::Save() int Inventory::Add(Product *pr) { FnTrace("Inventory::Add(Product)"); - if (pr == nullptr) + if (pr == NULL) return 1; // Start at end of list and work backwords @@ -707,7 +707,7 @@ int Inventory::Add(Product *pr) int Inventory::Add(Recipe *rc) { FnTrace("Inventory::Add(Recipe)"); - if (rc == nullptr) + if (rc == NULL) return 1; // Start at end of list and work backwords @@ -729,7 +729,7 @@ int Inventory::Add(Recipe *rc) int Inventory::Add(Vendor *v) { FnTrace("Inventory::Add(Vendor)"); - if (v == nullptr) + if (v == NULL) return 1; // Start at end of list and work backwords @@ -751,7 +751,7 @@ int Inventory::Add(Vendor *v) int Inventory::Add(Stock *s) { FnTrace("Inventory::Add(Stock)"); - if (s == nullptr) + if (s == NULL) return 1; stock_list.AddToTail(s); @@ -804,10 +804,10 @@ int Inventory::LoadStock(const char* path) stock_path.Set(path); DIR *dp = opendir(stock_path.Value()); - if (dp == nullptr) + if (dp == NULL) return 1; // Error - can't find directory - struct dirent *record = nullptr; + struct dirent *record = NULL; do { record = readdir(dp); @@ -823,8 +823,8 @@ int Inventory::LoadStock(const char* path) { genericChar str[256]; vt_safe_string::safe_format(str, 256, "%s/%s", stock_path.Value(), name); - auto *s = new Stock; - if (s == nullptr) + Stock *s = new Stock; + if (s == NULL) ReportError("Couldn't create stock"); else { @@ -843,16 +843,16 @@ int Inventory::LoadStock(const char* path) int Inventory::PartMatches(const char* word) { FnTrace("Inventory::PartMatches()"); - if (word == nullptr) + if (word == NULL) return 0; int match = 0; int len = strlen(word); - for (Product *pr = ProductList(); pr != nullptr; pr = pr->next) + for (Product *pr = ProductList(); pr != NULL; pr = pr->next) if (StringCompare(pr->name.Value(), word, len) == 0) ++match; - for (Recipe *rc = RecipeList(); rc != nullptr; rc = rc->next) + for (Recipe *rc = RecipeList(); rc != NULL; rc = rc->next) if (StringCompare(rc->name.Value(), word, len) == 0) ++match; return match; @@ -867,27 +867,27 @@ Product *Inventory::FindProductByRecord(int record) Product *Inventory::FindProductByWord(const char* word, int &record) { FnTrace("Inventory::FindProductByWord()"); - if (word == nullptr) - return nullptr; + if (word == NULL) + return NULL; record = 0; int len = strlen(word); - for (Product *pr = ProductList(); pr != nullptr; pr = pr->next) + for (Product *pr = ProductList(); pr != NULL; pr = pr->next) { if (StringCompare(pr->name.Value(), word, len) == 0) return pr; ++record; } - return nullptr; + return NULL; } Product *Inventory::FindProductByID(int id) { FnTrace("Inventory::FindProductByID()"); - for (Product *pr = ProductList(); pr != nullptr; pr = pr->next) + for (Product *pr = ProductList(); pr != NULL; pr = pr->next) if (pr->id == id) return pr; - return nullptr; + return NULL; } Recipe *Inventory::FindRecipeByRecord(int record) @@ -899,36 +899,36 @@ Recipe *Inventory::FindRecipeByRecord(int record) Recipe *Inventory::FindRecipeByWord(const char* word, int &record) { FnTrace("Inventory::FindRecipeByWord()"); - if (word == nullptr) - return nullptr; + if (word == NULL) + return NULL; record = 0; int len = strlen(word); - for (Recipe *rc = RecipeList(); rc != nullptr; rc = rc->next) + for (Recipe *rc = RecipeList(); rc != NULL; rc = rc->next) { if (StringCompare(rc->name.Value(), word, len) == 0) return rc; ++record; } - return nullptr; + return NULL; } Recipe *Inventory::FindRecipeByID(int id) { FnTrace("Inventory::FindRecipeByID()"); - for (Recipe *rc = RecipeList(); rc != nullptr; rc = rc->next) + for (Recipe *rc = RecipeList(); rc != NULL; rc = rc->next) if (rc->id == id) return rc; - return nullptr; + return NULL; } Recipe *Inventory::FindRecipeByName(const char* name) { FnTrace("Inventory::FindRecipeByName()"); - for (Recipe *rc = RecipeList(); rc != nullptr; rc = rc->next) + for (Recipe *rc = RecipeList(); rc != NULL; rc = rc->next) if (StringCompare(rc->name.Value(), name) == 0) return rc; - return nullptr; + return NULL; } Vendor *Inventory::FindVendorByRecord(int record) @@ -940,43 +940,43 @@ Vendor *Inventory::FindVendorByRecord(int record) Vendor *Inventory::FindVendorByWord(const char* word, int &record) { FnTrace("Inventory::FindVendorByWord()"); - if (word == nullptr) - return nullptr; + if (word == NULL) + return NULL; record = 0; int len = strlen(word); - for (Vendor *v = VendorList(); v != nullptr; v = v->next) + for (Vendor *v = VendorList(); v != NULL; v = v->next) { if (StringCompare(v->name.Value(), word, len) == 0) return v; ++record; } - return nullptr; + return NULL; } Vendor *Inventory::FindVendorByID(int id) { FnTrace("Inventory::FindVendorByID()"); - for (Vendor *v = VendorList(); v != nullptr; v = v->next) + for (Vendor *v = VendorList(); v != NULL; v = v->next) if (id == v->id) return v; - return nullptr; + return NULL; } int Inventory::ProductListReport(Terminal *t, Stock *s, Report *r) { FnTrace("Inventory::ProductListReport(Stock)"); - if (r == nullptr) + if (r == NULL) return 1; - if (s == nullptr) + if (s == NULL) { r->TextC("Can't find stock information"); return 0; } Product *pr = ProductList(); - if (pr == nullptr) + if (pr == NULL) { r->TextC("There are no products definied"); return 0; @@ -1042,11 +1042,11 @@ int Inventory::ProductListReport(Terminal *t, Stock *s, Report *r) int Inventory::ProductListReport(Terminal *t, Invoice *in, Report *r) { FnTrace("Inventory::ProductListReport(Invoice)"); - if (in == nullptr || r == nullptr) + if (in == NULL || r == NULL) return 1; Product *pr = ProductList(); - if (pr == nullptr) + if (pr == NULL) { r->TextC("There are no products definied"); return 0; @@ -1082,7 +1082,7 @@ int Inventory::ProductListReport(Terminal *t, Invoice *in, Report *r) int Inventory::ScanItems(ItemDB *db) { FnTrace("Inventory::ScanItems()"); - if (db == nullptr) + if (db == NULL) return 1; // Clear 'in_menu' flags @@ -1148,7 +1148,7 @@ bool Inventory::ChangeRecipeName(const std::string &old_name, const std::string return true; } - for (Recipe *r = RecipeList(); r != nullptr; r = r->next) + for (Recipe *r = RecipeList(); r != NULL; r = r->next) { if (StringCompare(r->name.Value(), old_name) == 0) { @@ -1163,9 +1163,9 @@ Stock *Inventory::CurrentStock() { FnTrace("Inventory::CurrentStock()"); Stock *end = StockListEnd(); - if (end == nullptr || end->end_time.IsSet()) + if (end == NULL || end->end_time.IsSet()) { - auto *s = new Stock; + Stock *s = new Stock; Add(s); genericChar str[256]; @@ -1179,12 +1179,12 @@ int Inventory::MakeOrder(Check *c) { FnTrace("Inventory::MakeOrder()"); Stock *s = CurrentStock(); - if (s == nullptr) + if (s == NULL) return 1; int changed = 0; - for (SubCheck *sc = c->SubList(); sc != nullptr; sc = sc->next) - for (Order *o = sc->OrderList(); o != nullptr; o = o->next) + for (SubCheck *sc = c->SubList(); sc != NULL; sc = sc->next) + for (Order *o = sc->OrderList(); o != NULL; o = o->next) if (!(o->status & ORDER_MADE) && (o->status & ORDER_SENT)) { o->status |= ORDER_MADE; @@ -1192,7 +1192,7 @@ int Inventory::MakeOrder(Check *c) { Recipe *rc = FindRecipeByName(o->item_name.Value()); if (rc) - for (RecipePart *rp = rc->PartList(); rp != nullptr; rp = rp->next) + for (RecipePart *rp = rc->PartList(); rp != NULL; rp = rp->next) { StockEntry *se = s->FindStock(rp->part_id, 1); UnitAmount ua = rp->amount; @@ -1211,10 +1211,10 @@ int Inventory::MakeOrder(Check *c) int Inventory::InvoiceReport(Terminal *t, Invoice *in, Report *r) { FnTrace("Inventory::InvoiceReport()"); - if (r == nullptr) + if (r == NULL) return 1; - if (in == nullptr) + if (in == NULL) { r->TextC("No Invoice"); return 0; @@ -1280,8 +1280,8 @@ int Inventory::InvoiceReport(Terminal *t, Invoice *in, Report *r) // Constructor InvoiceEntry::InvoiceEntry() { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; product_id = 0; } @@ -1309,8 +1309,8 @@ int InvoiceEntry::Write(OutputDataFile &df, int version) // Constructor Invoice::Invoice() { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; vendor_id = 0; id = 0; } @@ -1336,7 +1336,7 @@ int Invoice::Read(InputDataFile &df, int version) if (df.end_of_file) return 1; - auto *ie = new InvoiceEntry; + InvoiceEntry *ie = new InvoiceEntry; error += ie->Read(df, version); Add(ie); } @@ -1352,7 +1352,7 @@ int Invoice::Write(OutputDataFile &df, int version) error += df.Write(time); error += df.Write(EntryCount()); - for (InvoiceEntry *ie = EntryList(); ie != nullptr; ie = ie->next) + for (InvoiceEntry *ie = EntryList(); ie != NULL; ie = ie->next) error += ie->Write(df, version); return error; } @@ -1381,14 +1381,14 @@ InvoiceEntry *Invoice::FindEntry(int product_id, int create) FnTrace("Invoice::FindEntry()"); InvoiceEntry *ie; - for (ie = EntryList(); ie != nullptr; ie = ie->next) + for (ie = EntryList(); ie != NULL; ie = ie->next) { if (ie->product_id == product_id) return ie; } if (create <= 0) - return nullptr; + return NULL; ie = new InvoiceEntry; ie->product_id = product_id; @@ -1400,8 +1400,8 @@ InvoiceEntry *Invoice::FindEntry(int product_id, int create) // Constructor StockEntry::StockEntry() { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; product_id = 0; } @@ -1430,8 +1430,8 @@ int StockEntry::Write(OutputDataFile &df, int version) // Constructor Stock::Stock() { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; id = 0; } @@ -1452,7 +1452,7 @@ int Stock::Read(InputDataFile &df, int version) if (df.end_of_file) return 1; - auto *se = new StockEntry; + StockEntry *se = new StockEntry; error += se->Read(df, version); Add(se); } @@ -1464,7 +1464,7 @@ int Stock::Read(InputDataFile &df, int version) if (df.end_of_file) return 1; - auto *in = new Invoice; + Invoice *in = new Invoice; error += in->Read(df, version); Add(in); } @@ -1479,11 +1479,11 @@ int Stock::Write(OutputDataFile &df, int version) error += df.Write(end_time); error += df.Write(EntryCount()); - for (StockEntry *se = EntryList(); se != nullptr; se = se->next) + for (StockEntry *se = EntryList(); se != NULL; se = se->next) error += se->Write(df, version); error += df.Write(InvoiceCount()); - for (Invoice *in = InvoiceList(); in != nullptr; in = in->next) + for (Invoice *in = InvoiceList(); in != NULL; in = in->next) error += in->Write(df, version); return error; } @@ -1550,14 +1550,14 @@ StockEntry *Stock::FindStock(int product_id, int create) FnTrace("Stock::FindStock()"); StockEntry *se; - for (se = EntryList(); se != nullptr; se = se->next) + for (se = EntryList(); se != NULL; se = se->next) { if (se->product_id == product_id) return se; } if (create <= 0) - return nullptr; + return NULL; se = new StockEntry; se->product_id = product_id; @@ -1630,7 +1630,7 @@ Invoice *Stock::NewInvoice(int vendor_id) } } - auto *in = new Invoice; + Invoice *in = new Invoice; in->vendor_id = vendor_id; in->time = SystemTime; Add(in); diff --git a/main/business/inventory.hh b/main/business/inventory.hh index 7901d647..1c8f56a3 100644 --- a/main/business/inventory.hh +++ b/main/business/inventory.hh @@ -18,8 +18,8 @@ * Raw Product, Receipe & Vendor data bases */ -#ifndef INVENTORY_HH -#define INVENTORY_HH +#ifndef _INVENTORY_HH +#define _INVENTORY_HH #include "utility.hh" #include "list_utility.hh" @@ -73,8 +73,8 @@ public: int Read(InputDataFile &df, int version); int Write(OutputDataFile &df, int version); int Convert(int new_type); - genericChar* Description( char* str = nullptr); - genericChar* Measurement( char* str = nullptr); + genericChar* Description( char* str = NULL); + genericChar* Measurement( char* str = NULL); UnitAmount &operator *= (Flt a) { amount *= a; return *this; } @@ -261,7 +261,7 @@ public: int Remove(StockEntry *se); int Remove(Invoice *in); int Purge(); - int Load(const char* file = nullptr); + int Load(const char* file = NULL); int Save(); int Total(); Invoice *NewInvoice(int vendor_id); diff --git a/main/business/labor.cc b/main/business/labor.cc index fe0ac147..1efff910 100644 --- a/main/business/labor.cc +++ b/main/business/labor.cc @@ -42,29 +42,29 @@ // Constructors WorkEntry::WorkEntry() { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; user_id = 0; job = 0; pay_rate = PERIOD_HOUR; pay_amount = 0; tips = 0; edit_id = 0; - original = nullptr; + original = NULL; end_shift = 0; overtime = 0; } WorkEntry::WorkEntry(Employee *e, int j) { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; user_id = e->id; start = SystemTime; start.Floor(); tips = 0; edit_id = 0; - original = nullptr; + original = NULL; end_shift = 0; job = j; overtime = 0; @@ -97,9 +97,9 @@ WorkEntry::~WorkEntry() // Member Functions WorkEntry *WorkEntry::Copy() { - auto *w = new WorkEntry; - if (w == nullptr) - return nullptr; + WorkEntry *w = new WorkEntry; + if (w == NULL) + return NULL; w->user_id = user_id; w->job = job; @@ -286,7 +286,7 @@ int WorkEntry::Edit(int my_user_id) } WorkEntry *work_entry = Copy(); - if (work_entry == nullptr) + if (work_entry == NULL) return 1; original = work_entry; @@ -298,7 +298,7 @@ int WorkEntry::Update(LaborPeriod *lp) { FnTrace("WorkEntry::Update()"); WorkEntry *work_entry = original; - if (work_entry == nullptr) + if (work_entry == NULL) return 0; if (lp->fore && start < lp->fore->end_time) @@ -323,7 +323,7 @@ int WorkEntry::Update(LaborPeriod *lp) pay_amount == work_entry->pay_amount && pay_rate == work_entry->pay_rate) { delete original; - original = nullptr; + original = NULL; edit_id = 0; } return 0; @@ -333,7 +333,7 @@ int WorkEntry::UndoEdit() { FnTrace("WorkEntry::UndoEdit()"); WorkEntry *work_entry = original; - if (work_entry == nullptr) + if (work_entry == NULL) return 0; start = work_entry->start; @@ -344,7 +344,7 @@ int WorkEntry::UndoEdit() tips = work_entry->tips; delete original; - original = nullptr; + original = NULL; edit_id = 0; return 0; } @@ -390,8 +390,8 @@ int WorkEntry::Overlap(TimeInfo &st, TimeInfo &et) // Constructor LaborPeriod::LaborPeriod() { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; serial_number = 0; loaded = 0; } @@ -400,7 +400,7 @@ LaborPeriod::LaborPeriod() int LaborPeriod::Add(WorkEntry *work_entry) { FnTrace("LaborPeriod::Add()"); - if (work_entry == nullptr) + if (work_entry == NULL) return 1; // Start at end of list & work backwards @@ -428,7 +428,7 @@ int LaborPeriod::Purge() int LaborPeriod::Scan(const char* filename) { FnTrace("LaborPeriod::Scan()"); - if (filename == nullptr) + if (filename == NULL) return 1; file_name.Set(filename); @@ -484,7 +484,7 @@ int LaborPeriod::Load() return 1; } - auto *work_entry = new WorkEntry; + WorkEntry *work_entry = new WorkEntry; error += work_entry->Read(df, version); Add(work_entry); work_entry->Update(this); @@ -525,7 +525,7 @@ int LaborPeriod::Save() // Add safety limit to prevent infinite loops from corrupted linked lists int max_iterations = 10000; int iterations = 0; - for (WorkEntry *work_entry = WorkList(); work_entry != nullptr && iterations < max_iterations; work_entry = work_entry->next) + for (WorkEntry *work_entry = WorkList(); work_entry != NULL && iterations < max_iterations; work_entry = work_entry->next) { work_entry->Update(this); error += work_entry->Write(df, LABOR_VERSION); @@ -541,7 +541,7 @@ int LaborPeriod::Save() int LaborPeriod::ShiftReport(Terminal *t, WorkEntry *work_entry, Report *r) { FnTrace("LaborPeriod::ShiftReport()"); - if (work_entry == nullptr || r == nullptr) + if (work_entry == NULL || r == NULL) return 1; r->TextC("Work Summary Report"); @@ -561,7 +561,7 @@ int LaborPeriod::WorkReport(Terminal *t, Employee *user, TimeInfo &tm_s, TimeInfo &tm_e, Report *r) { FnTrace("LaborPeriod::WorkReport()"); - if (r == nullptr) + if (r == NULL) return 1; Settings *s = t->GetSettings(); @@ -603,7 +603,7 @@ int LaborPeriod::WorkReport(Terminal *t, Employee *user, TimeInfo &tm_s, te = now; te.Floor(); } - if ((user == nullptr || user->id == wid) && ts <= end && te >= start && + if ((user == NULL || user->id == wid) && ts <= end && te >= start && ((1 << work_entry->job) & t->job_filter) == 0) { if (!work_entry->end.IsSet()) @@ -682,7 +682,7 @@ int LaborPeriod::WorkReport(Terminal *t, Employee *user, TimeInfo &tm_s, } work_entry = work_entry->next; - if (last_id == wid && (work_entry == nullptr || work_entry->user_id != wid)) + if (last_id == wid && (work_entry == NULL || work_entry->user_id != wid)) { r->Mode(PRINT_BOLD); // r->TextPosR(-25, "Total", COLOR_DK_GREEN); @@ -730,13 +730,13 @@ WorkEntry *LaborPeriod::WorkReportEntry(Terminal *t, int line, Employee *user, if (!te.IsSet()) te = SystemTime; - if ((user == nullptr || user->id == wid) && work_entry->start <= end && te >= start && + if ((user == NULL || user->id == wid) && work_entry->start <= end && te >= start && ((1 << work_entry->job) & t->job_filter) == 0) { if (line == l) return work_entry; else if (l > line) - return nullptr; + return NULL; ++l; last_id = wid; @@ -745,10 +745,10 @@ WorkEntry *LaborPeriod::WorkReportEntry(Terminal *t, int line, Employee *user, } work_entry = work_entry->next; - if (last_id == wid && (work_entry == nullptr || work_entry->user_id != wid)) + if (last_id == wid && (work_entry == NULL || work_entry->user_id != wid)) l+= 2; } - return nullptr; + return NULL; } int LaborPeriod::WorkReportLine(Terminal *t, WorkEntry *work, Employee *user, @@ -778,7 +778,7 @@ int LaborPeriod::WorkReportLine(Terminal *t, WorkEntry *work, Employee *user, if (!te.IsSet()) te = SystemTime; - if ((user == nullptr || user->id == wid) && work_entry->start <= end && te >= start && + if ((user == NULL || user->id == wid) && work_entry->start <= end && te >= start && ((1 << work_entry->job) & t->job_filter) == 0) { if (work == work_entry) @@ -790,7 +790,7 @@ int LaborPeriod::WorkReportLine(Terminal *t, WorkEntry *work, Employee *user, ++l; } work_entry = work_entry->next; - if (last_id == wid && (work_entry == nullptr || work_entry->user_id != wid)) + if (last_id == wid && (work_entry == NULL || work_entry->user_id != wid)) l+= 2; } return -1; @@ -813,11 +813,11 @@ int LaborDB::Load(const char* path) } DIR *dp = opendir(pathname.Value()); - if (dp == nullptr) + if (dp == NULL) return 1; char str[256]; - struct dirent *record = nullptr; + struct dirent *record = NULL; do { record = readdir(dp); @@ -830,7 +830,7 @@ int LaborDB::Load(const char* path) if (strncmp(name, "labor_", 6) == 0) { vt_safe_string::safe_format(str, 256, "%s/%s", pathname.Value(), name); - auto *lp = new LaborPeriod; + LaborPeriod *lp = new LaborPeriod; if (lp->Scan(str)) { ReportError("Couldn't load labor period"); @@ -849,7 +849,7 @@ int LaborDB::Load(const char* path) int LaborDB::Add(LaborPeriod *lp) { FnTrace("LaborDB::Add()"); - if (lp == nullptr) + if (lp == NULL) return 1; // Add failed // start at end of list and work backwords @@ -883,8 +883,8 @@ int LaborDB::Purge() int LaborDB::NewLaborPeriod() { FnTrace("LaborDB::NewLaborPerion()"); - auto *lp = new LaborPeriod; - if (lp == nullptr) + LaborPeriod *lp = new LaborPeriod; + if (lp == NULL) return 1; LaborPeriod *end = PeriodListEnd(); @@ -896,7 +896,7 @@ int LaborDB::NewLaborPeriod() if (!work_entry->IsWorkDone()) { work_entry->EndEntry(SystemTime); - auto *nw = new WorkEntry; + WorkEntry *nw = new WorkEntry; nw->user_id = work_entry->user_id; nw->start = SystemTime; nw->job = work_entry->job; @@ -923,13 +923,13 @@ int LaborDB::NewLaborPeriod() LaborPeriod *LaborDB::CurrentPeriod() { FnTrace("LaborDB::CurrentPeriod()"); - LaborPeriod *lp = nullptr; - if (PeriodListEnd() == nullptr) + LaborPeriod *lp = NULL; + if (PeriodListEnd() == NULL) NewLaborPeriod(); lp = PeriodListEnd(); - if (lp == nullptr) - return nullptr; + if (lp == NULL) + return NULL; if (lp->loaded == 0) lp->Load(); @@ -939,12 +939,12 @@ LaborPeriod *LaborDB::CurrentPeriod() WorkEntry *LaborDB::CurrentWorkEntry(Employee *e) { FnTrace("LaborDB::CurrentWorkEntry()"); - if (e == nullptr) - return nullptr; + if (e == NULL) + return NULL; LaborPeriod *lp = CurrentPeriod(); - if (lp == nullptr) - return nullptr; + if (lp == NULL) + return NULL; WorkEntry *work_entry = lp->WorkListEnd(); // Add safety check to prevent infinite loops from corrupted linked lists @@ -962,27 +962,27 @@ WorkEntry *LaborDB::CurrentWorkEntry(Employee *e) // If we hit max iterations, the list might be corrupted - return NULL to be safe if (iterations >= max_iterations) - return nullptr; + return NULL; - return nullptr; + return NULL; } int LaborDB::IsUserOnClock(Employee *e) { FnTrace("LaborDB::IsUserOnClock()"); - if (e == nullptr) + if (e == NULL) return 0; if (e->UseClock() == 0) return 1; WorkEntry *work_entry = CurrentWorkEntry(e); - return (work_entry != nullptr); + return (work_entry != NULL); } int LaborDB::IsUserOnBreak(Employee *e) { FnTrace("LaborDB::IsUserOnBreak()"); - if (e == nullptr) + if (e == NULL) return 0; if (e->UseClock() == 0) return 0; @@ -1012,7 +1012,7 @@ int LaborDB::IsUserOnBreak(Employee *e) int LaborDB::CurrentJob(Employee *e) { FnTrace("LaborDB::CurrentJob()"); - if (e == nullptr) + if (e == NULL) return 0; if (e->id == 1) @@ -1037,14 +1037,14 @@ int LaborDB::CurrentJob(Employee *e) WorkEntry *LaborDB::NewWorkEntry(Employee *e, int job) { FnTrace("LaborDB::NewWorkEntry()"); - if (e == nullptr || IsUserOnClock(e) || !e->UseClock()) - return nullptr; + if (e == NULL || IsUserOnClock(e) || !e->UseClock()) + return NULL; LaborPeriod *lp = CurrentPeriod(); - if (lp == nullptr) - return nullptr; + if (lp == NULL) + return NULL; - auto *work_entry = new WorkEntry(e, job); + WorkEntry *work_entry = new WorkEntry(e, job); lp->Add(work_entry); lp->Save(); return work_entry; @@ -1053,15 +1053,15 @@ WorkEntry *LaborDB::NewWorkEntry(Employee *e, int job) int LaborDB::EndWorkEntry(Employee *e, int end_shift) { FnTrace("LaborDB::EndWorkEntry()"); - if (e == nullptr || e->UseClock() == 0) + if (e == NULL || e->UseClock() == 0) return 1; WorkEntry *work_entry = CurrentWorkEntry(e); - if (work_entry == nullptr) + if (work_entry == NULL) return 1; LaborPeriod *lp = CurrentPeriod(); - if (lp == nullptr) + if (lp == NULL) return 1; work_entry->EndEntry(SystemTime); @@ -1074,7 +1074,7 @@ int LaborDB::ServerLaborReport(Terminal *t, Employee *e, TimeInfo &start, TimeInfo &end, Report *r) { FnTrace("LaborDB::ServerLaborReport()"); - if (e == nullptr || r == nullptr) + if (e == NULL || r == NULL) return 1; TimeInfo ps; @@ -1182,11 +1182,11 @@ int LaborDB::ServerLaborReport(Terminal *t, Employee *e, TimeInfo &start, WorkEntry *LaborDB::StartOfShift(Employee *e) { FnTrace("LaborDB::StartOfShift()"); - if (e == nullptr) - return nullptr; + if (e == NULL) + return NULL; LaborPeriod *lp = PeriodListEnd(); - WorkEntry *first = nullptr; + WorkEntry *first = NULL; while (lp) { WorkEntry *work_entry = lp->WorkListEnd(); @@ -1208,8 +1208,8 @@ WorkEntry *LaborDB::StartOfShift(Employee *e) WorkEntry *LaborDB::NextEntry(WorkEntry *work_entry) { FnTrace("LaborDB::NextEntry()"); - if (work_entry == nullptr) - return nullptr; + if (work_entry == NULL) + return NULL; int user_id = work_entry->user_id; work_entry = work_entry->next; @@ -1219,19 +1219,19 @@ WorkEntry *LaborDB::NextEntry(WorkEntry *work_entry) return work_entry; work_entry = work_entry->next; } - return nullptr; + return NULL; } #define WORKRECEIPT_TITLE "Attendance Receipt" int LaborDB::WorkReceipt(Terminal *t, Employee *e, Report *r) { FnTrace("LaborDB::WorkReceipt()"); - if (r == nullptr) + if (r == NULL) return 1; //r->max_width = 40; WorkEntry *we = StartOfShift(e); - if (we == nullptr) + if (we == NULL) { r->TextC("No work entries found"); return 0; @@ -1377,14 +1377,14 @@ int LaborDB::FigureLabor(Settings *s, TimeInfo &start, TimeInfo &end_time, // Constructor WorkDB::WorkDB() { - archive = nullptr; + archive = NULL; } // Member Functions int WorkDB::Add(WorkEntry *we) { FnTrace("WorkDB::Add()"); - if (we == nullptr) + if (we == NULL) return 1; // Start at end of list & work backwards @@ -1447,7 +1447,7 @@ int WorkDB::Read(InputDataFile &df, int version) df.Read(count); for (int i = 0; i < count; ++i) { - auto *we = new WorkEntry; + WorkEntry *we = new WorkEntry; we->Read(df, version); Add(we); } @@ -1461,7 +1461,7 @@ int WorkDB::Write(OutputDataFile &df, int version) // Add safety limit to prevent infinite loops from corrupted linked lists int max_iterations = 10000; int iterations = 0; - for (WorkEntry *we = WorkList(); we != nullptr && iterations < max_iterations; we = we->next) + for (WorkEntry *we = WorkList(); we != NULL && iterations < max_iterations; we = we->next) { we->Write(df, version); iterations++; diff --git a/main/business/labor.hh b/main/business/labor.hh index 1b29a357..e66ca85c 100644 --- a/main/business/labor.hh +++ b/main/business/labor.hh @@ -18,8 +18,8 @@ * Work scheduling & time clock classes */ -#ifndef LABOR_HH -#define LABOR_HH +#ifndef _LABOR_HH +#define _LABOR_HH #include "utility.hh" #include "list_utility.hh" @@ -169,7 +169,7 @@ public: // Will replace LaborPeriod & LaborDB -constexpr int WORK_VERSION = 1; +#define WORK_VERSION 1 class WorkDB { diff --git a/main/business/sales.cc b/main/business/sales.cc index a69d2a8e..c2abd6da 100644 --- a/main/business/sales.cc +++ b/main/business/sales.cc @@ -33,7 +33,7 @@ #include #include -#include +#include #ifdef DMALLOC #include @@ -43,9 +43,9 @@ /**** Module Data ****/ const char* SalesGroupName[] = { GlobalTranslate("Unused"), GlobalTranslate("Food"), GlobalTranslate("Beverage"), GlobalTranslate("Beer"), GlobalTranslate("Wine"), GlobalTranslate("Alcohol"), - GlobalTranslate("Merchandise"), GlobalTranslate("Room"), nullptr}; + GlobalTranslate("Merchandise"), GlobalTranslate("Room"), NULL}; const char* SalesGroupShortName[] = { - "", GlobalTranslate("Food"), GlobalTranslate("Bev"), GlobalTranslate("Beer"), GlobalTranslate("Wine"), GlobalTranslate("Alcohol"), GlobalTranslate("Merchan"), GlobalTranslate("Room"), nullptr}; + "", GlobalTranslate("Food"), GlobalTranslate("Bev"), GlobalTranslate("Beer"), GlobalTranslate("Wine"), GlobalTranslate("Alcohol"), GlobalTranslate("Merchan"), GlobalTranslate("Room"), NULL}; int SalesGroupValue[] = { SALESGROUP_NONE, SALESGROUP_FOOD, SALESGROUP_BEVERAGE, SALESGROUP_BEER, SALESGROUP_WINE, SALESGROUP_ALCOHOL, @@ -56,8 +56,8 @@ int SalesGroupValue[] = { // Constructor Component::Component() { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; item_id = 0; } @@ -69,8 +69,8 @@ SalesItem::SalesItem(const char* name) if (name) item_name.Set(name); - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; id = 0; item_code.Set(""); @@ -110,7 +110,7 @@ int SalesItem::Copy(SalesItem *target) FnTrace("SalesItem::Copy()"); int retval = 1; - if (target != nullptr) + if (target != NULL) { target->item_name.Set(item_name); target->zone_name.Set(zone_name); @@ -347,9 +347,9 @@ int SalesItem::Price(Settings *s, int qualifier) if (qualifier & QUALIFIER_DOUBLE) { - const auto base = static_cast(c); - const auto multiplier = static_cast(s->double_mult); - const auto additive = static_cast(s->double_add); + const double base = static_cast(c); + const double multiplier = static_cast(s->double_mult); + const double additive = static_cast(s->double_add); const double adjusted = base * multiplier + additive; c = static_cast(std::lround(adjusted)); } @@ -391,8 +391,8 @@ const char* SalesItem::CallCenterName(Terminal *t) // Constructor GroupItem::GroupItem() { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; } // Member Functions @@ -412,7 +412,7 @@ ItemDB::ItemDB() { last_id = 0; changed = 0; - name_array = nullptr; + name_array = NULL; array_size = 0; merchandise_count = 0; merchandise_sales = 0; @@ -452,7 +452,7 @@ int ItemDB::Load(const char* file) for (int i = 0; i < items; ++i) { - auto *si = new SalesItem; + SalesItem *si = new SalesItem; si->Read(df, version); Add(si); } @@ -483,7 +483,7 @@ int ItemDB::Save() int error = 0; error += df.Write(ItemCount()); - for (SalesItem *si = ItemList(); si != nullptr; si = si->next) + for (SalesItem *si = ItemList(); si != NULL; si = si->next) { error += si->Write(df, SALES_ITEM_VERSION); si->changed = 0; @@ -502,13 +502,13 @@ int ItemDB::Save() int ItemDB::Add(SalesItem *si) { FnTrace("ItemDB::Add()"); - if (si == nullptr) + if (si == NULL) return 1; - if (name_array != nullptr) + if (name_array != NULL) { delete [] name_array; - name_array = nullptr; + name_array = NULL; array_size = 0; } @@ -534,13 +534,13 @@ int ItemDB::Add(SalesItem *si) int ItemDB::Remove(SalesItem *si) { FnTrace("ItemDB::Remove()"); - if (si == nullptr) + if (si == NULL) return 1; - if (name_array != nullptr) + if (name_array != NULL) { delete [] name_array; - name_array = nullptr; + name_array = NULL; array_size = 0; } return item_list.Remove(si); @@ -552,10 +552,10 @@ int ItemDB::Purge() item_list.Purge(); group_list.Purge(); - if (name_array != nullptr) + if (name_array != NULL) { delete [] name_array; - name_array = nullptr; + name_array = NULL; array_size = 0; } return 0; @@ -563,7 +563,7 @@ int ItemDB::Purge() int ItemDB::ResetAdmissionItems() { - for(SalesItem* si=ItemList();si!=nullptr;si=si->next) + for(SalesItem* si=ItemList();si!=NULL;si=si->next) { if(si->type == ITEM_ADMISSION) { @@ -576,7 +576,7 @@ int ItemDB::ResetAdmissionItems() SalesItem *ItemDB::FindByName(const std::string &name) { FnTrace("ItemDB::FindByName()"); - if (name_array == nullptr) + if (name_array == NULL) BuildNameArray(); // use binary search to find item @@ -595,37 +595,37 @@ SalesItem *ItemDB::FindByName(const std::string &name) else return mi; } - return nullptr; + return NULL; } SalesItem *ItemDB::FindByID(int id) { FnTrace("ItemDB::FindByID()"); if (id <= 0) - return nullptr; + return NULL; - for (SalesItem *si = ItemList(); si != nullptr; si = si->next) + for (SalesItem *si = ItemList(); si != NULL; si = si->next) if (si->id == id) return si; - return nullptr; + return NULL; } SalesItem *ItemDB::FindByRecord(int record) { FnTrace("ItemDB::FindByRecord()"); if (record < 0) - return nullptr; - if (name_array == nullptr) + return NULL; + if (name_array == NULL) BuildNameArray(); if (record >= array_size) - return nullptr; + return NULL; return name_array[record]; } SalesItem *ItemDB::FindByWord(const char* word, int &record) { FnTrace("ItemDB::FindByWord()"); - if (name_array == nullptr) + if (name_array == NULL) BuildNameArray(); int len = strlen(word); @@ -641,16 +641,16 @@ SalesItem *ItemDB::FindByWord(const char* word, int &record) } } record = 0; - return nullptr; + return NULL; } SalesItem *ItemDB::FindByCallCenterName(const char* word, int &record) { FnTrace("ItemDB::FindByCallCenterName()"); - if (name_array == nullptr) + if (name_array == NULL) BuildNameArray(); - SalesItem *retval = nullptr; - SalesItem *si = nullptr; + SalesItem *retval = NULL; + SalesItem *si = NULL; int len = strlen(word); int idx = 0; @@ -666,7 +666,7 @@ SalesItem *ItemDB::FindByCallCenterName(const char* word, int &record) } } - if (retval == nullptr) + if (retval == NULL) record = 0; return retval; @@ -675,10 +675,10 @@ SalesItem *ItemDB::FindByCallCenterName(const char* word, int &record) SalesItem *ItemDB::FindByItemCode(const char* code, int &record) { FnTrace("ItemDB::FindByItemCode()"); - if (name_array == nullptr) + if (name_array == NULL) BuildNameArray(); - SalesItem *retval = nullptr; - SalesItem *si = nullptr; + SalesItem *retval = NULL; + SalesItem *si = NULL; int idx = 0; for (idx = 0; idx < array_size; idx += 1) @@ -698,24 +698,24 @@ SalesItem *ItemDB::FindByItemCode(const char* code, int &record) int ItemDB::BuildNameArray() { FnTrace("ItemDB::BuildNameArray()"); - if (name_array != nullptr) + if (name_array != NULL) { delete [] name_array; - name_array = nullptr; + name_array = NULL; array_size = 0; } // Build search array array_size = ItemCount(); name_array = new(std::nothrow) SalesItem*[array_size + 1](); // zero-initialized - if (name_array == nullptr) + if (name_array == NULL) { array_size = 0; return 1; } int i = 0; - for (SalesItem *si = ItemList(); si != nullptr; si = si->next) + for (SalesItem *si = ItemList(); si != NULL; si = si->next) name_array[i++] = si; return 0; @@ -724,13 +724,13 @@ int ItemDB::BuildNameArray() int ItemDB::DeleteUnusedItems(ZoneDB *zone_db) { FnTrace("ItemDB::DeleteUnusedItems()"); - if (zone_db == nullptr) + if (zone_db == NULL) return 1; // crossreference items with touchzones - for (Page *p = zone_db->PageList(); p != nullptr; p = p->next) + for (Page *p = zone_db->PageList(); p != NULL; p = p->next) { - for (Zone *z = p->ZoneList(); z != nullptr; z = z->next) + for (Zone *z = p->ZoneList(); z != NULL; z = z->next) { SalesItem *si = z->Item(this); if (si) @@ -761,7 +761,7 @@ int ItemDB::ItemsInFamily(int family) int count = 0; SalesItem *item = ItemList(); - while (item != nullptr) + while (item != NULL) { if (item->family == family) count += 1; diff --git a/main/business/sales.hh b/main/business/sales.hh index f33380ba..a2c4bf49 100644 --- a/main/business/sales.hh +++ b/main/business/sales.hh @@ -18,8 +18,8 @@ * Definitions of sale item classes */ -#ifndef SALES_HH -#define SALES_HH +#ifndef _SALES_HH +#define _SALES_HH #include "utility.hh" #include "list_utility.hh" @@ -28,7 +28,7 @@ /**** Definitions ****/ -constexpr int SALES_ITEM_VERSION = 16; +#define SALES_ITEM_VERSION 16 // Family Difinitions #define FAMILY_APPETIZERS 0 @@ -201,7 +201,7 @@ public: int price_type; // price type (see above) // Constructor - SalesItem(const char* name = nullptr); + SalesItem(const char* name = NULL); // Member Functions Component *ComponentList() { return component_list.Head(); } diff --git a/main/business/tips.cc b/main/business/tips.cc index ec1d2ffe..53f71e7f 100644 --- a/main/business/tips.cc +++ b/main/business/tips.cc @@ -39,8 +39,8 @@ TipEntry::TipEntry() { FnTrace("TipEntry::TipEntry()"); - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; user_id = 0; amount = 0; previous_amount = 0; @@ -71,9 +71,9 @@ int TipEntry::Write(OutputDataFile &df, int version) TipEntry *TipEntry::Copy() { FnTrace("TipEntry::Copy()"); - auto *te = new TipEntry; - if (te == nullptr) - return nullptr; + TipEntry *te = new TipEntry; + if (te == NULL) + return NULL; te->user_id = user_id; te->amount = amount; @@ -85,7 +85,7 @@ int TipEntry::Count() { FnTrace("TipEntry::Count()"); int count = 1; - for (TipEntry *te = next; te != nullptr; te = te->next) + for (TipEntry *te = next; te != NULL; te = te->next) ++count; return count; } @@ -95,7 +95,7 @@ int TipEntry::Count() TipDB::TipDB() { FnTrace("TipDB::TipDB()"); - archive = nullptr; + archive = NULL; total_paid = 0; total_held = 0; total_previous = 0; @@ -105,7 +105,7 @@ TipDB::TipDB() int TipDB::Add(TipEntry *te) { FnTrace("TipDB::Add()"); - if (te == nullptr) + if (te == NULL) return 1; // search for previous entry for user @@ -144,30 +144,30 @@ int TipDB::Purge() TipEntry *TipDB::FindByUser(int id) { FnTrace("TipDB::FindByUser()"); - for (TipEntry *te = TipList(); te != nullptr; te = te->next) + for (TipEntry *te = TipList(); te != NULL; te = te->next) { if (te->user_id == id) return te; } - return nullptr; + return NULL; } TipEntry *TipDB::FindByRecord(int record, Employee *e) { FnTrace("TipDB::FindByRecord()"); if (record < 0) - return nullptr; + return NULL; - for (TipEntry *te = TipList(); te != nullptr; te = te->next) + for (TipEntry *te = TipList(); te != NULL; te = te->next) { - if (e == nullptr || te->user_id == e->id) + if (e == NULL || te->user_id == e->id) { if (record <= 0) return te; --record; } } - return nullptr; + return NULL; } int TipDB::CaptureTip(int user_id, int amount) @@ -222,7 +222,7 @@ int TipDB::PayoutTip(int user_id, int amount) { FnTrace("TipDB::PayoutTip()"); TipEntry *te = FindByUser(user_id); - if (te == nullptr || te->amount <= 0) + if (te == NULL || te->amount <= 0) return 1; // no captured tip to payout te->amount -= amount; @@ -247,9 +247,9 @@ int TipDB::Calculate(Settings *s, TipDB *previous, } // figure today's tips - for (Check *c = check_list; c != nullptr; c = c->next) + for (Check *c = check_list; c != NULL; c = c->next) { - for (SubCheck *sc = c->SubList(); sc != nullptr; sc = sc->next) + for (SubCheck *sc = c->SubList(); sc != NULL; sc = sc->next) { int tips = sc->TotalTip(); if (tips != 0) @@ -258,9 +258,9 @@ int TipDB::Calculate(Settings *s, TipDB *previous, } // subract amount paid out - for (Drawer *d = drawer_list; d != nullptr; d = d->next) + for (Drawer *d = drawer_list; d != NULL; d = d->next) { - for (DrawerPayment *dp = d->PaymentList(); dp != nullptr; dp = dp->next) + for (DrawerPayment *dp = d->PaymentList(); dp != NULL; dp = dp->next) { if (dp->tender_type == TENDER_PAID_TIP) PayoutTip(dp->target_id, dp->amount); @@ -275,7 +275,7 @@ int TipDB::Copy(TipDB *db) FnTrace("TipDB::Copy()"); Purge(); - for (TipEntry *te = db->TipList(); te != nullptr; te = te->next) + for (TipEntry *te = db->TipList(); te != NULL; te = te->next) Add(te->Copy()); return 0; } @@ -287,7 +287,7 @@ int TipDB::Total() total_held = 0; total_previous = 0; - for (TipEntry *te = TipList(); te != nullptr; te = te->next) + for (TipEntry *te = TipList(); te != NULL; te = te->next) { if (te->paid > 0) total_paid += te->paid; @@ -304,21 +304,21 @@ void TipDB::ClearHeld() FnTrace("TipDB::ClearHeld()"); total_held = 0; - for (TipEntry *te = TipList(); te != nullptr; te = te->next) + for (TipEntry *te = TipList(); te != NULL; te = te->next) te->amount = 0; } int TipDB::PaidReport(Terminal *t, Report *r) { FnTrace("TipDB::PaidReport()"); - if (r == nullptr) + if (r == NULL) return 1; r->TextC(GlobalTranslate("Tips Paid Report")); r->NewLine(2); int total = 0; - for (TipEntry *te = TipList(); te != nullptr; te = te->next) + for (TipEntry *te = TipList(); te != NULL; te = te->next) { if (te->paid > 0) { @@ -340,7 +340,7 @@ int TipDB::PaidReport(Terminal *t, Report *r) int TipDB::PayoutReceipt(Terminal *t, Employee *e, int amount, Report *r) { FnTrace("TipDB::PayoutReceipt()"); - if (r == nullptr || e == nullptr || amount <= 0) + if (r == NULL || e == NULL || amount <= 0) return 1; genericChar str[256]; @@ -366,14 +366,14 @@ int TipDB::PayoutReceipt(Terminal *t, Employee *e, int amount, Report *r) int TipDB::ListReport(Terminal *t, Employee *e, Report *r) { FnTrace("TipDB::ListReport()"); - if (r == nullptr || e == nullptr) + if (r == NULL || e == NULL) return 1; Settings *s = t->GetSettings(); int flag = e->IsSupervisor(s); int count = 0; - for (TipEntry *te = TipList(); te != nullptr; te = te->next) + for (TipEntry *te = TipList(); te != NULL; te = te->next) { if (te->user_id == e->id || flag) { @@ -415,6 +415,6 @@ int TipDB::Update(System *sys) Calculate(s, &a->tip_db, sys->CheckList(), sys->DrawerList()); } else - Calculate(s, nullptr, sys->CheckList(), sys->DrawerList()); + Calculate(s, NULL, sys->CheckList(), sys->DrawerList()); return 0; } diff --git a/main/business/tips.hh b/main/business/tips.hh index 4a0b62ed..9c9684de 100644 --- a/main/business/tips.hh +++ b/main/business/tips.hh @@ -18,15 +18,15 @@ * Handeling of captured tips and tip payout */ -#ifndef TIPS_HH -#define TIPS_HH +#ifndef _TIPS_HH +#define _TIPS_HH #include "utility.hh" #include "list_utility.hh" /**** Definitions ****/ -constexpr int TIP_VERSION = 1; +#define TIP_VERSION 1 /**** Types ****/ @@ -86,7 +86,7 @@ public: int Remove(TipEntry *te); int Purge(); TipEntry *FindByUser(int id); - TipEntry *FindByRecord(int record, Employee *e = nullptr); + TipEntry *FindByRecord(int record, Employee *e = NULL); int CaptureTip(int user_id, int amount); int TransferTip(int user_id, int amount); int PayoutTip(int user_id, int amount); diff --git a/main/data/admission.cc b/main/data/admission.cc index 0f3bca2c..2619a443 100644 --- a/main/data/admission.cc +++ b/main/data/admission.cc @@ -1,7 +1,7 @@ #include "admission.hh" #include -#include -#include +#include +#include #include "safe_string_utils.hh" @@ -51,7 +51,7 @@ void admission_parse_hash_ltime_hash(Str& hashout,const Str& ih) uint32_t val=0; if(zloc) { - val=strtoul(zloc+1,nullptr,16); + val=strtoul(zloc+1,NULL,16); } if(val!=0) { diff --git a/main/data/admission.hh b/main/data/admission.hh index d7630d3a..353d1716 100644 --- a/main/data/admission.hh +++ b/main/data/admission.hh @@ -1,5 +1,5 @@ -#ifndef ADMISSION_HH -#define ADMISSION_HH +#ifndef _ADMISSION_HH +#define _ADMISSION_HH #include "utility.hh" #include "sales.hh" diff --git a/main/data/archive.cc b/main/data/archive.cc index 4b1024ba..fe2cf16f 100644 --- a/main/data/archive.cc +++ b/main/data/archive.cc @@ -36,8 +36,8 @@ Archive::Archive(TimeInfo &end) { FnTrace("Archive::Archive(TimeInfo)"); - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; end_time = end; id = 0; loaded = 1; @@ -79,20 +79,20 @@ Archive::Archive(TimeInfo &end) discount_alcohol = 0; price_rounding = 0; - cc_exception_db = nullptr; - cc_refund_db = nullptr; - cc_void_db = nullptr; - cc_init_results = nullptr; - cc_saf_details_results = nullptr; - cc_settle_results = nullptr; + cc_exception_db = NULL; + cc_refund_db = NULL; + cc_void_db = NULL; + cc_init_results = NULL; + cc_saf_details_results = NULL; + cc_settle_results = NULL; } Archive::Archive(Settings *settings, const char* file) { FnTrace("Archive::Archive(Settings, const char* )"); filename.Set(file); - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; loaded = 0; changed = 0; id = 0; @@ -132,12 +132,12 @@ Archive::Archive(Settings *settings, const char* file) discount_alcohol = settings->discount_alcohol; price_rounding = settings->price_rounding; - cc_exception_db = nullptr; - cc_refund_db = nullptr; - cc_void_db = nullptr; - cc_init_results = nullptr; - cc_saf_details_results = nullptr; - cc_settle_results = nullptr; + cc_exception_db = NULL; + cc_refund_db = NULL; + cc_void_db = NULL; + cc_init_results = NULL; + cc_saf_details_results = NULL; + cc_settle_results = NULL; // Read in header of archive file_version = 0; @@ -145,19 +145,11 @@ Archive::Archive(Settings *settings, const char* file) if (df.Open(file, file_version)) return; - const int error = [file_version, &df, this]() { - int read_error = 0; - read_error += df.Read(id); - if (file_version >= 6) - read_error += df.Read(start_time); - read_error += df.Read(end_time); - return read_error; - }(); - - if (error != 0) - { - corrupt = 1; - } + int error = 0; + error += df.Read(id); + if (file_version >= 6) + error += df.Read(start_time); + error += df.Read(end_time); } // Member Functions @@ -269,7 +261,7 @@ int Archive::LoadPacked(Settings *settings, const char* file) ReportError("Unexpected end of Check data"); goto archive_read_error; } - auto *check = new Check; + Check *check = new Check; error = check->Read(settings, df, check_version); if (error) { @@ -297,7 +289,7 @@ int Archive::LoadPacked(Settings *settings, const char* file) ReportError("Unexpected end of TipDB"); goto archive_read_error; } - auto *te = new TipEntry; + TipEntry *te = new TipEntry; error = te->Read(df, tip_version); if (error) { @@ -350,7 +342,7 @@ int Archive::LoadPacked(Settings *settings, const char* file) { for (i = 0; i < count; i++) { - auto *discinfo = new DiscountInfo; + DiscountInfo *discinfo = new DiscountInfo; discinfo->Read(df, media_version); Add(discinfo); } @@ -363,7 +355,7 @@ int Archive::LoadPacked(Settings *settings, const char* file) { for (i = 0; i < count; i++) { - auto *coupinfo = new CouponInfo; + CouponInfo *coupinfo = new CouponInfo; coupinfo->Read(df, media_version); Add(coupinfo); } @@ -376,7 +368,7 @@ int Archive::LoadPacked(Settings *settings, const char* file) { for (i = 0; i < count; i++) { - auto *credinfo = new CreditCardInfo; + CreditCardInfo *credinfo = new CreditCardInfo; credinfo->Read(df, media_version); Add(credinfo); } @@ -389,7 +381,7 @@ int Archive::LoadPacked(Settings *settings, const char* file) { for (i = 0; i < count; i++) { - auto *compinfo = new CompInfo; + CompInfo *compinfo = new CompInfo; compinfo->Read(df, media_version); Add(compinfo); } @@ -402,7 +394,7 @@ int Archive::LoadPacked(Settings *settings, const char* file) { for (i = 0; i < count; i++) { - auto *mealinfo = new MealInfo; + MealInfo *mealinfo = new MealInfo; mealinfo->Read(df, media_version); Add(mealinfo); } @@ -469,7 +461,7 @@ int Archive::LoadPacked(Settings *settings, const char* file) df.Read(advertise_fund); // Initialize Data - for (drawer = DrawerList(); drawer != nullptr; drawer = drawer->next) + for (drawer = DrawerList(); drawer != NULL; drawer = drawer->next) { drawer->Total(CheckList()); } @@ -477,10 +469,10 @@ int Archive::LoadPacked(Settings *settings, const char* file) { Check *check = CheckList(); SubCheck *subcheck; - while (check != nullptr) + while (check != NULL) { subcheck = check->SubList(); - while (subcheck != nullptr) + while (subcheck != NULL) { subcheck->archive = this; subcheck->FigureTotals(settings); @@ -525,7 +517,7 @@ int Archive::LoadAlternateMedia() mf.Read(count); // using count for all media types for (i = 0; i < count; i++) { - auto *discinfo = new DiscountInfo; + DiscountInfo *discinfo = new DiscountInfo; discinfo->Read(mf, media_version); Add(discinfo); } @@ -533,7 +525,7 @@ int Archive::LoadAlternateMedia() mf.Read(count); // using count for all media types for (i = 0; i < count; i++) { - auto *coupinfo = new CouponInfo; + CouponInfo *coupinfo = new CouponInfo; coupinfo->Read(mf, media_version); Add(coupinfo); } @@ -541,7 +533,7 @@ int Archive::LoadAlternateMedia() mf.Read(count); // using count for all media types for (i = 0; i < count; i++) { - auto *credinfo = new CreditCardInfo; + CreditCardInfo *credinfo = new CreditCardInfo; credinfo->Read(mf, media_version); Add(credinfo); } @@ -549,7 +541,7 @@ int Archive::LoadAlternateMedia() mf.Read(count); // using count for all media types for (i = 0; i < count; i++) { - auto *compinfo = new CompInfo; + CompInfo *compinfo = new CompInfo; compinfo->Read(mf, media_version); Add(compinfo); } @@ -557,7 +549,7 @@ int Archive::LoadAlternateMedia() mf.Read(count); // using count for all media types for (i = 0; i < count; i++) { - auto *mealinfo = new MealInfo; + MealInfo *mealinfo = new MealInfo; mealinfo->Read(mf, media_version); Add(mealinfo); } @@ -696,7 +688,7 @@ int Archive::SavePacked() df.Write(media_version); df.Write(DiscountCount()); DiscountInfo *discount = DiscountList(); - while (discount != nullptr) + while (discount != NULL) { discount->Write(df, media_version); discount = discount->next; @@ -704,7 +696,7 @@ int Archive::SavePacked() df.Write(CouponCount()); CouponInfo *coupon = CouponList(); - while (coupon != nullptr) + while (coupon != NULL) { coupon->Write(df, media_version); coupon = coupon->next; @@ -712,7 +704,7 @@ int Archive::SavePacked() df.Write(CreditCardCount()); CreditCardInfo *creditcard = CreditCardList(); - while (creditcard != nullptr) + while (creditcard != NULL) { creditcard->Write(df, media_version); creditcard = creditcard->next; @@ -720,7 +712,7 @@ int Archive::SavePacked() df.Write(CompCount()); CompInfo *comp = CompList(); - while (comp != nullptr) + while (comp != NULL) { comp->Write(df, media_version); comp = comp->next; @@ -728,7 +720,7 @@ int Archive::SavePacked() df.Write(MealCount()); MealInfo *meal = MealList(); - while (meal != nullptr) + while (meal != NULL) { meal->Write(df, media_version); meal = meal->next; @@ -751,23 +743,23 @@ int Archive::SavePacked() df.Write(discount_alcohol); df.Write(tax_VAT); - if (cc_exception_db == nullptr) + if (cc_exception_db == NULL) cc_exception_db = new CreditDB(CC_DBTYPE_EXCEPT); cc_exception_db->Write(df); - if (cc_refund_db == nullptr) + if (cc_refund_db == NULL) cc_refund_db = new CreditDB(CC_DBTYPE_REFUND); cc_refund_db->Write(df); - if (cc_void_db == nullptr) + if (cc_void_db == NULL) cc_void_db = new CreditDB(CC_DBTYPE_VOID); cc_void_db->Write(df); - if (cc_init_results == nullptr) + if (cc_init_results == NULL) cc_init_results = new CCInit(); cc_init_results->Write(df); - if (cc_saf_details_results == nullptr) + if (cc_saf_details_results == NULL) cc_saf_details_results = new CCSAFDetails(); cc_saf_details_results->Write(df); - if (cc_settle_results == nullptr) + if (cc_settle_results == NULL) cc_settle_results = new CCSettle(); cc_settle_results->Write(df); @@ -801,22 +793,22 @@ int Archive::Unload() expense_db.Purge(); delete cc_exception_db; - cc_exception_db = nullptr; + cc_exception_db = NULL; delete cc_refund_db; - cc_refund_db = nullptr; + cc_refund_db = NULL; delete cc_void_db; - cc_void_db = nullptr; + cc_void_db = NULL; delete cc_init_results; - cc_init_results = nullptr; + cc_init_results = NULL; delete cc_saf_details_results; - cc_saf_details_results = nullptr; + cc_saf_details_results = NULL; delete cc_settle_results; - cc_settle_results = nullptr; + cc_settle_results = NULL; loaded = 0; return 0; @@ -825,7 +817,7 @@ int Archive::Unload() int Archive::Add(Check *c) { FnTrace("Archive::Add(Check)"); - if (loaded == 0 || c == nullptr || c->GetStatus() == CHECK_OPEN) + if (loaded == 0 || c == NULL || c->GetStatus() == CHECK_OPEN) return 1; // can't archive open check c->archive = this; @@ -840,10 +832,10 @@ int Archive::Add(Check *c) int Archive::Remove(Check *c) { FnTrace("Archive::Remove(Check)"); - if (c == nullptr || c->archive != this) + if (c == NULL || c->archive != this) return 1; - c->archive = nullptr; + c->archive = NULL; check_list.Remove(c); changed = 1; @@ -853,7 +845,7 @@ int Archive::Remove(Check *c) int Archive::Add(Drawer *drawer) { FnTrace("Archive::Add(Drawer)"); - if (drawer == nullptr || loaded == 0) + if (drawer == NULL || loaded == 0) return 1; drawer->archive = this; @@ -869,10 +861,10 @@ int Archive::Add(Drawer *drawer) int Archive::Remove(Drawer *drawer) { FnTrace("Archive::Remove(Drawer)"); - if (drawer == nullptr || drawer->archive != this) + if (drawer == NULL || drawer->archive != this) return 1; - drawer->archive = nullptr; + drawer->archive = NULL; drawer_list.Remove(drawer); changed = 1; @@ -882,7 +874,7 @@ int Archive::Remove(Drawer *drawer) int Archive::Add(WorkEntry *we) { FnTrace("Archive::Add(WorkEntry)"); - if (we == nullptr || loaded == 0) + if (we == NULL || loaded == 0) return 1; work_db.Add(we); @@ -899,7 +891,7 @@ int Archive::Remove(WorkEntry *we) int Archive::Add(DiscountInfo *discount) { FnTrace("Archive::Add(Discount)"); - if (discount == nullptr) + if (discount == NULL) return 1; return discount_list.AddToTail(discount); } @@ -907,7 +899,7 @@ int Archive::Add(DiscountInfo *discount) int Archive::Add(CouponInfo *coupon) { FnTrace("Archive::Add(Coupon)"); - if (coupon == nullptr) + if (coupon == NULL) return 1; return coupon_list.AddToTail(coupon); } @@ -915,7 +907,7 @@ int Archive::Add(CouponInfo *coupon) int Archive::Add(CreditCardInfo *creditcard) { FnTrace("Archive::Add(CreditCard)"); - if (creditcard == nullptr) + if (creditcard == NULL) return 1; return creditcard_list.AddToTail(creditcard); } @@ -923,7 +915,7 @@ int Archive::Add(CreditCardInfo *creditcard) int Archive::Add(CompInfo *comp) { FnTrace("Archive::Add(Comp)"); - if (comp == nullptr) + if (comp == NULL) return 1; return comp_list.AddToTail(comp); } @@ -931,7 +923,7 @@ int Archive::Add(CompInfo *comp) int Archive::Add(MealInfo *meal) { FnTrace("Archive::Add(Meal)"); - if (meal == nullptr) + if (meal == NULL) return 1; return meal_list.AddToTail(meal); } @@ -941,7 +933,7 @@ int Archive::DiscountCount() FnTrace("Archive::DiscountCount()"); int count = 0; DiscountInfo *discount = DiscountList(); - while (discount != nullptr) + while (discount != NULL) { count += 1; discount = discount->next; @@ -954,7 +946,7 @@ int Archive::CouponCount() FnTrace("Archive::CouponCount()"); int count = 0; CouponInfo *coupon = CouponList(); - while (coupon != nullptr) + while (coupon != NULL) { count += 1; coupon = coupon->next; @@ -967,7 +959,7 @@ int Archive::CreditCardCount() FnTrace("Archive::CreditCardCount()"); int count = 0; CreditCardInfo *creditcard = CreditCardList(); - while (creditcard != nullptr) + while (creditcard != NULL) { count += 1; creditcard = creditcard->next; @@ -980,7 +972,7 @@ int Archive::CompCount() FnTrace("Archive::CompCount()"); int count = 0; CompInfo *comp = CompList(); - while (comp != nullptr) + while (comp != NULL) { count += 1; comp = comp->next; @@ -993,7 +985,7 @@ int Archive::MealCount() FnTrace("Archive::MealCount()"); int count = 0; MealInfo *meal = MealList(); - while (meal != nullptr) + while (meal != NULL) { count += 1; meal = meal->next; @@ -1004,54 +996,54 @@ int Archive::MealCount() DiscountInfo *Archive::FindDiscountByID(int discount_id) { FnTrace("Archive::FindDiscountByID()"); - for (DiscountInfo *ds = discount_list.Head(); ds != nullptr; ds = ds->next) + for (DiscountInfo *ds = discount_list.Head(); ds != NULL; ds = ds->next) { if (ds->id == discount_id) return ds; } - return nullptr; + return NULL; } CouponInfo *Archive::FindCouponByID(int coupon_id) { FnTrace("Archive::FindCouponByID()"); - for (CouponInfo *cp = coupon_list.Head(); cp != nullptr; cp = cp->next) + for (CouponInfo *cp = coupon_list.Head(); cp != NULL; cp = cp->next) { if (cp->id == coupon_id) return cp; } - return nullptr; + return NULL; } CompInfo *Archive::FindCompByID(int comp_id) { FnTrace("Archive::FindCompByID()"); - for (CompInfo *cm = comp_list.Head(); cm != nullptr; cm = cm->next) + for (CompInfo *cm = comp_list.Head(); cm != NULL; cm = cm->next) { if (cm->id == comp_id) return cm; } - return nullptr; + return NULL; } CreditCardInfo *Archive::FindCreditCardByID(int creditcard_id) { FnTrace("Archive::FindCreditCardByID()"); - for (CreditCardInfo *cc = creditcard_list.Head(); cc != nullptr; cc = cc->next) + for (CreditCardInfo *cc = creditcard_list.Head(); cc != NULL; cc = cc->next) { if (cc->id == creditcard_id) return cc; } - return nullptr; + return NULL; } MealInfo *Archive::FindMealByID(int meal_id) { FnTrace("Archive::FindMealByID()"); - for (MealInfo *mi = meal_list.Head(); mi != nullptr; mi = mi->next) + for (MealInfo *mi = meal_list.Head(); mi != NULL; mi = mi->next) { if (mi->id == meal_id) return mi; } - return nullptr; + return NULL; } diff --git a/main/data/archive.hh b/main/data/archive.hh index 88624dad..4e2bfd7f 100644 --- a/main/data/archive.hh +++ b/main/data/archive.hh @@ -18,8 +18,8 @@ * Data storage past business days */ -#ifndef ARCHIVE_HH -#define ARCHIVE_HH +#ifndef _ARCHIVE_HH +#define _ARCHIVE_HH #include "tips.hh" #include "labor.hh" @@ -124,7 +124,7 @@ public: CompInfo *CompList() { return comp_list.Head(); } MealInfo *MealList() { return meal_list.Head(); } - int LoadPacked(Settings *s, const genericChar* filename = nullptr); + int LoadPacked(Settings *s, const genericChar* filename = NULL); // Loads archive from single file int LoadUnpacked(Settings *s, const genericChar* path); // Loads archive from files in directory (usually 'current' directory) diff --git a/main/data/credit.cc b/main/data/credit.cc index 42f8a470..9b826678 100644 --- a/main/data/credit.cc +++ b/main/data/credit.cc @@ -34,8 +34,8 @@ #include "safe_string_utils.hh" #include #include -#include -#include +#include +#include #ifdef DMALLOC #include @@ -69,27 +69,27 @@ /**** Exported Varibles ****/ const char* CardTypeName[] = { - "Credit Card", "Debit Card", "Gift Card", nullptr}; + "Credit Card", "Debit Card", "Gift Card", NULL}; const char* CardTypeShortName[] = { - "Credit", "Debit", "Gift", nullptr}; + "Credit", "Debit", "Gift", NULL}; int CardTypeValue[] = { CARD_TYPE_CREDIT, CARD_TYPE_DEBIT, CARD_TYPE_GIFT, -1}; const char* CreditCardName[] = { "Visa", "MasterCard", "American Express", "Discover Card", "Diners Club", - "JCB Card", nullptr}; + "JCB Card", NULL}; const char* CreditCardShortName[] = { - "Visa", "MC", "AMEX", "Discover", "Diners", "JCB", nullptr}; + "Visa", "MC", "AMEX", "Discover", "Diners", "JCB", NULL}; int CreditCardValue[] = { CREDIT_TYPE_VISA, CREDIT_TYPE_MASTERCARD, CREDIT_TYPE_AMEX, CREDIT_TYPE_DISCOVER, CREDIT_TYPE_DINERSCLUB, CREDIT_TYPE_JCB, -1}; const char* DebitAcctName[] = { - "Checking", "Savings", nullptr}; + "Checking", "Savings", NULL}; int DebitAcctValue[] = { DEBIT_ACCT_CHECKING, DEBIT_ACCT_SAVINGS, -1}; const char* CreditCardStateName[] = { "Pre-Authorized", "Authorized", "Pre-Auth Completed", "Voided", "Refunded", - "Refund Cancelled", "Pre-Auth Adviced", nullptr }; + "Refund Cancelled", "Pre-Auth Adviced", NULL }; int CreditCardStateValue[] = { CCAUTH_PREAUTH, CCAUTH_AUTHORIZE, CCAUTH_COMPLETE, CCAUTH_VOID, CCAUTH_REFUND, CCAUTH_REFUND_CANCEL, CCAUTH_ADVICE, -1 }; @@ -103,8 +103,8 @@ Credit::Credit() { FnTrace("Credit::Credit()"); - fore = nullptr; - next = nullptr; + fore = NULL; + next = NULL; Clear(); } @@ -113,12 +113,12 @@ Credit::Credit(const char* value) { FnTrace("Credit::Credit(const char* )"); - fore = nullptr; - next = nullptr; + fore = NULL; + next = NULL; Clear(); - if (value != nullptr) + if (value != NULL) { swipe.Set(value); valid = ParseSwipe(value); @@ -414,7 +414,7 @@ int Credit::Write(OutputDataFile &df, int version) error += df.Write(settle_time); error += df.Write(errors_list.Count()); - while (ecredit != nullptr) + while (ecredit != NULL) { ecredit->Write(df, version); ecredit = ecredit->next; @@ -447,10 +447,10 @@ int Credit::AddError(Credit *ecredit) Credit *Credit::Copy() { FnTrace("Credit::Copy()"); - auto *newcredit = new Credit(); + Credit *newcredit = new Credit(); Credit *ecredit; - if (newcredit != nullptr) + if (newcredit != NULL) { newcredit->card_id = card_id; newcredit->db_type = db_type; @@ -516,7 +516,7 @@ Credit *Credit::Copy() newcredit->read_manual = read_manual; ecredit = errors_list.Head(); - while (ecredit != nullptr) + while (ecredit != NULL) { newcredit->AddError(ecredit); ecredit = ecredit->next; @@ -535,7 +535,7 @@ int Credit::Copy(Credit *credit) Credit *ecredit; int retval = 1; - if (credit != nullptr) + if (credit != NULL) { card_id = credit->card_id; db_type = credit->db_type; @@ -599,7 +599,7 @@ int Credit::Copy(Credit *credit) read_manual = credit->read_manual; ecredit = credit->errors_list.Head(); - while (ecredit != nullptr) + while (ecredit != NULL) { AddError(ecredit); ecredit = ecredit->next; @@ -1204,7 +1204,7 @@ int Credit::ParseSwipe(const char* value) int Credit::ParseApproval(const char* value) { FnTrace("Credit::ParseApproval()"); - if (value == nullptr) + if (value == NULL) return 1; char str[256]; @@ -1283,9 +1283,9 @@ char* Credit::CreditTypeName(char* str, int shortname) { FnTrace("Credit::CreditTypeName()"); static char buffer[32]; - const char* hold = nullptr; + const char* hold = NULL; - if (str == nullptr) + if (str == NULL) str = buffer; vt_safe_string::safe_copy(str, 32, UnknownStr); @@ -1312,7 +1312,7 @@ char* Credit::CreditTypeName(char* str, int shortname) } } - if (hold != nullptr) + if (hold != NULL) vt_safe_string::safe_copy(str, 32, hold); return str; @@ -1692,7 +1692,7 @@ char* Credit::LastFour(char* dest) int sidx = 0; int didx = 0; int len = 0; - if (dest == nullptr) + if (dest == NULL) dest = str; if (number.size() > 0) @@ -1742,7 +1742,7 @@ const char* Credit::Name() int idx; vt_safe_string::safe_copy(buffer, STRLENGTH, name.Value()); - if (strlen(buffer) > 0 && strcmp(buffer, " /") != 0) + if (strlen(buffer) > 0 && strcmp(buffer, " /")) { bidx = 0; @@ -1838,7 +1838,7 @@ int Credit::MaskCardNumber() { FnTrace("Credit::MaskCardNumber()"); int retval = 0; - const char* cardnum = nullptr; + const char* cardnum = NULL; cardnum = PAN(0); number.Set(cardnum); @@ -1904,7 +1904,7 @@ int Credit::SetBatch(long long batchnum, const char* btermid) FnTrace("Credit::SetBatch()"); int retval = 1; - if (btermid != nullptr) + if (btermid != NULL) { if (batch <= 0 && strcmp(batch_term_id.Value(), btermid) == 0) { @@ -1972,7 +1972,7 @@ int Credit::GetApproval(Terminal *term) FnTrace("Credit::GetApproval()"); int retval = 1; - if (term->credit != nullptr && term->credit != this) + if (term->credit != NULL && term->credit != this) { if (debug_mode) printf("Have stale card in GetApproval...\n"); } @@ -1988,7 +1988,7 @@ int Credit::GetPreApproval(Terminal *term) FnTrace("Credit::GetPreApproval()"); int retval = 1; - if (term->credit != nullptr && term->credit != this) + if (term->credit != NULL && term->credit != this) { if (debug_mode) printf("Have stale card in GetPreApproval...\n"); } @@ -2004,7 +2004,7 @@ int Credit::GetFinalApproval(Terminal *term) FnTrace("Credit::GetFinalApproval()"); int retval = 1; - if (term->credit != nullptr && term->credit != this) + if (term->credit != NULL && term->credit != this) { if (debug_mode) printf("Have stale card in GetFinalApproval...\n"); } @@ -2020,7 +2020,7 @@ int Credit::GetVoid(Terminal *term) FnTrace("Credit::GetVoid()"); int retval = 1; - if (term->credit != nullptr && term->credit != this) + if (term->credit != NULL && term->credit != this) { if (debug_mode) printf("Have stale card in GetVoid...\n"); } @@ -2036,7 +2036,7 @@ int Credit::GetVoidCancel(Terminal *term) FnTrace("Credit::GetVoidCancel()"); int retval = 1; - if (term->credit != nullptr && term->credit != this) + if (term->credit != NULL && term->credit != this) { if (debug_mode) printf("Have stale card in GetVoidCancel...\n"); } @@ -2052,7 +2052,7 @@ int Credit::GetRefund(Terminal *term) FnTrace("Credit::GetRefund()"); int retval = 1; - if (term->credit != nullptr && term->credit != this) + if (term->credit != NULL && term->credit != this) { if (debug_mode) printf("Have stale card in GetRefund...\n"); } @@ -2068,7 +2068,7 @@ int Credit::GetRefundCancel(Terminal *term) FnTrace("Credit::GetRefundCancel()"); int retval = 1; - if (term->credit != nullptr && term->credit != this) + if (term->credit != NULL && term->credit != this) { if (debug_mode) printf("Have stale card in GetRefundCancel...\n"); } @@ -2103,9 +2103,9 @@ int Credit::ReceiptPrint(Terminal *term, int receipt_type, Printer *pprinter, in static int count = 0; // for saving receipts for Moneris testing Check *parent = term->system_data->FindCheckByID(check_id); - if (printer == nullptr) + if (printer == NULL) printer = term->FindPrinter(PRINTER_RECEIPT); - if (printer != nullptr) + if (printer != NULL) { pwidth = printer->MaxWidth(); snprintf(line, STRLENGTH, "%*s", pwidth, "________________"); @@ -2189,7 +2189,7 @@ int Credit::ReceiptPrint(Terminal *term, int receipt_type, Printer *pprinter, in // card and date information if (settings->cc_print_custinfo) { - if (parent != nullptr) + if (parent != NULL) { int did_print = 0; vt_safe_string::safe_copy(buffer2, STRLENGTH, parent->FullName()); @@ -2370,15 +2370,15 @@ CreditDB *CreditDB::Copy() FnTrace("CreditDB::Copy()"); CreditDB *newdb; Credit *credit = credit_list.Head(); - Credit *crednext = nullptr; + Credit *crednext = NULL; newdb = new CreditDB(db_type); - if (newdb != nullptr) + if (newdb != NULL) { vt_safe_string::safe_copy(newdb->fullpath, STRLONG, fullpath); newdb->last_card_id = last_card_id; - while (credit != nullptr) + while (credit != NULL) { crednext = credit->next; newdb->credit_list.AddToTail(credit); @@ -2422,7 +2422,7 @@ int CreditDB::Write(OutputDataFile &outfile) outfile.Write(CREDIT_CARD_VERSION); outfile.Write(count); - while (credit != nullptr) + while (credit != NULL) { if (credit->IsEmpty() == 0) credit->Write(outfile, CREDIT_CARD_VERSION); @@ -2465,7 +2465,7 @@ int CreditDB::Load(const char* path) int version; // a throwaway for infile; we save version manually so that // Read() and Write() don't have to wonder. - if (path != nullptr) + if (path != NULL) vt_safe_string::safe_copy(fullpath, STRLONG, path); if (fullpath[0] != '\0') @@ -2487,7 +2487,7 @@ int CreditDB::Add(Credit *credit) FnTrace("CreditDB::Add(Credit)"); int retval = 0; - if (credit != nullptr) + if (credit != NULL) { if (credit->card_id == 0) { @@ -2551,10 +2551,10 @@ int CreditDB::Remove(int id) int retval = 0; Credit *credit = credit_list.Head(); - while (credit != nullptr && credit->card_id != id) + while (credit != NULL && credit->card_id != id) credit = credit->next; - if (credit != nullptr && credit->card_id == id) + if (credit != NULL && credit->card_id == id) { credit_list.Remove(credit); } @@ -2566,7 +2566,7 @@ int CreditDB::MakeReport(Terminal *term, Report *report, LayoutZone *rzone) { FnTrace("CreditDB::MakeReport()"); int retval = 0; - Credit *credit = nullptr; + Credit *credit = NULL; int color = COLOR_DEFAULT; int spacing = rzone->ColumnSpacing(term, 4); int indent = 0; @@ -2580,7 +2580,7 @@ int CreditDB::MakeReport(Terminal *term, Report *report, LayoutZone *rzone) else { credit = credit_list.Head(); - while (credit != nullptr) + while (credit != NULL) { indent = 0; report->TextPosL(indent, credit->PAN(settings->show_entire_cc_num)); @@ -2605,12 +2605,12 @@ int CreditDB::MakeReport(Terminal *term, Report *report, LayoutZone *rzone) Credit *CreditDB::FindByRecord(Terminal *term, int record) { FnTrace("CreditDB::FindByRecord()"); - Credit *retval = nullptr; + Credit *retval = NULL; Credit *curr = credit_list.Head(); int count = 0; int done = 0; - while (curr != nullptr && done == 0) + while (curr != NULL && done == 0) { if (count == record) { @@ -2634,7 +2634,7 @@ int CreditDB::HaveOpenCards() int retval = 0; Credit *curr = credit_list.Head(); - while (curr != nullptr && retval == 0) + while (curr != NULL && retval == 0) { if (curr->GetStatus() != CCAUTH_VOID && curr->GetStatus() != CCAUTH_REFUND) retval = 1; @@ -2673,7 +2673,7 @@ CCBInfo::CCBInfo(const char* newname, int settype) FnTrace("CCBInfo::CCBInfo(const char* )"); name.Set(newname); - type = settype; // assign provided type to member + settype = type; Clear(); } @@ -2851,11 +2851,11 @@ CCSettle::CCSettle() { FnTrace("CCSettle::CCSettle()"); - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; filepath[0] = '\0'; - current = nullptr; - archive = nullptr; + current = NULL; + archive = NULL; Clear(); } @@ -2863,18 +2863,18 @@ CCSettle::CCSettle(const char* fullpath) { FnTrace("CCSettle::CCSettle()"); - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; vt_safe_string::safe_copy(filepath, STRLONG, fullpath); - current = nullptr; - archive = nullptr; + current = NULL; + archive = NULL; Clear(); } CCSettle::~CCSettle() { FnTrace("CCSettle::~CCSettle()"); - if (next != nullptr) + if (next != NULL) delete next; } @@ -2885,7 +2885,7 @@ int CCSettle::Next(Terminal *term) int loops = 0; Settings *settings = term->GetSettings(); - if (current == nullptr) + if (current == NULL) { current = this; } @@ -2896,11 +2896,11 @@ int CCSettle::Next(Terminal *term) // avoid grabbing NULLs. while (loops < MAX_LOOPS) { - if (current != nullptr && current->next != nullptr) + if (current != NULL && current->next != NULL) current = current->next; else { // search archives - if (archive == nullptr) + if (archive == NULL) { archive = MasterSystem->ArchiveList(); if (archive && archive->loaded == 0) @@ -2913,15 +2913,15 @@ int CCSettle::Next(Terminal *term) archive = archive->next; if (archive && archive->loaded == 0) archive->LoadPacked(settings); - } while (archive != nullptr && archive->cc_settle_results == nullptr); + } while (archive != NULL && archive->cc_settle_results == NULL); } - if (archive != nullptr) + if (archive != NULL) current = archive->cc_settle_results; else current = this; } - loops += ((current != nullptr) ? MAX_LOOPS : 1); + loops += ((current != NULL) ? MAX_LOOPS : 1); } } @@ -2935,7 +2935,7 @@ int CCSettle::Fore(Terminal *term) int loops = 0; Settings *settings = term->GetSettings(); - if (current == nullptr) + if (current == NULL) { current = this; } @@ -2946,11 +2946,11 @@ int CCSettle::Fore(Terminal *term) // avoid grabbing NULLs. while (loops < MAX_LOOPS) { - if (current != nullptr && current->fore != nullptr) + if (current != NULL && current->fore != NULL) current = current->fore; else { // search archives - if (archive == nullptr) + if (archive == NULL) { archive = MasterSystem->ArchiveListEnd(); if (archive && archive->loaded == 0) @@ -2963,18 +2963,18 @@ int CCSettle::Fore(Terminal *term) archive = archive->fore; if (archive && archive->loaded == 0) archive->LoadPacked(settings); - } while (archive != nullptr && archive->cc_settle_results == nullptr); + } while (archive != NULL && archive->cc_settle_results == NULL); } - if (archive != nullptr) + if (archive != NULL) current = archive->cc_settle_results; else current = this; - while (current!= nullptr && current->next != nullptr) + while (current!= NULL && current->next != NULL) current = current->next; } - loops += ((current != nullptr) ? MAX_LOOPS : 1); + loops += ((current != NULL) ? MAX_LOOPS : 1); } } @@ -2986,7 +2986,7 @@ CCSettle *CCSettle::Last() FnTrace("CCSettle:Last()"); CCSettle *retval = this; - while (retval->next != nullptr) + while (retval->next != NULL) retval = retval->next; return retval; @@ -2996,12 +2996,12 @@ int CCSettle::Add(Terminal *term, const char* message) { FnTrace("CCSettle::Add(Terminal)"); int retval = 0; - CCSettle *newsettle = nullptr; - CCSettle *curr = nullptr; + CCSettle *newsettle = NULL; + CCSettle *curr = NULL; if (result.empty()) { - if (message != nullptr) + if (message != NULL) { result.Set("Batch Settle Failed"); errormsg.Set(message); @@ -3013,7 +3013,7 @@ int CCSettle::Add(Terminal *term, const char* message) else { newsettle = new CCSettle(); - if (message != nullptr) + if (message != NULL) { newsettle->result.Set("Batch Settle Failed"); newsettle->errormsg.Set(message); @@ -3022,7 +3022,7 @@ int CCSettle::Add(Terminal *term, const char* message) newsettle->ReadResults(term); // Add to tail curr = this; - while (curr->next != nullptr) + while (curr->next != NULL) curr = curr->next; curr->next = newsettle; newsettle->fore = curr; @@ -3041,15 +3041,15 @@ int CCSettle::Add(Check *check) FnTrace("CCSettle::Add(Check)"); int retval = 1; SubCheck *subcheck = check->SubList(); - Payment *payment = nullptr; - Credit *credit = nullptr; + Payment *payment = NULL; + Credit *credit = NULL; - while (subcheck != nullptr) + while (subcheck != NULL) { payment = subcheck->PaymentList(); - while (payment != nullptr) + while (payment != NULL) { - if (payment->credit != nullptr) + if (payment->credit != NULL) { credit = payment->credit; if (credit->CardType() == CARD_TYPE_DEBIT) @@ -3095,7 +3095,7 @@ int CCSettle::Add(Check *check) CCSettle *CCSettle::Copy() { FnTrace("CCSettle::Copy()"); - auto *newsettle = new CCSettle(); + CCSettle *newsettle = new CCSettle(); newsettle->result.Set(result); newsettle->settle.Set(settle); @@ -3125,7 +3125,7 @@ CCSettle *CCSettle::Copy() newsettle->settle_date.Set(settle_date); - if (next != nullptr) + if (next != NULL) newsettle->next = next->Copy(); return newsettle; @@ -3135,9 +3135,9 @@ void CCSettle::Clear() { FnTrace("CCSettle::Clear()"); - if (next != nullptr) + if (next != NULL) delete next; - next = nullptr; + next = NULL; result.Clear(); settle.Clear(); @@ -3179,7 +3179,7 @@ int CCSettle::Read(InputDataFile &df) int count = 0; int idx = 0; CCSettle *curr = this; - CCSettle *node = nullptr; + CCSettle *node = NULL; int version = 0; df.Read(version); @@ -3234,10 +3234,10 @@ int CCSettle::Write(OutputDataFile &df) int count = 0; int version = CREDIT_CARD_VERSION; - while (head->fore != nullptr) + while (head->fore != NULL) head = head->fore; curr = head; - while (curr != nullptr) + while (curr != NULL) { count += 1; curr = curr->next; @@ -3246,7 +3246,7 @@ int CCSettle::Write(OutputDataFile &df) df.Write(version); df.Write(count); curr = head; - while (curr != nullptr) + while (curr != NULL) { df.Write(curr->result); df.Write(curr->settle); @@ -3287,7 +3287,7 @@ int CCSettle::Load(const char* filename) InputDataFile infile; int version = 0; - if (filename != nullptr && strlen(filename) > 0) + if (filename != NULL && strlen(filename) > 0) { vt_safe_string::safe_copy(filepath, STRLONG, filename); @@ -3470,15 +3470,15 @@ int CCSettle::MakeReport(Terminal *term, Report *report, ReportZone *rzone) FnTrace("CCSettle::MakeReport()"); int retval = 1; - if (current == nullptr) + if (current == NULL) { // Go to the last CCSettle in the linked list current = this; - while (current->next != nullptr) + while (current->next != NULL) current = current->next; } - if (current != nullptr) + if (current != NULL) { current->GenerateReport(term, report, rzone, archive); retval = 0; @@ -3529,10 +3529,10 @@ CCInit::CCInit() FnTrace("CCInit::CCInit()"); filepath[0] = '\0'; - next = nullptr; - fore = nullptr; - current = nullptr; - archive = nullptr; + next = NULL; + fore = NULL; + current = NULL; + archive = NULL; } CCInit::CCInit(const char* fullpath) @@ -3540,17 +3540,17 @@ CCInit::CCInit(const char* fullpath) FnTrace("CCInit::CCInit()"); vt_safe_string::safe_copy(filepath, STRLONG, fullpath); - next = nullptr; - fore = nullptr; - current = nullptr; - archive = nullptr; + next = NULL; + fore = NULL; + current = NULL; + archive = NULL; } CCInit::~CCInit() { FnTrace("CCInit::~CCInit()"); - if (next != nullptr) + if (next != NULL) delete next; } @@ -3561,7 +3561,7 @@ int CCInit::Next(Terminal *term) int loops = 0; Settings *settings = term->GetSettings(); - if (current == nullptr) + if (current == NULL) { current = this; } @@ -3572,11 +3572,11 @@ int CCInit::Next(Terminal *term) // avoid grabbing NULLs. while (loops < MAX_LOOPS) { - if (current != nullptr && current->next != nullptr) + if (current != NULL && current->next != NULL) current = current->next; else { // search archives - if (archive == nullptr) + if (archive == NULL) { archive = MasterSystem->ArchiveList(); if (archive && archive->loaded == 0) @@ -3589,15 +3589,15 @@ int CCInit::Next(Terminal *term) archive = archive->next; if (archive && archive->loaded == 0) archive->LoadPacked(settings); - } while (archive != nullptr && archive->cc_init_results == nullptr); + } while (archive != NULL && archive->cc_init_results == NULL); } - if (archive != nullptr) + if (archive != NULL) current = archive->cc_init_results; else current = this; } - loops += ((current != nullptr) ? MAX_LOOPS : 1); + loops += ((current != NULL) ? MAX_LOOPS : 1); } } @@ -3611,7 +3611,7 @@ int CCInit::Fore(Terminal *term) int loops = 0; Settings *settings = term->GetSettings(); - if (current == nullptr) + if (current == NULL) { current = this; } @@ -3622,11 +3622,11 @@ int CCInit::Fore(Terminal *term) // avoid grabbing NULLs. while (loops < MAX_LOOPS) { - if (current != nullptr && current->fore != nullptr) + if (current != NULL && current->fore != NULL) current = current->fore; else { // search archives - if (archive == nullptr) + if (archive == NULL) { archive = MasterSystem->ArchiveListEnd(); if (archive && archive->loaded == 0) @@ -3639,19 +3639,19 @@ int CCInit::Fore(Terminal *term) archive = archive->fore; if (archive && archive->loaded == 0) archive->LoadPacked(settings); - } while (archive != nullptr && archive->cc_init_results == nullptr); + } while (archive != NULL && archive->cc_init_results == NULL); } - if (archive != nullptr) + if (archive != NULL) current = archive->cc_init_results; else { current = this; - while (current->next != nullptr) + while (current->next != NULL) current = current->next; } } - loops += ((current != nullptr) ? MAX_LOOPS : 1); + loops += ((current != NULL) ? MAX_LOOPS : 1); } } @@ -3690,7 +3690,7 @@ int CCInit::Write(OutputDataFile &df) df.Write(version); df.Write(count); - while (currstr != nullptr) + while (currstr != NULL) { df.Write(currstr); currstr = currstr->next; @@ -3706,7 +3706,7 @@ int CCInit::Load(const char* filename) InputDataFile infile; int version = 0; - if (filename != nullptr) + if (filename != NULL) { vt_safe_string::safe_copy(filepath, STRLONG, filename); if (infile.Open(filepath, version) == 0) @@ -3759,14 +3759,14 @@ int CCInit::MakeReport(Terminal *term, Report *report, ReportZone *rzone) FnTrace("CCInit::MakeReport()"); int retval = 0; - if (current == nullptr) + if (current == NULL) { current = this; - while (current->next != nullptr) + while (current->next != NULL) current = current->next; } - if (current != nullptr) + if (current != NULL) { current->GenerateReport(term, report, rzone); retval = 0; @@ -3781,7 +3781,7 @@ int CCInit::GenerateReport(Terminal *term, Report *report, ReportZone *rzone) int retval = 0; Str *currstr = init_list.Head(); - while (currstr != nullptr) + while (currstr != NULL) { report->TextL(currstr->Value(), COLOR_DEFAULT); report->NewLine(); @@ -3802,15 +3802,15 @@ int CCInit::GenerateReport(Terminal *term, Report *report, ReportZone *rzone) CCDetails::CCDetails() { FnTrace("CCDetails::CCDetails()"); - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; } CCDetails::~CCDetails() { FnTrace("CCDetails::~CCDetails()"); - if (next != nullptr) + if (next != NULL) delete next; } @@ -3861,16 +3861,16 @@ int CCDetails::MakeReport(Terminal *term, Report *report, ReportZone *rzone) { FnTrace("CCDetails::MakeReport()"); int retval = 0; - Str *currstr = nullptr; + Str *currstr = NULL; if (MasterSystem->settings.authorize_method == CCAUTH_MAINSTREET && - report != nullptr) + report != NULL) { currstr = mcve_list.Head(); report->Mode(0); report->NewLine(); - while (currstr != nullptr) + while (currstr != NULL) { report->TextL(currstr->Value()); report->NewLine(); @@ -3890,10 +3890,10 @@ CCSAFDetails::CCSAFDetails() FnTrace("CCSAFDetails::CCSAFDetails()"); filepath[0] = '\0'; - next = nullptr; - fore = nullptr; - current = nullptr; - archive = nullptr; + next = NULL; + fore = NULL; + current = NULL; + archive = NULL; Clear(); } @@ -3902,10 +3902,10 @@ CCSAFDetails::CCSAFDetails(const char* fullpath) FnTrace("CCSAFDetails::CCSAFDetails()"); vt_safe_string::safe_copy(filepath, STRLONG, fullpath); - next = nullptr; - fore = nullptr; - current = nullptr; - archive = nullptr; + next = NULL; + fore = NULL; + current = NULL; + archive = NULL; Clear(); } @@ -3913,7 +3913,7 @@ CCSAFDetails::~CCSAFDetails() { FnTrace("CCSAFDetails::~CCSAFDetails()"); - if (next != nullptr) + if (next != NULL) delete next; } @@ -3938,10 +3938,10 @@ void CCSAFDetails::Clear() expired = 0; last = 0; - if (next != nullptr) + if (next != NULL) delete next; - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; } int CCSAFDetails::Next(Terminal *term) @@ -3951,7 +3951,7 @@ int CCSAFDetails::Next(Terminal *term) int loops = 0; Settings *settings = term->GetSettings(); - if (current == nullptr) + if (current == NULL) { current = this; } @@ -3962,11 +3962,11 @@ int CCSAFDetails::Next(Terminal *term) // avoid grabbing NULLs. while (loops < MAX_LOOPS) { - if (current != nullptr && current->next != nullptr) + if (current != NULL && current->next != NULL) current = current->next; else { // search archives - if (archive == nullptr) + if (archive == NULL) { archive = MasterSystem->ArchiveList(); if (archive && archive->loaded == 0) @@ -3979,15 +3979,15 @@ int CCSAFDetails::Next(Terminal *term) archive = archive->next; if (archive && archive->loaded == 0) archive->LoadPacked(settings); - } while (archive != nullptr && archive->cc_saf_details_results == nullptr); + } while (archive != NULL && archive->cc_saf_details_results == NULL); } - if (archive != nullptr) + if (archive != NULL) current = archive->cc_saf_details_results; else current = this; } - loops += ((current != nullptr) ? MAX_LOOPS : 1); + loops += ((current != NULL) ? MAX_LOOPS : 1); } } @@ -4001,7 +4001,7 @@ int CCSAFDetails::Fore(Terminal *term) int loops = 0; Settings *settings = term->GetSettings(); - if (current == nullptr) + if (current == NULL) { current = this; } @@ -4012,11 +4012,11 @@ int CCSAFDetails::Fore(Terminal *term) // avoid grabbing NULLs. while (loops < MAX_LOOPS) { - if (current != nullptr && current->fore != nullptr) + if (current != NULL && current->fore != NULL) current = current->fore; else { // search archives - if (archive == nullptr) + if (archive == NULL) { archive = MasterSystem->ArchiveListEnd(); if (archive && archive->loaded == 0) @@ -4029,19 +4029,19 @@ int CCSAFDetails::Fore(Terminal *term) archive = archive->fore; if (archive && archive->loaded == 0) archive->LoadPacked(settings); - } while (archive != nullptr && archive->cc_saf_details_results == nullptr); + } while (archive != NULL && archive->cc_saf_details_results == NULL); } - if (archive != nullptr) + if (archive != NULL) current = archive->cc_saf_details_results; else { current = this; - while (current->next != nullptr) + while (current->next != NULL) current = current->next; } } - loops += ((current != nullptr) ? MAX_LOOPS : 1); + loops += ((current != NULL) ? MAX_LOOPS : 1); } } @@ -4053,7 +4053,7 @@ CCSAFDetails *CCSAFDetails::Last() FnTrace("CCSAFDetails::Last()"); CCSAFDetails *retval = this; - while (retval->next != nullptr) + while (retval->next != NULL) retval = retval->next; return retval; @@ -4064,7 +4064,7 @@ int CCSAFDetails::Read(InputDataFile &df) FnTrace("CCSAFDetails::Read()"); int retval = 0; CCSAFDetails *curr = this; - CCSAFDetails *node = nullptr; + CCSAFDetails *node = NULL; int count = 0; int idx = 0; int version = 0; @@ -4112,10 +4112,10 @@ int CCSAFDetails::Write(OutputDataFile &df) int count = 0; int version = CREDIT_CARD_VERSION; - while (head->fore != nullptr) + while (head->fore != NULL) head = head->fore; curr = head; - while (curr != nullptr) + while (curr != NULL) { count += 1; curr = curr->next; @@ -4124,7 +4124,7 @@ int CCSAFDetails::Write(OutputDataFile &df) df.Write(version); df.Write(count); curr = head; - while (curr != nullptr) + while (curr != NULL) { df.Write(curr->terminal); df.Write(curr->batch); @@ -4156,7 +4156,7 @@ int CCSAFDetails::Load(const char* filename) InputDataFile infile; int version; - if (filename != nullptr) + if (filename != NULL) { vt_safe_string::safe_copy(filepath, STRLONG, filename); if (infile.Open(filepath, version) == 0) @@ -4194,7 +4194,7 @@ int CCSAFDetails::Count() if (terminal.size() > 0) { retval = 1; - while (node != nullptr) + while (node != NULL) { retval += 1; node = node->next; @@ -4233,7 +4233,7 @@ int CCSAFDetails::Add(Terminal *term) { FnTrace("CCSAFDetails::Add()"); int retval = 0; - CCSAFDetails *newsaf = nullptr; + CCSAFDetails *newsaf = NULL; CCSAFDetails *node = this; if (terminal.empty()) @@ -4242,7 +4242,7 @@ int CCSAFDetails::Add(Terminal *term) } else { - while (node->next != nullptr) + while (node->next != NULL) node = node->next; newsaf = new CCSAFDetails; newsaf->ReadResults(term); @@ -4259,14 +4259,14 @@ int CCSAFDetails::MakeReport(Terminal *term, Report *report, ReportZone *rzone) FnTrace("CCSAFDetails::MakeReport()"); int retval = 0; - if (current == nullptr) + if (current == NULL) { current = this; - while (current->next != nullptr) + while (current->next != NULL) current = current->next; } - if (current != nullptr) + if (current != NULL) { current->GenerateReport(term, report, rzone); retval = 0; @@ -4347,7 +4347,7 @@ int CCSAFDetails::GenerateReport(Terminal *term, Report *report, ReportZone *rzo int CC_CreditType(const char* a) { FnTrace("CC_CreditType()"); - if (a == nullptr) + if (a == NULL) return CREDIT_TYPE_UNKNOWN; int len = strlen(a); @@ -4457,7 +4457,7 @@ int CC_IsValidExpiry(const char* expiry) year = atoi(buff) + 2000; // get current month and year - now = time(nullptr); + now = time(NULL); current = localtime(&now); curr_month = current->tm_mon + 1; curr_year = current->tm_year + 1900; diff --git a/main/data/credit.hh b/main/data/credit.hh index 2651909a..c7305de7 100644 --- a/main/data/credit.hh +++ b/main/data/credit.hh @@ -18,8 +18,8 @@ * Credit/charge card verification/authorization */ -#ifndef CREDIT_HH -#define CREDIT_HH +#ifndef _CREDIT_HH +#define _CREDIT_HH #include "list_utility.hh" #include "printer.hh" @@ -39,9 +39,9 @@ extern const char* CreditCardName[]; extern const char* CreditCardShortName[]; extern int CreditCardValue[]; -#define CC_STATUS_NONE (-2) +#define CC_STATUS_NONE -2 // these are taken from MCVE -#define CC_STATUS_ERROR (-1) +#define CC_STATUS_ERROR -1 #define CC_STATUS_FAIL 0 #define CC_STATUS_SUCCESS 1 #define CC_STATUS_AUTH 2 @@ -60,7 +60,7 @@ extern int CreditCardValue[]; #define CC_STATUS_WRITEFAIL 21 // actions -#define CCAUTH_FIND (-1) +#define CCAUTH_FIND -1 #define CCAUTH_NOACTION 0 #define CCAUTH_PREAUTH 1 #define CCAUTH_AUTHORIZE 2 @@ -130,7 +130,7 @@ extern int CreditCardValue[]; #define SWIPE_MSG "Please Swipe Card" #define WAIT_MSG "Please Wait" -#define AUTH_DEFAULT (-1) +#define AUTH_DEFAULT -1 #define AUTH_NONE 0 #define AUTH_IN_PROGRESS 1 #define AUTH_PREAUTH 2 @@ -142,12 +142,9 @@ extern int CreditCardValue[]; #define AUTH_COMPLETE 128 #define AUTH_ADVICE 256 -// Receipt copy selection (converted from macros to enum constants) -enum ReceiptCopy : std::uint8_t { - RECEIPT_PICK = 0, // auto-select receipt types based on settings - RECEIPT_CUSTOMER = 1, - RECEIPT_MERCHANT = 2 -}; +#define RECEIPT_PICK 0 // auto-select receipts types based on settings +#define RECEIPT_CUSTOMER 1 +#define RECEIPT_MERCHANT 2 #define MASTER_CC_EXCEPT VIEWTOUCH_PATH "/dat/current/cc_exceptions.dat" #define MASTER_CC_REFUND VIEWTOUCH_PATH "/dat/current/cc_refunds.dat" @@ -295,7 +292,7 @@ class Credit char* ReverseExpiry( char* expiry ); int ValidateCardInfo(); int CanPrintSignature(); - int ReceiptPrint(Terminal *term, int receipt_type, Printer *pprinter = nullptr, + int ReceiptPrint(Terminal *term, int receipt_type, Printer *pprinter = NULL, int print_amount = -1); public: @@ -325,7 +322,7 @@ public: int ParseSwipe(const char* swipe_value); int ParseApproval(const char* value); int CardType() { return card_type; } - char* CreditTypeName( char* str=nullptr, int shortname = 0 ); + char* CreditTypeName( char* str=0, int shortname = 0 ); int CreditType(); int GetApproval(Terminal *term); int GetPreApproval(Terminal *term); @@ -335,7 +332,7 @@ public: int GetRefund(Terminal *term); int GetRefundCancel(Terminal *term); int PrintReceipt(Terminal *term, int receipt_type = RECEIPT_PICK, - Printer *pprinter = nullptr, int print_amount = -1); + Printer *pprinter = NULL, int print_amount = -1); int IsEmpty(); int IsValid(); int IsVoiced(); @@ -355,7 +352,7 @@ public: const char* Approval(); const char* Auth() { return auth.Value(); } const char* PAN(int all = 0); - char* LastFour( char* dest = nullptr); + char* LastFour( char* dest = 0); const char* ExpireDate(); // nicely formats expiration date const char* Name(); const char* Verb() { return verb.Value(); } @@ -371,7 +368,7 @@ public: int SetCode(const char* set) { code.Set(set); return 0; } int SetVerb(const char* set) { verb.Set(set); return 0; } int SetAuth(const char* set) { auth.Set(set); return 0; } - int SetBatch(long long set, const char* btermid = nullptr); + int SetBatch(long long set, const char* btermid = NULL); int SetItem(long set) { item = set; return 0; } int SetTTID(long set) { ttid = set; return 0; } int SetAVS(const char* set) { AVS.Set(set); return 0; } @@ -516,7 +513,7 @@ public: int Next(Terminal *term); int Fore(Terminal *term); CCSettle *Last(); - int Add(Terminal *term, const char* message = nullptr); + int Add(Terminal *term, const char* message = NULL); int Add(Check *check); CCSettle *Copy(); void Clear(); diff --git a/main/data/exception.cc b/main/data/exception.cc index f273a2f8..bbe391fb 100644 --- a/main/data/exception.cc +++ b/main/data/exception.cc @@ -36,8 +36,8 @@ // Constructors ItemException::ItemException() { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; user_id = 0; exception_type = 0; reason = -1; @@ -48,8 +48,8 @@ ItemException::ItemException() ItemException::ItemException(Check *c, Order *o) { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; user_id = 0; exception_type = 0; reason = -1; @@ -96,8 +96,8 @@ int ItemException::Write(OutputDataFile &df, int version) // Constructors TableException::TableException() { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; user_id = 0; source_id = 0; target_id = 0; @@ -106,8 +106,8 @@ TableException::TableException() TableException::TableException(Check *c) { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; user_id = 0; source_id = 0; target_id = 0; @@ -145,16 +145,16 @@ int TableException::Write(OutputDataFile &df, int version) // Constructor RebuildException::RebuildException() { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; user_id = 0; check_serial = 0; } RebuildException::RebuildException(Check *c) { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; user_id = 0; check_serial = c->serial_number; } @@ -185,7 +185,7 @@ int RebuildException::Write(OutputDataFile &df, int version) // Constructor ExceptionDB::ExceptionDB() { - archive = nullptr; + archive = NULL; } // Member Functions @@ -237,7 +237,7 @@ int ExceptionDB::Read(InputDataFile &df, int version) for (i = 0; i < count; ++i) { - auto *ie = new ItemException; + ItemException *ie = new ItemException; ie->Read(df, version); Add(ie); } @@ -245,7 +245,7 @@ int ExceptionDB::Read(InputDataFile &df, int version) error += df.Read(count); for (i = 0; i < count; ++i) { - auto *te = new TableException; + TableException *te = new TableException; te->Read(df, version); Add(te); } @@ -253,7 +253,7 @@ int ExceptionDB::Read(InputDataFile &df, int version) error += df.Read(count); for (i = 0; i < count; ++i) { - auto *re = new RebuildException; + RebuildException *re = new RebuildException; re->Read(df, version); Add(re); } @@ -267,17 +267,17 @@ int ExceptionDB::Write(OutputDataFile &df, int version) // Write Item Exceptions int error = df.Write(ItemCount(), 1); - for (ItemException *ie = ItemList(); ie != nullptr; ie = ie->next) + for (ItemException *ie = ItemList(); ie != NULL; ie = ie->next) error += ie->Write(df, version); // Write Table Exceptions error += df.Write(TableCount(), 1); - for (TableException *te = TableList(); te != nullptr; te = te->next) + for (TableException *te = TableList(); te != NULL; te = te->next) error += te->Write(df, version); // Write Rebuild Exceptions error += df.Write(RebuildCount(), 1); - for (RebuildException *re = RebuildList(); re != nullptr; re = re->next) + for (RebuildException *re = RebuildList(); re != NULL; re = re->next) error += re->Write(df, version); return error; } @@ -352,13 +352,13 @@ int ExceptionDB::AddItemException(Terminal *term, Check *thisCheck, Order *thisO FnTrace("ExceptionDB::AddItemException()"); Employee *thisEmployee = term->user; - if (thisOrder == nullptr || !(thisOrder->status & ORDER_FINAL) || thisEmployee == nullptr) + if (thisOrder == NULL || !(thisOrder->status & ORDER_FINAL) || thisEmployee == NULL) { return 1; // exception ignored } // allocate space on the heap for exception structure - auto *ie = new ItemException(thisCheck, thisOrder); + ItemException *ie = new ItemException(thisCheck, thisOrder); // NOTE: need to implement check for failed allocation // set relevant properties for this exception @@ -377,11 +377,11 @@ int ExceptionDB::AddTableException(Terminal *t, Check *c, int target_id) { FnTrace("ExceptionDB::AddTableException()"); Employee *e = t->user; - if (c == nullptr || c->IsEmpty() || c->IsTraining() || e == nullptr) + if (c == NULL || c->IsEmpty() || c->IsTraining() || e == NULL) return 1; // exception ignored // Add table exception - auto *te = new TableException(c); + TableException *te = new TableException(c); te->user_id = e->id; te->time = SystemTime; te->source_id = c->user_owner; @@ -395,11 +395,11 @@ int ExceptionDB::AddRebuildException(Terminal *t, Check *c) { FnTrace("ExceptionDB::AddRebuildException()"); Employee *e = t->user; - if (c == nullptr || c->IsTraining() || e == nullptr) + if (c == NULL || c->IsTraining() || e == NULL) return 1; // exception ignored // Add rebuild exception - auto *re = new RebuildException(c); + RebuildException *re = new RebuildException(c); re->user_id = e->id; re->time = SystemTime; Add(re); diff --git a/main/data/exception.hh b/main/data/exception.hh index d6056ae9..18a09cd6 100644 --- a/main/data/exception.hh +++ b/main/data/exception.hh @@ -18,8 +18,8 @@ * Record of voids/comps and other system changes */ -#ifndef EXCEPTION_HH -#define EXCEPTION_HH +#ifndef _EXCEPTION_HH +#define _EXCEPTION_HH #include "utility.hh" #include "list_utility.hh" @@ -28,7 +28,7 @@ /**** Definitions ****/ #define EXCEPTION_VERSION 3 -enum exceptions : std::uint8_t { +enum exceptions { EXCEPTION_COMP = 1, EXCEPTION_VOID, EXCEPTION_UNCOMP diff --git a/main/data/expense.cc b/main/data/expense.cc index 98501cbd..18955c09 100644 --- a/main/data/expense.cc +++ b/main/data/expense.cc @@ -22,8 +22,8 @@ #include "expense.hh" #include "system.hh" #include "expense_zone.hh" -#include -#include +#include +#include #include #include @@ -39,7 +39,7 @@ int compareString(const char* big, const genericChar* little) if (lenlit > lenbig) return 0; - if (nullptr != strstr(big, little)) + if (NULL != strstr(big, little)) return 1; else return 0; @@ -189,7 +189,7 @@ int Expense::IsBlank() int Expense::Author( Terminal* term, genericChar* employee_name ) { FnTrace("Expense::Author()"); - if (term == nullptr || term->system_data == nullptr || employee_name == nullptr) + if (term == NULL || term->system_data == NULL || employee_name == NULL) return 1; UserDB *employee_db = &(term->system_data->user_db); Employee *employee; @@ -205,20 +205,20 @@ int Expense::Author( Terminal* term, genericChar* employee_name ) int Expense::DrawerOwner(Terminal *term, genericChar* drawer_name, Archive *archive) { FnTrace("Expense::DrawerOwner(term)"); - if (term == nullptr || drawer_name == nullptr) + if (term == NULL || drawer_name == NULL) return 1; UserDB *employee_db = &(term->system_data->user_db); Drawer *drawerlist; - if (archive != nullptr) + if (archive != NULL) drawerlist = archive->DrawerList(); else drawerlist = term->system_data->DrawerList(); - Drawer *drawer = nullptr; - Employee *drawer_owner = nullptr; + Drawer *drawer = NULL; + Employee *drawer_owner = NULL; drawer_name[0] = '\0'; drawer = drawerlist->FindBySerial(drawer_id); - if (drawer != nullptr) + if (drawer != NULL) { drawer_owner = employee_db->FindByID(drawer->owner_id); if (drawer_owner) @@ -245,13 +245,13 @@ int Expense::DrawerOwner(Terminal *term, genericChar* drawer_name, Archive *arch int Expense::AccountName(Terminal *term, genericChar* account_name, Archive *archive) { FnTrace("Expense::AccountName()"); - if (term == nullptr || account_name == nullptr) + if (term == NULL || account_name == NULL) return 1; AccountDB *acct_db = &(term->system_data->account_db); - Account *account = nullptr; + Account *account = NULL; account = acct_db->FindByNumber(account_id); - if (account != nullptr) + if (account != NULL) snprintf(account_name, STRLENGTH, "%s", account->name.Value()); else account_name[0] = '\0'; @@ -394,13 +394,13 @@ int ExpenseDB::StatusMatch(int status, int drawer_status) int ExpenseDB::ExpenseCount(Terminal *term, int status) { FnTrace("ExpenseDB::ExpenseCount()"); - Expense *currExpense = nullptr; - Drawer *dlist = nullptr; - Drawer *drawer = nullptr; + Expense *currExpense = NULL; + Drawer *dlist = NULL; + Drawer *drawer = NULL; int dstat; int count = 0; - if (term == nullptr) + if (term == NULL) { count = expense_list.Count(); } @@ -408,7 +408,7 @@ int ExpenseDB::ExpenseCount(Terminal *term, int status) { dlist = term->system_data->DrawerList(); currExpense = expense_list.Head(); - while (currExpense != nullptr) + while (currExpense != NULL) { drawer = dlist->FindBySerial(currExpense->drawer_id); if (drawer) @@ -465,7 +465,7 @@ int ExpenseDB::Write(OutputDataFile &outfile, int version) outfile.Write(entered); outfile.Write(expense_list.Count()); - while (currExp != nullptr) + while (currExp != NULL) { if (! currExp->IsTraining()) currExp->Write(outfile, version); @@ -478,7 +478,7 @@ int ExpenseDB::Load(const char* path) { FnTrace("ExpenseDB::Load()"); InputDataFile infile; - struct dirent *record = nullptr; + struct dirent *record = NULL; const genericChar* name; genericChar fullpath[STRLENGTH]; int version = 0; @@ -502,7 +502,7 @@ int ExpenseDB::Load(const char* path) // then read the individual expenses DIR *dp = opendir(pathname.Value()); - if (dp == nullptr) + if (dp == NULL) return 1; // Error - can't find directory do { @@ -516,7 +516,7 @@ int ExpenseDB::Load(const char* path) if (strcmp(&name[len-4], ".fmt") == 0) break; snprintf(fullpath, STRLENGTH, "%s/%s", pathname.Value(), name); - auto *exp = new Expense(); + Expense *exp = new Expense(); if (exp->Load(fullpath)) ReportError("Error loading expense"); else @@ -538,11 +538,11 @@ int ExpenseDB::RemoveBlank() { FnTrace("ExpenseDB::RemoveBlank()"); Expense *curr = expense_list.Head(); - Expense *next = nullptr; + Expense *next = NULL; int new_id = 0; // wipe out all blank records and find the highest id - while (curr != nullptr) + while (curr != NULL) { next = curr->next; if (curr->IsBlank()) @@ -582,7 +582,7 @@ int ExpenseDB::Save() // save individual expenses Expense *thisexp = expense_list.Head(); - while (thisexp != nullptr) + while (thisexp != NULL) { if (! thisexp->IsTraining()) thisexp->Save(pathname.Value()); @@ -598,7 +598,7 @@ int ExpenseDB::Save(int id) RemoveBlank(); Expense *exp = FindByID(id); - if (exp != nullptr && exp->IsTraining() == 0) + if (exp != NULL && exp->IsTraining() == 0) { exp->Save(pathname.Value()); retval = 0; @@ -612,12 +612,12 @@ int ExpenseDB::SaveEntered(int entered_val, int drawer_serial) int retval = 0; Expense *expense = expense_list.Head(); - while (expense != nullptr) + while (expense != NULL) { if (expense->drawer_id == drawer_serial) { expense->entered = entered_val; - expense = nullptr; // end the loop + expense = NULL; // end the loop } else { @@ -663,10 +663,10 @@ int ExpenseDB::AddDrawerPayments(Drawer *drawer_list) int count; // First, clear out the payment balances - while (currDrawer != nullptr) + while (currDrawer != NULL) { currBalance = currDrawer->BalanceList(); - while (currBalance != nullptr) + while (currBalance != NULL) { nextBalance = currBalance->next; if (currBalance->tender_type == TENDER_EXPENSE) @@ -679,13 +679,13 @@ int ExpenseDB::AddDrawerPayments(Drawer *drawer_list) } currDrawer = drawer_list; - while (currDrawer != nullptr) + while (currDrawer != NULL) { amount = 0; my_entered = 0; count = 0; Expense *currExpense = expense_list.Head(); - while (currExpense != nullptr) + while (currExpense != NULL) { if ((currExpense->IsTraining() == 0) && (currExpense->drawer_id == currDrawer->serial_number)) @@ -704,7 +704,7 @@ int ExpenseDB::AddDrawerPayments(Drawer *drawer_list) currBalance->amount = amount; currBalance->count = count; currBalance->entered = my_entered; - currDrawer->Total(nullptr, 1); + currDrawer->Total(NULL, 1); } } currDrawer = currDrawer->next; @@ -745,12 +745,12 @@ int ExpenseDB::MoveTo(ExpenseDB *exp_db, Drawer *DrawerList) { FnTrace("ExpenseDB::MoveTo()"); Expense *currExpense = expense_list.Head(); - Expense *prevExpense = nullptr; + Expense *prevExpense = NULL; Drawer *currDrawer; int move; exp_db->entered = entered; - while (currExpense != nullptr) + while (currExpense != NULL) { move = 0; // if the Expense is from an account, or if the drawer has been balanced, @@ -762,7 +762,7 @@ int ExpenseDB::MoveTo(ExpenseDB *exp_db, Drawer *DrawerList) if (currExpense->drawer_id > -1) { currDrawer = DrawerList->FindBySerial(currExpense->drawer_id); - if (currDrawer != nullptr && currDrawer->GetStatus() == DRAWER_BALANCED) + if (currDrawer != NULL && currDrawer->GetStatus() == DRAWER_BALANCED) { move = 1; } @@ -803,10 +803,10 @@ int ExpenseDB::MoveAll(ExpenseDB *exp_db) FnTrace("ExpenseDB::MoveAll()"); Expense *currExpense = expense_list.Head(); - while (currExpense != nullptr) + while (currExpense != NULL) { Remove(currExpense); - if (exp_db != nullptr) + if (exp_db != NULL) exp_db->Add(currExpense); currExpense = expense_list.Head(); } @@ -816,32 +816,32 @@ int ExpenseDB::MoveAll(ExpenseDB *exp_db) Expense *ExpenseDB::FindByRecord(Terminal *term, int no, int drawer_type) { FnTrace("ExpenseDB::FindByRecord()"); - Drawer *dlist = nullptr; - Drawer *drawer = nullptr; + Drawer *dlist = NULL; + Drawer *drawer = NULL; Expense *thisexp = expense_list.Head(); - Expense *retexp = nullptr; + Expense *retexp = NULL; int count = 0; int maxcount = expense_list.Count(); - if (term != nullptr) + if (term != NULL) dlist = term->system_data->DrawerList(); - while (thisexp != nullptr && count < maxcount) + while (thisexp != NULL && count < maxcount) { - if (dlist != nullptr) + if (dlist != NULL) drawer = dlist->FindBySerial(thisexp->drawer_id); - if ((drawer == nullptr) || (StatusMatch(drawer_type, drawer->GetStatus()))) + if ((drawer == NULL) || (StatusMatch(drawer_type, drawer->GetStatus()))) { if (count == no) { retexp = thisexp; - thisexp = nullptr; //end the loop + thisexp = NULL; //end the loop } else { count += 1; } } - if (thisexp != nullptr) + if (thisexp != NULL) thisexp = thisexp->next; } return retexp; @@ -851,14 +851,14 @@ Expense *ExpenseDB::FindByID(int id) { FnTrace("ExpenseDB::FindByID()"); Expense *thisexp = expense_list.Head(); - Expense *retexp = nullptr; + Expense *retexp = NULL; - while (thisexp != nullptr) + while (thisexp != NULL) { if (id == thisexp->eid) { retexp = thisexp; - thisexp = nullptr; //end the loop + thisexp = NULL; //end the loop } else thisexp = thisexp->next; @@ -873,34 +873,34 @@ Expense *ExpenseDB::FindByID(int id) int ExpenseDB::FindRecordByWord(Terminal *term, const genericChar* word, int start, Archive *archive) { FnTrace("ExpenseDB::FindRecordByWord()"); - Drawer *dlist = nullptr; - Drawer *drawer = nullptr; + Drawer *dlist = NULL; + Drawer *drawer = NULL; Expense *thisexp = expense_list.Head(); int count = 0; int maxcount = expense_list.Count(); int retval = -1; - if (archive != nullptr) + if (archive != NULL) dlist = archive->DrawerList(); - else if (term != nullptr) + else if (term != NULL) dlist = term->system_data->DrawerList(); - while (thisexp != nullptr && count < maxcount) + while (thisexp != NULL && count < maxcount) { - if (dlist != nullptr) + if (dlist != NULL) drawer = dlist->FindBySerial(thisexp->drawer_id); - if ((drawer == nullptr) || (StatusMatch(DRAWER_OPEN, drawer->GetStatus()))) + if ((drawer == NULL) || (StatusMatch(DRAWER_OPEN, drawer->GetStatus()))) { if ((count > start) && thisexp->WordMatch(term, word)) { retval = count; - thisexp = nullptr; //end the loop + thisexp = NULL; //end the loop } else { count += 1; } } - if (thisexp != nullptr) + if (thisexp != NULL) thisexp = thisexp->next; } return retval; @@ -918,7 +918,7 @@ int ExpenseDB::CountFromDrawer(int drawer_id, int training) Expense *currExp = expense_list.Head(); int drawer_count = 0; - while (currExp != nullptr) + while (currExp != NULL) { if ((currExp->drawer_id == drawer_id) && (currExp->IsTraining() == training)) @@ -942,7 +942,7 @@ int ExpenseDB::BalanceFromDrawer(int drawer_id, int training) Expense *currExp = expense_list.Head(); int drawer_expenses = 0; - while (currExp != nullptr) + while (currExp != NULL) { if ((currExp->drawer_id == drawer_id) && (currExp->IsTraining() == training)) @@ -960,7 +960,7 @@ int ExpenseDB::CountFromAccount(int account_id, int training) Expense *currExp = expense_list.Head(); int account_count = 0; - while (currExp != nullptr) + while (currExp != NULL) { if ((currExp->account_id == account_id) && (currExp->IsTraining() == training)) @@ -978,7 +978,7 @@ int ExpenseDB::BalanceFromAccount(int account_id, int training) Expense *currExp = expense_list.Head(); int account_expenses = 0; - while (currExp != nullptr) + while (currExp != NULL) { if ((currExp->account_id == account_id) && (currExp->IsTraining() == training)) @@ -1008,7 +1008,7 @@ int ExpenseDB::TotalExpenses(int training) Expense *currExp = expense_list.Head(); int total_expenses = 0; - while (currExp != nullptr) + while (currExp != NULL) { if (currExp->IsTraining() == training) total_expenses += currExp->amount; @@ -1023,7 +1023,7 @@ int ExpenseDB::EnteredFromDrawer(int drawer_id, int training) Expense *currExp = expense_list.Head(); int drawer_entered = 0; - while (currExp != nullptr) + while (currExp != NULL) { if ((currExp->drawer_id == drawer_id) && (currExp->IsTraining() == training)) @@ -1041,7 +1041,7 @@ int ExpenseDB::PrintExpenses() Expense *currExpense = expense_list.Head(); printf("Print Start...\n"); - while (currExpense != nullptr) + while (currExpense != NULL) { printf(" Expense %s\n", currExpense->document.Value()); currExpense = currExpense->next; diff --git a/main/data/expense.hh b/main/data/expense.hh index 7d303641..f6a58985 100644 --- a/main/data/expense.hh +++ b/main/data/expense.hh @@ -28,8 +28,8 @@ // for one value per drawer. Thus the current method which may, in // the end, not work. -#ifndef EXPENSE_HH -#define EXPENSE_HH +#ifndef _EXPENSE_HH +#define _EXPENSE_HH #include "list_utility.hh" #include "utility.hh" @@ -86,8 +86,8 @@ public: int Save(const char* path); int IsBlank(); int Author(Terminal *term, genericChar* employee_name); - int DrawerOwner(Terminal *term, genericChar* drawer_name, Archive *archive = nullptr); - int AccountName(Terminal *term, genericChar* account_name, Archive *archive = nullptr); + int DrawerOwner(Terminal *term, genericChar* drawer_name, Archive *archive = NULL); + int AccountName(Terminal *term, genericChar* account_name, Archive *archive = NULL); int IsTraining(); int SetFlag(int flagval); int Copy(Expense *original); @@ -104,7 +104,7 @@ public: ~ExpenseDB(); Expense *ExpenseList() { return expense_list.Head(); } Expense *ExpenseListEnd() { return expense_list.Tail(); } - int ExpenseCount(Terminal *term = nullptr, int status = DRAWER_ANY); + int ExpenseCount(Terminal *term = NULL, int status = DRAWER_ANY); int StatusMatch(int status, int drawer_status); int Read(InputDataFile &infile, int version); @@ -123,7 +123,7 @@ public: int MoveAll(ExpenseDB *exp_db); Expense *FindByRecord(Terminal *term, int no, int drawer_type = DRAWER_OPEN); Expense *FindByID(int id); - int FindRecordByWord(Terminal *term, const genericChar* word, int start = -1, Archive *archive = nullptr); + int FindRecordByWord(Terminal *term, const genericChar* word, int start = -1, Archive *archive = NULL); int CountFromDrawer(int drawer_id, int training = 0); int BalanceFromDrawer(int drawer_id, int training = 0); int EnteredFromDrawer(int drawer_id, int training = 0); diff --git a/main/data/license_hash.cc b/main/data/license_hash.cc index 9b322e0b..9545e7d5 100644 --- a/main/data/license_hash.cc +++ b/main/data/license_hash.cc @@ -101,11 +101,11 @@ int GetInterfaceInfo(char* stringbuff, int stringlen) mib[4] = NET_RT_IFLIST; mib[5] = 0; - if (sysctl(mib, 6, nullptr, &len, nullptr, 0) < 0) + if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) return 1; - if ((buffer = (char*)malloc(len)) == nullptr) + if ((buffer = (char*)malloc(len)) == NULL) return 1; - if (sysctl(mib, 6, buffer, &len, nullptr, 0) < 0) { + if (sysctl(mib, 6, buffer, &len, NULL, 0) < 0) { free(buffer); return 1; } @@ -374,7 +374,7 @@ int GetInterfaceInfo(char* stringbuf, int stringlen) } close(sockfd); - if (buf != nullptr) + if (buf != NULL) free(buf); */ diff --git a/main/data/locale.cc b/main/data/locale.cc index 3433126c..f4a630af 100644 --- a/main/data/locale.cc +++ b/main/data/locale.cc @@ -3820,8 +3820,8 @@ static const TranslationEntry extended_translations[] = { {"Scheduled Restart Settings", "Configuración de Reinicio Programado"}, {"Kitchen Video Order Alert Settings", "Configuración de Alertas de Pedidos de Video de Cocina"}, {"TermError", "Error de Terminal"}, - {"ServerProtocol::SrvZoneData received, calling ReadZone()", "Datos de zona del servidor recibidos, llamando ReadZone()"}, - {"ServerProtocol::SrvZoneData: ReadZone() returned", "Datos de zona del servidor: ReadZone() retornó"}, + {"SERVER_ZONEDATA received, calling ReadZone()", "Datos de zona del servidor recibidos, llamando ReadZone()"}, + {"SERVER_ZONEDATA: ReadZone() returned", "Datos de zona del servidor: ReadZone() retornó"}, {"Unknown check version '%d'", "Versión de cheque desconocida '%d'"}, {"Warning Time (minutes)", "Tiempo de Advertencia (minutos)"}, {"Warning Color", "Color de Advertencia"}, @@ -3869,7 +3869,7 @@ static const char* LookupHardcodedTranslation(const char* str, int lang) { void StartupLocalization() { - if (setlocale(LC_ALL, "") == nullptr) + if (setlocale(LC_ALL, "") == NULL) { (void) fprintf(stderr, "Cannot set locale.\n"); exit(1); @@ -3879,7 +3879,7 @@ void StartupLocalization() // Global translation function that can be used anywhere const genericChar* GlobalTranslate(const genericChar* str) { - if (MasterLocale == nullptr) + if (MasterLocale == NULL) return str; return MasterLocale->Translate(str, global_current_language, 0); @@ -4132,7 +4132,7 @@ PhraseEntry PhraseData[] = { {15, "Pre-Auth Complete"}, {15, "Fast Food"}, - {-1, nullptr} + {-1, NULL} }; /********************************************************************* @@ -4142,15 +4142,15 @@ PhraseEntry PhraseData[] = { PhraseInfo::PhraseInfo() { FnTrace("PhraseInfo::PhraseInfo()"); - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; } PhraseInfo::PhraseInfo(const char* k, const genericChar* v) { FnTrace("PhraseInfo::PhraseInfo(const char* , const char* )"); - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; key.Set(k); value.Set(v); } @@ -4180,9 +4180,9 @@ int PhraseInfo::Write(OutputDataFile &df, int version) Locale::Locale() { FnTrace("Locale::Locale()"); - next = nullptr; - fore = nullptr; - search_array = nullptr; + next = NULL; + fore = NULL; + search_array = NULL; array_size = 0; } @@ -4220,7 +4220,7 @@ int Locale::Load(const char* file) df.Read(count); for (int i = 0; i < count; ++i) { - auto *ph = new PhraseInfo; + PhraseInfo *ph = new PhraseInfo; ph->Read(df, 1); Add(ph); } @@ -4247,7 +4247,7 @@ int Locale::Save() df.Write(0); df.Write(PhraseCount()); - for (PhraseInfo *ph = PhraseList(); ph != nullptr; ph = ph->next) + for (PhraseInfo *ph = PhraseList(); ph != NULL; ph = ph->next) ph->Write(df, 1); return 0; } @@ -4255,13 +4255,13 @@ int Locale::Save() int Locale::Add(PhraseInfo *ph) { FnTrace("Locale::Add()"); - if (ph == nullptr) + if (ph == NULL) return 1; if (search_array) { free(search_array); - search_array = nullptr; + search_array = NULL; array_size = 0; } @@ -4278,13 +4278,13 @@ int Locale::Add(PhraseInfo *ph) int Locale::Remove(PhraseInfo *ph) { FnTrace("Locale::Remove()"); - if (ph == nullptr) + if (ph == NULL) return 1; if (search_array) { free(search_array); - search_array = nullptr; + search_array = NULL; array_size = 0; } return phrase_list.Remove(ph); @@ -4298,7 +4298,7 @@ int Locale::Purge() if (search_array) { free(search_array); - search_array = nullptr; + search_array = NULL; array_size = 0; } return 0; @@ -4318,7 +4318,7 @@ int Locale::BuildSearchArray() array_size = PhraseCount(); search_array = (PhraseInfo **)calloc(sizeof(PhraseInfo *), (array_size + 1)); - if (search_array == nullptr) + if (search_array == NULL) return 1; PhraseInfo *ph = PhraseList(); @@ -4336,9 +4336,9 @@ int Locale::BuildSearchArray() PhraseInfo *Locale::Find(const char* key) { FnTrace("Locale::Find()"); - if (key == nullptr) - return nullptr; - if (search_array == nullptr) + if (key == NULL) + return NULL; + if (search_array == NULL) BuildSearchArray(); int l = 0; @@ -4356,7 +4356,7 @@ PhraseInfo *Locale::Find(const char* key) else return ph; } - return nullptr; + return NULL; } /**** @@ -4371,7 +4371,7 @@ const char* Locale::Translate(const char* str, int lang, int clear) if (lang == LANG_PHRASE) { PhraseInfo *ph = Find(str); - if (ph == nullptr) + if (ph == NULL) { // If clear flag is set and phrase not found, return empty string if (clear) @@ -4418,19 +4418,19 @@ int Locale::NewTranslation(const char* str, const genericChar* value) if (search_array) { free(search_array); - search_array = nullptr; + search_array = NULL; array_size = 0; } return 0; } - if (value == nullptr || strlen(value) <= 0) + if (value == NULL || strlen(value) <= 0) return 1; if (search_array) { free(search_array); - search_array = nullptr; + search_array = NULL; array_size = 0; } return Add(new PhraseInfo(str, value)); @@ -4447,7 +4447,7 @@ const char* Locale::TimeDate(Settings *s, const TimeInfo &timevar, int format, i // Mon Oct 1 13:14:27 PDT 2001: some work done in this direction - JMK static genericChar buffer[256]; - if (str == nullptr) + if (str == NULL) str = buffer; if (!timevar.IsSet()) @@ -4591,7 +4591,7 @@ char* Locale::Page(int current, int page_max, int lang, genericChar* str) { FnTrace("Locale::Page()"); static genericChar buffer[32]; - if (str == nullptr) + if (str == NULL) str = buffer; // Ensure current and page_max are valid diff --git a/main/data/locale.hh b/main/data/locale.hh index e30419e7..30d958fa 100644 --- a/main/data/locale.hh +++ b/main/data/locale.hh @@ -18,15 +18,15 @@ * Phrase lookup/translation & local conventions module */ -#ifndef LOCALE_HH -#define LOCALE_HH +#ifndef _LOCALE_HH +#define _LOCALE_HH #include "data_file.hh" #include "utility.hh" #include "list_utility.hh" #include -#define LANG_NONE (-1) // uninitialized POFile class +#define LANG_NONE -1 // uninitialized POFile class #define LANG_PHRASE 0 // for old defaults; do not search POFile classes #define LANG_ENGLISH 1 #define LANG_SPANISH 2 @@ -107,7 +107,7 @@ public: const genericChar* TranslatePO(const char* str, int lang = LANG_PHRASE, int clear = 0); int NewTranslation(const char* str, const genericChar* value); - const char* TimeDate(Settings* s, const TimeInfo &timevar, int format, int lang, genericChar* str = nullptr); + const char* TimeDate(Settings* s, const TimeInfo &timevar, int format, int lang, genericChar* str = 0); char* Page( int current, int page_max, int lang, genericChar* str ); }; diff --git a/main/data/manager.cc b/main/data/manager.cc index 131d5dcc..03e0fd75 100644 --- a/main/data/manager.cc +++ b/main/data/manager.cc @@ -46,6 +46,7 @@ #include "src/utils/vt_logger.hh" // Modern C++ logging #include "safe_string_utils.hh" // Safe string operations #include "date/date.h" // helper library to output date strings with std::chrono +#include "src/network/reverse_ssh_service.hh" // Reverse SSH tunnel service #include "src/core/crash_report.hh" // Automatic crash reporting #include @@ -55,7 +56,7 @@ #include // Standard C++ libraries -#include // system error numbers +#include // system error numbers #include // basic input and output controls (C++ alone contains no facilities for IO) #include // basic file input and output #include // standard symbolic constants and types @@ -76,7 +77,6 @@ #include // File Control #include // generic filesystem functions available since C++17 #include // for std::remove -#include // std::array for fixed-size buffers #ifdef DMALLOC #include @@ -110,25 +110,25 @@ constexpr int CALLCTR_STATUS_FAILED = 2; /************************************************************* * Calendar Values *************************************************************/ -const std::array DayName = {"Sunday", "Monday", "Tuesday", "Wednesday", +const char* DayName[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", nullptr}; -const std::array ShortDayName = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", nullptr}; +const char* ShortDayName[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", nullptr}; -const std::array MonthName = {"January", "February", "March", "April", - "May", "June", "July", "August", "September", +const char* MonthName[] = { "January", "February", "March", "April", + "May", "June", "July", "August", "September", "October", "November", "December", nullptr}; -const std::array ShortMonthName = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", +const char* ShortMonthName[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", nullptr}; /************************************************************* * Terminal Type values *************************************************************/ -const std::array TermTypeName = {"Normal", "Order Only", "Bar", "Bar2", +const char* TermTypeName[] = { "Normal", "Order Only", "Bar", "Bar2", "Fast Food", "Self Order", "Kitchen Video", "Kitchen Video2", nullptr}; -const std::array TermTypeValue = {TERMINAL_NORMAL, TERMINAL_ORDER_ONLY, +int TermTypeValue[] = { TERMINAL_NORMAL, TERMINAL_ORDER_ONLY, TERMINAL_BAR, TERMINAL_BAR2, TERMINAL_FASTFOOD, TERMINAL_SELFORDER, TERMINAL_KITCHEN_VIDEO, TERMINAL_KITCHEN_VIDEO2, -1}; @@ -136,11 +136,11 @@ const std::array TermTypeValue = {TERMINAL_NORMAL, TERMINAL_ORDER_ONLY, /************************************************************* * Printer Type values *************************************************************/ -const std::array PrinterTypeName = {"Kitchen 1", "Kitchen 2", "Kitchen 3", "Kitchen 4", +const char* PrinterTypeName[] = { "Kitchen 1", "Kitchen 2", "Kitchen 3", "Kitchen 4", "Bar 1", "Bar 2", "Expediter", "Report", "Credit Receipt", "Remote Order", nullptr}; -const std::array PrinterTypeValue = {PRINTER_KITCHEN1, PRINTER_KITCHEN2, +int PrinterTypeValue[] = { PRINTER_KITCHEN1, PRINTER_KITCHEN2, PRINTER_KITCHEN3, PRINTER_KITCHEN4, PRINTER_BAR1, PRINTER_BAR2, PRINTER_EXPEDITER, PRINTER_REPORT, @@ -150,14 +150,14 @@ const std::array PrinterTypeValue = {PRINTER_KITCHEN1, PRINTER_KITCHEN2 /************************************************************* * Module Globals *************************************************************/ -static XtAppContext App = nullptr; +static XtAppContext App = 0; static Display *Dis = nullptr; static int ScrNo = 0; -static std::array FontInfo{}; -static std::array FontWidth{}; -static std::array FontHeight{}; -static std::array FontBaseline{}; -static std::array XftFontsArr{}; +static XFontStruct *FontInfo[32] = {nullptr}; +static int FontWidth[32]; +static int FontHeight[32]; +static int FontBaseline[32]; +static XftFont *XftFontsArr[32] = {nullptr}; int LoaderSocket = 0; int OpenTermPort = 10001; int OpenTermSocket = -1; @@ -170,10 +170,12 @@ int UserCommand = 2; // see RunUserCommand() definition int AllowLogins = 1; int UserRestart = 0; -std::array displaystr{}; -std::array restart_flag_str{}; +genericChar displaystr[STRLENGTH]; +genericChar restart_flag_str[STRLENGTH]; int use_net = 1; +#define FONT_COUNT (int)(sizeof(FontData)/sizeof(FontDataType)) + struct FontDataType { int id; @@ -182,9 +184,9 @@ struct FontDataType const genericChar* font; }; -const std::array FontData = +static FontDataType FontData[] = { - {{FONT_TIMES_20, 9, 20, "DejaVu Serif:size=12:style=Book"}, + {FONT_TIMES_20, 9, 20, "DejaVu Serif:size=12:style=Book"}, {FONT_TIMES_24, 12, 24, "DejaVu Serif:size=14:style=Book"}, {FONT_TIMES_34, 15, 33, "DejaVu Serif:size=18:style=Book"}, {FONT_TIMES_48, 26, 52, "DejaVu Serif:size=28:style=Book"}, @@ -199,11 +201,9 @@ const std::array FontData = {FONT_COURIER_18, 10, 18, "Liberation Serif:size=11:style=Regular"}, {FONT_COURIER_18B, 10, 18, "Liberation Serif:size=11:style=Bold"}, {FONT_COURIER_20, 10, 20, "Liberation Serif:size=12:style=Regular"}, - {FONT_COURIER_20B, 10, 20, "Liberation Serif:size=12:style=Bold"}} + {FONT_COURIER_20B, 10, 20, "Liberation Serif:size=12:style=Bold"} }; -constexpr int FONT_COUNT = static_cast(FontData.size()); - static XtIntervalId UpdateID = 0; // update callback function id static int LastMin = -1; static int LastHour = -1; @@ -260,11 +260,11 @@ void UserSignal1(int signal); void UserSignal2(int signal); void UpdateSystemCB(XtPointer client_data, XtIntervalId *time_id); int StartSystem(int my_use_net); -int RunUserCommand(); +int RunUserCommand(void); int PingCheck(); int UserCount(); -int RunEndDay(); -int RunMacros(); +int RunEndDay(void); +int RunMacros(void); int RunReport(const genericChar* report_string, Printer *printer); Printer *SetPrinter(const genericChar* printer_description); int ReadViewTouchConfig(); @@ -278,9 +278,9 @@ genericChar* GetMachineName(genericChar* str = nullptr, int len = STRLENGTH) } struct utsname uts; - static std::array buffer{}; + static genericChar buffer[STRLENGTH]; if (str == nullptr) - str = buffer.data(); + str = buffer; if (uname(&uts) == 0) { strncpy(str, uts.nodename, static_cast(len - 1)); @@ -298,24 +298,24 @@ void ViewTouchError(const char* message, int do_sleep) return; // invalid parameter } - std::array errormsg{}; + genericChar errormsg[STRLONG]; int sleeplen = (debug_mode ? 1 : 5); Settings *settings = &(MasterSystem->settings); if (settings->expire_message1.empty()) { - snprintf(errormsg.data(), errormsg.size(), "%s\\%s\\%s", message, + snprintf(errormsg, sizeof(errormsg), "%s\\%s\\%s", message, "Please contact support.", " 541-515-5913"); } else { - snprintf(errormsg.data(), errormsg.size(), R"(%s\%s\%s\%s\%s)", message, + snprintf(errormsg, sizeof(errormsg), "%s\\%s\\%s\\%s\\%s", message, settings->expire_message1.Value(), settings->expire_message2.Value(), settings->expire_message3.Value(), settings->expire_message4.Value()); } - ReportLoader(errormsg.data()); + ReportLoader(errormsg); if (do_sleep) sleep(static_cast(sleeplen)); } @@ -326,7 +326,7 @@ bool DownloadFile(const std::string &url, const std::string &destination) std::string temp_file = destination + ".tmp"; std::ofstream fout(temp_file, std::ios::binary); if (!fout.is_open()) { - std::cerr << "Error: Cannot open temporary file '" << temp_file << "' for writing" << '\n'; + std::cerr << "Error: Cannot open temporary file '" << temp_file << "' for writing" << std::endl; return false; } @@ -361,41 +361,41 @@ bool DownloadFile(const std::string &url, const std::string &destination) if (file_size > 0) { // Download successful, move temp file to final destination if (std::rename(temp_file.c_str(), destination.c_str()) == 0) { - std::cerr << "Successfully downloaded file '" << destination << "' from '" << url << "' (size: " << file_size << " bytes)" << '\n'; + std::cerr << "Successfully downloaded file '" << destination << "' from '" << url << "' (size: " << file_size << " bytes)" << std::endl; return true; } else { - std::cerr << "Error: Could not move temporary file to final destination" << '\n'; + std::cerr << "Error: Could not move temporary file to final destination" << std::endl; std::remove(temp_file.c_str()); // Clean up temp file return false; } } else { - std::cerr << "Downloaded file is empty from '" << url << "'" << '\n'; + std::cerr << "Downloaded file is empty from '" << url << "'" << std::endl; std::remove(temp_file.c_str()); // Remove empty temp file return false; } } else { - std::cerr << "Cannot verify downloaded file from '" << url << "'" << '\n'; + std::cerr << "Cannot verify downloaded file from '" << url << "'" << std::endl; std::remove(temp_file.c_str()); // Remove temp file if we can't verify it return false; } } catch (const curlpp::LogicError & e) { - std::cerr << "Logic error downloading file from '" << url << "': " << e.what() << '\n'; + std::cerr << "Logic error downloading file from '" << url << "': " << e.what() << std::endl; fout.close(); std::remove(temp_file.c_str()); // Remove partial temp file return false; } catch (const curlpp::RuntimeError &e) { - std::cerr << "Runtime error downloading file from '" << url << "': " << e.what() << '\n'; + std::cerr << "Runtime error downloading file from '" << url << "': " << e.what() << std::endl; fout.close(); std::remove(temp_file.c_str()); // Remove partial temp file return false; } catch (const std::exception &e) { - std::cerr << "Unexpected error downloading file from '" << url << "': " << e.what() << '\n'; + std::cerr << "Unexpected error downloading file from '" << url << "': " << e.what() << std::endl; fout.close(); std::remove(temp_file.c_str()); // Remove partial temp file return false; @@ -412,7 +412,7 @@ bool DownloadFileWithFallback(const std::string &base_url, const std::string &de https_url = "https://" + https_url; } - std::cerr << "Attempting HTTPS download from '" << https_url << "'" << '\n'; + std::cerr << "Attempting HTTPS download from '" << https_url << "'" << std::endl; if (DownloadFile(https_url, destination)) { return true; } @@ -425,12 +425,12 @@ bool DownloadFileWithFallback(const std::string &base_url, const std::string &de http_url = "http://" + http_url; } - std::cerr << "HTTPS failed, attempting HTTP download from '" << http_url << "'" << '\n'; + std::cerr << "HTTPS failed, attempting HTTP download from '" << http_url << "'" << std::endl; if (DownloadFile(http_url, destination)) { return true; } - std::cerr << "Both HTTPS and HTTP downloads failed for '" << base_url << "'" << '\n'; + std::cerr << "Both HTTPS and HTTP downloads failed for '" << base_url << "'" << std::endl; return false; } @@ -488,7 +488,7 @@ int main(int argc, genericChar* argv[]) vt::Logger::info("ViewTouch Main (vt_main) starting - Version {}", viewtouch::get_version_short()); - std::array socket_file{}; + genericChar socket_file[256] = ""; if (argc >= 2) { if (strcmp(argv[1], "version") == 0) @@ -508,8 +508,8 @@ int main(int argc, genericChar* argv[]) // Should never reach here, but just in case: return 1; } - strncpy(socket_file.data(), argv[1], socket_file.size() - 1); - socket_file[socket_file.size() - 1] = '\0'; // ensure null termination + strncpy(socket_file, argv[1], sizeof(socket_file) - 1); + socket_file[sizeof(socket_file) - 1] = '\0'; // ensure null termination } LoaderSocket = socket(AF_UNIX, SOCK_STREAM, 0); @@ -523,15 +523,15 @@ int main(int argc, genericChar* argv[]) struct sockaddr_un server_adr; server_adr.sun_family = AF_UNIX; - strncpy(server_adr.sun_path, socket_file.data(), sizeof(server_adr.sun_path) - 1); + strncpy(server_adr.sun_path, socket_file, sizeof(server_adr.sun_path) - 1); server_adr.sun_path[sizeof(server_adr.sun_path) - 1] = '\0'; // ensure null termination sleep(1); - vt::Logger::debug("Connecting to loader socket: {}", socket_file.data()); + vt::Logger::debug("Connecting to loader socket: {}", socket_file); if (connect(LoaderSocket, (struct sockaddr *) &server_adr, SUN_LEN(&server_adr)) < 0) { - vt::Logger::critical("Can't connect to loader socket '{}' - errno: {}", socket_file.data(), errno); + vt::Logger::critical("Can't connect to loader socket '{}' - errno: {}", socket_file, errno); ReportError(GlobalTranslate("Can't connect to loader")); close(LoaderSocket); exit(1); @@ -542,7 +542,7 @@ int main(int argc, genericChar* argv[]) use_net = 1; int purge = 0; int notrace = 0; - std::array data_path{}; + genericChar data_path[256] = "\0"; std::array buffer{}; genericChar* c = buffer.data(); @@ -570,8 +570,8 @@ int main(int argc, genericChar* argv[]) else if (strncmp(buffer.data(), "datapath ", 9) == 0) { // Critical fix: Use strncpy with bounds checking - strncpy(data_path.data(), &buffer[9], data_path.size() - 1); - data_path[data_path.size() - 1] = '\0'; + strncpy(data_path, &buffer[9], sizeof(data_path) - 1); + data_path[sizeof(data_path) - 1] = '\0'; } else if (strcmp(buffer.data(), "netoff") == 0) { @@ -583,7 +583,7 @@ int main(int argc, genericChar* argv[]) } else if (strncmp(buffer.data(), "display ", 8) == 0) { - strncpy(displaystr.data(), &buffer[8], STRLENGTH); + strncpy(displaystr, &buffer[8], STRLENGTH); displaystr[STRLENGTH - 1] = '\0'; // Ensure null termination } else if (strcmp(buffer.data(), "notrace") == 0) @@ -658,9 +658,9 @@ int main(int argc, genericChar* argv[]) vt::Logger::info("Initializing data persistence manager..."); InitializeDataPersistence(MasterSystem.get()); - if (strlen(data_path.data()) > 0) { - vt::Logger::info("Using custom data path: {}", data_path.data()); - MasterSystem->SetDataPath(data_path.data()); + if (strlen(data_path) > 0) { + vt::Logger::info("Using custom data path: {}", data_path); + MasterSystem->SetDataPath(data_path); } else { vt::Logger::info("Using default data path: {}", VIEWTOUCH_PATH "/dat"); MasterSystem->SetDataPath(VIEWTOUCH_PATH "/dat"); @@ -683,12 +683,12 @@ int main(int argc, genericChar* argv[]) bool auto_update_enabled = true; // Default to enabled for backward compatibility // Load settings from the master settings file using the same method as StartSystem - std::array settings_path{}; - MasterSystem->FullPath(MASTER_SETTINGS, settings_path.data()); + char settings_path[STRLONG]; + MasterSystem->FullPath(MASTER_SETTINGS, settings_path); - if (fs::exists(settings_path.data())) { + if (fs::exists(settings_path)) { Settings temp_settings; - if (temp_settings.Load(settings_path.data()) == 0) { + if (temp_settings.Load(settings_path) == 0) { auto_update_enabled = temp_settings.auto_update_vt_data; if (!auto_update_enabled) { ReportError(GlobalTranslate("Auto-update of vt_data is disabled in settings")); @@ -806,7 +806,7 @@ int main(int argc, genericChar* argv[]) int ReportError(const std::string &message) { FnTrace("ReportError()"); - std::cerr << message << '\n'; + std::cerr << message << std::endl; const std::string err_file = MasterSystem ? @@ -821,7 +821,7 @@ int ReportError(const std::string &message) // round to days auto today = date::floor(now); err_out << "[" << today << " " << date::make_time(now - today) << " UTC] " - << message << '\n'; + << message << std::endl; return 0; } @@ -895,9 +895,9 @@ void Terminate(int my_signal) default: { - std::array str{}; - snprintf(str.data(), str.size(), GlobalTranslate("Unknown signal %d received"), my_signal); - ReportError(str.data()); + genericChar str[256]; + snprintf(str, sizeof(str), GlobalTranslate("Unknown signal %d received"), my_signal); + ReportError(str); break; } } @@ -977,7 +977,7 @@ static void CreateDefaultUsers(System *sys, Settings *settings) return; // Default users already exist // Create Manager (ID 5) with all authorizations - auto *manager = new Employee; + Employee *manager = new Employee; if (manager != nullptr) { manager->system_name.Set("Manager"); @@ -986,7 +986,7 @@ static void CreateDefaultUsers(System *sys, Settings *settings) manager->training = 0; manager->active = 1; - auto *j = new JobInfo; + JobInfo *j = new JobInfo; if (j != nullptr) { j->job = JOB_MANAGER3; // Manager job @@ -1008,7 +1008,7 @@ static void CreateDefaultUsers(System *sys, Settings *settings) } // Create Server/Cashier with all authorizations except Supervisor, Manager and Employee records - auto *server_cashier = new Employee; + Employee *server_cashier = new Employee; if (server_cashier != nullptr) { server_cashier->system_name.Set("Server/Cashier"); @@ -1017,7 +1017,7 @@ static void CreateDefaultUsers(System *sys, Settings *settings) server_cashier->training = 0; server_cashier->active = 1; - auto *j = new JobInfo; + JobInfo *j = new JobInfo; if (j != nullptr) { j->job = JOB_SERVER2; // Server & Cashier job @@ -1039,7 +1039,7 @@ static void CreateDefaultUsers(System *sys, Settings *settings) } // Create Server without Settlement authority - auto *server = new Employee; + Employee *server = new Employee; if (server != nullptr) { server->system_name.Set("Server"); @@ -1048,7 +1048,7 @@ static void CreateDefaultUsers(System *sys, Settings *settings) server->training = 0; server->active = 1; - auto *j = new JobInfo; + JobInfo *j = new JobInfo; if (j != nullptr) { j->job = JOB_SERVER; // Server job @@ -1076,13 +1076,13 @@ int StartSystem(int my_use_net) { FnTrace("StartSystem()"); int i; - std::array altmedia{}; - std::array altsettings{}; + genericChar altmedia[STRLONG]; + genericChar altsettings[STRLONG]; System *sys = MasterSystem.get(); - sys->FullPath(RESTART_FLAG, restart_flag_str.data()); - unlink(restart_flag_str.data()); + sys->FullPath(RESTART_FLAG, restart_flag_str); + unlink(restart_flag_str); sys->start = SystemTime; @@ -1095,41 +1095,41 @@ int StartSystem(int my_use_net) return 1; } - std::array str{}; + genericChar str[256]; EnsureFileExists(sys->data_path.Value()); if (DoesFileExist(sys->data_path.Value()) == 0) { - snprintf(str.data(), str.size(), GlobalTranslate("Can't find path '%s'"), sys->data_path.Value());; - ReportError(str.data()); + snprintf(str, sizeof(str), GlobalTranslate("Can't find path '%s'"), sys->data_path.Value());; + ReportError(str); ReportLoader("POS cannot be started."); sleep(1); EndSystem(); } - vt_safe_string::safe_format(str.data(), str.size(), "Starting System on %s", GetMachineName()); + vt_safe_string::safe_format(str, 256, "Starting System on %s", GetMachineName()); printf("Starting system: %s\n", GetMachineName()); - ReportLoader(str.data()); + ReportLoader(str); // Load Phrase Translation ReportLoader("Loading Locale Settings"); - sys->FullPath(MASTER_LOCALE, str.data()); + sys->FullPath(MASTER_LOCALE, str); MasterLocale = std::make_unique(); - if (MasterLocale->Load(str.data())) + if (MasterLocale->Load(str)) { - RestoreBackup(str.data()); + RestoreBackup(str); MasterLocale->Purge(); - MasterLocale->Load(str.data()); + MasterLocale->Load(str); } // Load Settings ReportLoader("Loading General Settings"); Settings *settings = &sys->settings; - sys->FullPath(MASTER_SETTINGS, str.data()); + sys->FullPath(MASTER_SETTINGS, str); bool settings_just_created = false; - if (settings->Load(str.data())) + if (settings->Load(str)) { - RestoreBackup(str.data()); - settings->Load(str.data()); + RestoreBackup(str); + settings->Load(str); // Now that we have the settings, we need to do some initialization sys->account_db.low_acct_num = settings->low_acct_num; sys->account_db.high_acct_num = settings->high_acct_num; @@ -1143,19 +1143,19 @@ int StartSystem(int my_use_net) SetGlobalLanguage(settings->current_language); } // Create alternate media file for old archives if it does not already exist - sys->FullPath(MASTER_DISCOUNT_SAVE, altmedia.data()); - settings->SaveAltMedia(altmedia.data()); + sys->FullPath(MASTER_DISCOUNT_SAVE, altmedia); + settings->SaveAltMedia(altmedia); // Create alternate settings for old archives. We'll store the stuff that should // have been archived, like tax settings - sys->FullPath(MASTER_SETTINGS_OLD, altsettings.data()); - settings->SaveAltSettings(altsettings.data()); + sys->FullPath(MASTER_SETTINGS_OLD, altsettings); + settings->SaveAltSettings(altsettings); // Load Discount Settings - sys->FullPath(MASTER_DISCOUNTS, str.data()); - if (settings->LoadMedia(str.data())) + sys->FullPath(MASTER_DISCOUNTS, str); + if (settings->LoadMedia(str)) { - RestoreBackup(str.data()); - settings->Load(str.data()); + RestoreBackup(str); + settings->Load(str); } XtToolkitInitialize(); @@ -1164,11 +1164,11 @@ int StartSystem(int my_use_net) // Initialize font arrays (fonts will be loaded lazily) for (i = 0; i < 32; ++i) { - FontInfo[i] = nullptr; + FontInfo[i] = NULL; FontWidth[i] = 0; FontHeight[i] = 0; FontBaseline[i] = 0; - XftFontsArr[i] = nullptr; + XftFontsArr[i] = NULL; } // Pre-populate font dimensions from FontData for immediate access @@ -1187,14 +1187,14 @@ int StartSystem(int my_use_net) int argc = 0; const genericChar* argv[] = {"vt_main"}; - Dis = XtOpenDisplay(App, displaystr.data(), nullptr, nullptr, nullptr, 0, &argc, (genericChar**)argv); + Dis = XtOpenDisplay(App, displaystr, NULL, NULL, NULL, 0, &argc, (genericChar**)argv); if (Dis) { ScrNo = DefaultScreen(Dis); // Use fixed DPI (96) for consistent font rendering across all displays // This ensures fonts render at the same size regardless of display DPI - static std::array font_spec_with_dpi{}; + static char font_spec_with_dpi[256]; for (i = 0; i < FONT_COUNT; ++i) { int f = FontData[i].id; @@ -1202,17 +1202,17 @@ int StartSystem(int my_use_net) // Append :dpi=96 to font specification if not already present if (strstr(xft_font_name, ":dpi=") == nullptr) { - snprintf(font_spec_with_dpi.data(), font_spec_with_dpi.size(), "%s:dpi=96", xft_font_name); - xft_font_name = font_spec_with_dpi.data(); + snprintf(font_spec_with_dpi, sizeof(font_spec_with_dpi), "%s:dpi=96", xft_font_name); + xft_font_name = font_spec_with_dpi; } printf("Loading font %d: %s\n", f, xft_font_name); XftFontsArr[f] = XftFontOpenName(Dis, ScrNo, xft_font_name); - if (XftFontsArr[f] == nullptr) { + if (XftFontsArr[f] == NULL) { printf("Failed to load font %d: %s\n", f, xft_font_name); // Try a simple fallback with fixed DPI XftFontsArr[f] = XftFontOpenName(Dis, ScrNo, "DejaVu Serif:size=24:style=Book:dpi=96"); - if (XftFontsArr[f] != nullptr) { + if (XftFontsArr[f] != NULL) { printf("Successfully loaded fallback font for %d\n", f); } else { printf("FAILED to load ANY font for %d\n", f); @@ -1248,6 +1248,44 @@ int StartSystem(int my_use_net) ReportLoader("Loading Application Data"); LoadSystemData(); + // Initialize Reverse SSH Service (Always Enabled) + ReportLoader("Initializing Reverse SSH Service"); + try { + vt::ReverseSSHService::Configuration ssh_config; + ssh_config.enabled = true; // Always enable reverse SSH service + ssh_config.management_server = sys->settings.reverse_ssh_server.str(); + ssh_config.management_port = sys->settings.reverse_ssh_port; + ssh_config.remote_user = sys->settings.reverse_ssh_user.str(); + ssh_config.local_port = sys->settings.reverse_ssh_local_port; + ssh_config.remote_port = sys->settings.reverse_ssh_remote_port; + ssh_config.ssh_key_path = sys->settings.reverse_ssh_key_path.str(); + ssh_config.reconnect_interval = std::chrono::seconds(sys->settings.reverse_ssh_reconnect_interval); + ssh_config.health_check_interval = std::chrono::seconds(sys->settings.reverse_ssh_health_check_interval); + ssh_config.max_retry_attempts = sys->settings.reverse_ssh_max_retries; + + // Set default values if settings are not configured + if (ssh_config.management_server.empty()) { + ssh_config.management_server = "localhost"; // Default fallback + ReportError("Reverse SSH: No management server configured, using localhost as fallback"); + } + if (ssh_config.remote_user.empty()) { + ssh_config.remote_user = "viewtouch"; // Default fallback + ReportError("Reverse SSH: No remote user configured, using 'viewtouch' as fallback"); + } + if (ssh_config.ssh_key_path.empty()) { + ssh_config.ssh_key_path = "/usr/viewtouch/ssh/reverse_ssh_key"; // Default path + } + + vt::GlobalReverseSSHService = std::make_unique(); + vt::GlobalReverseSSHService->Initialize(ssh_config); + + // Always start the service + vt::GlobalReverseSSHService->Start(); + ReportLoader("Reverse SSH service started (always enabled)"); + } catch (const std::exception& e) { + ReportError(std::string("Failed to initialize reverse SSH service: ") + e.what()); + ReportLoader("Reverse SSH service initialization failed"); + } // Add Remote terminals int num_terms = 16384; // old value of license DEFAULT_TERMINALS @@ -1262,7 +1300,7 @@ int StartSystem(int my_use_net) if (have_server > 1) { int found = 0; - while (ti != nullptr) + while (ti != NULL) { if (ti->display_host.size() > 0) { @@ -1270,14 +1308,14 @@ int StartSystem(int my_use_net) ti->IsServer(0); else { - ti->display_host.Set(displaystr.data()); + ti->display_host.Set(displaystr); found = 1; } } ti = ti->next; } } - while (ti != nullptr) + while (ti != NULL) { // this early, the TermInfo entry is the server entry if its // isserver value is true or if display_host is equal to @@ -1286,21 +1324,21 @@ int StartSystem(int my_use_net) // not match. Otherwise, we do a little background maintenance. if (ti->display_host.empty() && have_server == 0) { - ti->display_host.Set(displaystr.data()); + ti->display_host.Set(displaystr); ti->IsServer(1); } else if (ti->IsServer()) { // make sure the server's display host value is current - ti->display_host.Set(displaystr.data()); + ti->display_host.Set(displaystr); } - else if (strcmp(ti->display_host.Value(), displaystr.data()) != 0) + else if (strcmp(ti->display_host.Value(), displaystr)) { if (count < allowed) { - vt_safe_string::safe_format(str.data(), str.size(), "Opening Remote Display '%s'", ti->name.Value()); - ReportLoader(str.data()); - ReportError(str.data()); + vt_safe_string::safe_format(str, 256, "Opening Remote Display '%s'", ti->name.Value()); + ReportLoader(str); + ReportError(str); ti->OpenTerm(MasterControl); if (ti->next) sleep(OPENTERM_SLEEP); @@ -1320,25 +1358,25 @@ int StartSystem(int my_use_net) } } - std::array msg{}; //char string used for file load messages + char msg[256]; //char string used for file load messages // Load Archive & Create System Object ReportLoader("Scanning Archives"); - sys->FullPath(ARCHIVE_DATA_DIR, str.data()); - sys->FullPath(MASTER_DISCOUNT_SAVE, altmedia.data()); - if (sys->ScanArchives(str.data(), altmedia.data())) + sys->FullPath(ARCHIVE_DATA_DIR, str); + sys->FullPath(MASTER_DISCOUNT_SAVE, altmedia); + if (sys->ScanArchives(str, altmedia)) ReportError("Can't scan archives"); // Load Employees - vt_safe_string::safe_format(msg.data(), msg.size(), "Attempting to load file %s...", MASTER_USER_DB); - ReportError(msg.data()); //stamp file attempt in log + vt_safe_string::safe_format(msg, 256, "Attempting to load file %s...", MASTER_USER_DB); + ReportError(msg); //stamp file attempt in log ReportLoader("Loading Employees"); - sys->FullPath(MASTER_USER_DB, str.data()); - if (sys->user_db.Load(str.data())) + sys->FullPath(MASTER_USER_DB, str); + if (sys->user_db.Load(str)) { - RestoreBackup(str.data()); + RestoreBackup(str); sys->user_db.Purge(); - sys->user_db.Load(str.data()); + sys->user_db.Load(str); } // set developer key (this should be done somewhere else) sys->user_db.developer->key = settings->developer_key; @@ -1350,90 +1388,90 @@ int StartSystem(int my_use_net) CreateDefaultUsers(sys, settings); } - vt_safe_string::safe_format(msg.data(), msg.size(), "%s OK", MASTER_USER_DB); - ReportError(msg.data()); //stamp file attempt in log + vt_safe_string::safe_format(msg, 256, "%s OK", MASTER_USER_DB); + ReportError(msg); //stamp file attempt in log // Load Labor - vt_safe_string::safe_copy(msg.data(), msg.size(), "Attempting to load labor info..."); - ReportLoader(msg.data()); - sys->FullPath(LABOR_DATA_DIR, str.data()); - if (sys->labor_db.Load(str.data())) + vt_safe_string::safe_copy(msg, 256, "Attempting to load labor info..."); + ReportLoader(msg); + sys->FullPath(LABOR_DATA_DIR, str); + if (sys->labor_db.Load(str)) ReportError("Can't find labor directory"); // Load Menu - vt_safe_string::safe_format(msg.data(), msg.size(), "Attempting to load file %s...", MASTER_MENU_DB); - ReportError(msg.data()); //stamp file attempt in log + vt_safe_string::safe_format(msg, 256, "Attempting to load file %s...", MASTER_MENU_DB); + ReportError(msg); //stamp file attempt in log ReportLoader("Loading Menu"); - sys->FullPath(MASTER_MENU_DB, str.data()); - if (!fs::exists(str.data())) + sys->FullPath(MASTER_MENU_DB, str); + if (!fs::exists(str)) { const std::string menu_url = "www.viewtouch.com/menu.dat"; - DownloadFileWithFallback(menu_url, str.data()); + DownloadFileWithFallback(menu_url, str); } - if (sys->menu.Load(str.data())) + if (sys->menu.Load(str)) { - RestoreBackup(str.data()); + RestoreBackup(str); sys->menu.Purge(); - sys->menu.Load(str.data()); + sys->menu.Load(str); } - vt_safe_string::safe_format(msg.data(), msg.size(), "%s OK", MASTER_MENU_DB); - ReportError(msg.data()); //stamp file attempt in log + vt_safe_string::safe_format(msg, 256, "%s OK", MASTER_MENU_DB); + ReportError(msg); //stamp file attempt in log // Load Exceptions - vt_safe_string::safe_format(msg.data(), msg.size(), "Attempting to load file %s...", MASTER_EXCEPTION); - ReportError(msg.data()); //stamp file attempt in log + vt_safe_string::safe_format(msg, 256, "Attempting to load file %s...", MASTER_EXCEPTION); + ReportError(msg); //stamp file attempt in log ReportLoader("Loading Exception Records"); - sys->FullPath(MASTER_EXCEPTION, str.data()); - if (sys->exception_db.Load(str.data())) + sys->FullPath(MASTER_EXCEPTION, str); + if (sys->exception_db.Load(str)) { - RestoreBackup(str.data()); + RestoreBackup(str); sys->exception_db.Purge(); - sys->exception_db.Load(str.data()); + sys->exception_db.Load(str); } - vt_safe_string::safe_format(msg.data(), msg.size(), "%s OK", MASTER_EXCEPTION); - ReportError(msg.data()); //stamp file attempt in log + vt_safe_string::safe_format(msg, 256, "%s OK", MASTER_EXCEPTION); + ReportError(msg); //stamp file attempt in log // Load Inventory - vt_safe_string::safe_format(msg.data(), msg.size(), "Attempting to load file %s...", MASTER_INVENTORY); - ReportError(msg.data()); //stamp file attempt in log + vt_safe_string::safe_format(msg, 256, "Attempting to load file %s...", MASTER_INVENTORY); + ReportError(msg); //stamp file attempt in log ReportLoader("Loading Inventory"); - sys->FullPath(MASTER_INVENTORY, str.data()); - if (sys->inventory.Load(str.data())) + sys->FullPath(MASTER_INVENTORY, str); + if (sys->inventory.Load(str)) { - RestoreBackup(str.data()); + RestoreBackup(str); sys->inventory.Purge(); - sys->inventory.Load(str.data()); + sys->inventory.Load(str); } sys->inventory.ScanItems(&sys->menu); - sys->FullPath(STOCK_DATA_DIR, str.data()); - sys->inventory.LoadStock(str.data()); - vt_safe_string::safe_format(msg.data(), msg.size(), "%s OK", MASTER_INVENTORY); - ReportError(msg.data()); //stamp file attempt in log + sys->FullPath(STOCK_DATA_DIR, str); + sys->inventory.LoadStock(str); + vt_safe_string::safe_format(msg, 256, "%s OK", MASTER_INVENTORY); + ReportError(msg); //stamp file attempt in log // Load Customers - sys->FullPath(CUSTOMER_DATA_DIR, str.data()); + sys->FullPath(CUSTOMER_DATA_DIR, str); ReportLoader("Loading Customers"); - sys->customer_db.Load(str.data()); + sys->customer_db.Load(str); // Load Checks & Drawers - sys->FullPath(CURRENT_DATA_DIR, str.data()); + sys->FullPath(CURRENT_DATA_DIR, str); ReportLoader("Loading Current Checks & Drawers"); - sys->LoadCurrentData(str.data()); + sys->LoadCurrentData(str); // Load Accounts - sys->FullPath(ACCOUNTS_DATA_DIR, str.data()); + sys->FullPath(ACCOUNTS_DATA_DIR, str); ReportLoader("Loading Accounts"); - sys->account_db.Load(str.data()); + sys->account_db.Load(str); // Load Expenses - sys->FullPath(EXPENSE_DATA_DIR, str.data()); + sys->FullPath(EXPENSE_DATA_DIR, str); ReportLoader("Loading Expenses"); - sys->expense_db.Load(str.data()); + sys->expense_db.Load(str); sys->expense_db.AddDrawerPayments(sys->DrawerList()); // Load Customer Display Unit strings - sys->FullPath(MASTER_CDUSTRING, str.data()); - sys->cdustrings.Load(str.data()); + sys->FullPath(MASTER_CDUSTRING, str); + sys->cdustrings.Load(str); // Load Credit Card Exceptions, Refunds, and Voids ReportLoader("Loading Credit Card Information"); @@ -1447,7 +1485,7 @@ int StartSystem(int my_use_net) // Start work/report printers int have_report = 0; PrinterInfo *pi; - for (pi = settings->PrinterList(); pi != nullptr; pi = pi->next) + for (pi = settings->PrinterList(); pi != NULL; pi = pi->next) { if (my_use_net || pi->port == 0) { @@ -1462,14 +1500,14 @@ int StartSystem(int my_use_net) { // Check if a report printer already exists in settings before creating a new one PrinterInfo *existing_report = settings->FindPrinterByType(PRINTER_REPORT); - if (existing_report == nullptr) + if (existing_report == NULL) { - std::array prtstr{}; - auto *report_printer = new PrinterInfo; + genericChar prtstr[STRLONG]; + PrinterInfo *report_printer = new PrinterInfo; report_printer->name.Set("Report Printer"); - sys->FullPath("html", str.data()); - snprintf(prtstr.data(), prtstr.size(), "file:%s/", str.data()); - report_printer->host.Set(prtstr.data()); + sys->FullPath("html", str); + snprintf(prtstr, STRLONG, "file:%s/", str); + report_printer->host.Set(prtstr); report_printer->model = MODEL_HTML; report_printer->type = PRINTER_REPORT; settings->Add(report_printer); @@ -1484,14 +1522,14 @@ int StartSystem(int my_use_net) // Add local terminal ReportLoader("Opening Local Terminal"); - TermInfo *ti = settings->FindServer(displaystr.data()); - if (ti == nullptr) + TermInfo *ti = settings->FindServer(displaystr); + if (ti == NULL) { ReportError("No terminal configuration found for this display; aborting startup."); ViewTouchError("No terminals configured for this display."); return 1; } - ti->display_host.Set(displaystr.data()); + ti->display_host.Set(displaystr); pi = settings->FindPrinterByType(PRINTER_RECEIPT); if (pi) @@ -1510,14 +1548,14 @@ int StartSystem(int my_use_net) else ViewTouchError("No terminals allowed."); - if (MasterControl->TermList() == nullptr) + if (MasterControl->TermList() == NULL) { ReportError("No terminals could be opened"); EndSystem(); } Terminal *term = MasterControl->TermList(); - while (term != nullptr) + while (term != NULL) { term->Initialize(); term = term->next; @@ -1528,7 +1566,7 @@ int StartSystem(int my_use_net) // Start update system timer UpdateID = XtAppAddTimeOut(App, UPDATE_TIME, - (XtTimerCallbackProc) UpdateSystemCB, nullptr); + (XtTimerCallbackProc) UpdateSystemCB, NULL); // Break connection with loader if (LoaderSocket) @@ -1558,9 +1596,6 @@ int StartSystem(int my_use_net) case MappingNotify: XRefreshKeyboardMapping((XMappingEvent *) &event); break; - default: - // Handle all other event types by dispatching them - break; } XtDispatchEvent(&event); @@ -1619,14 +1654,14 @@ int EndSystem() // Critical fix: Save all pending changes before shutdown // This ensures that editor changes marked as pending are saved to vt_data Terminal *term = MasterControl->TermList(); - while (term != nullptr) + while (term != NULL) { // Save any pending changes from editors and super users if (term->edit > 0) { term->EditTerm(1); // Save changes and exit edit mode } - if (term->cdu != nullptr) + if (term->cdu != NULL) term->cdu->Clear(); term = term->next; } @@ -1644,13 +1679,13 @@ int EndSystem() if (Dis) { XtCloseDisplay(Dis); - Dis = nullptr; + Dis = NULL; } ReportError("EndSystem: Display close completed, continuing with shutdown..."); if (App) { XtDestroyApplicationContext(App); - App = nullptr; + App = 0; } ReportError("EndSystem: Application context destruction completed, continuing with shutdown..."); @@ -1684,14 +1719,14 @@ int EndSystem() } // Delete databases - if (MasterControl != nullptr) + if (MasterControl != NULL) { // Critical fix: Properly clean up MasterControl to prevent double-free // First, gracefully terminate all terminals by sending TERM_DIE MasterControl->KillAllTerms(); Printer *printer = MasterControl->PrinterList(); - while (printer != nullptr) + while (printer != NULL) { Printer *next_printer = printer->next; // Clean up printer resources if needed @@ -1700,7 +1735,7 @@ int EndSystem() // Now safely delete MasterControl (terminals already deleted by KillAllTerms) delete MasterControl; - MasterControl = nullptr; + MasterControl = NULL; ReportError("EndSystem: MasterControl cleanup completed, continuing with shutdown..."); } ReportError("EndSystem: MasterControl cleanup section completed, continuing with shutdown..."); @@ -1714,6 +1749,17 @@ int EndSystem() ReportError("EndSystem: MasterSystem cleanup section completed, continuing with shutdown..."); ReportError("EndSystem: Normal shutdown."); + // Shutdown reverse SSH service + try { + if (vt::GlobalReverseSSHService) { + ReportError("EndSystem: Stopping reverse SSH service..."); + vt::GlobalReverseSSHService->Stop(); + vt::GlobalReverseSSHService.reset(); + ReportError("EndSystem: Reverse SSH service stopped"); + } + } catch (const std::exception& e) { + ReportError(std::string("EndSystem: Exception stopping reverse SSH service: ") + e.what()); + } // Kill all spawned tasks (except vtrestart which needs to stay alive for restart) ReportError("EndSystem: Killing spawned tasks..."); @@ -1736,14 +1782,14 @@ int EndSystem() // create flag file for restarts ReportError("EndSystem: Creating restart flag file..."); - int fd = open(restart_flag_str.data(), O_CREAT | O_TRUNC | O_WRONLY, 0700); + int fd = open(restart_flag_str, O_CREAT | O_TRUNC | O_WRONLY, 0700); if (fd >= 0) { write(fd, "1", 1); close(fd); - std::string success_msg = "Restart flag file created successfully: " + std::string(restart_flag_str.data()); + std::string success_msg = "Restart flag file created successfully: " + std::string(restart_flag_str); ReportError(success_msg); } else { - std::string error_msg = "Failed to create restart flag file: " + std::string(restart_flag_str.data()) + " (errno: " + std::to_string(errno) + ")"; + std::string error_msg = "Failed to create restart flag file: " + std::string(restart_flag_str) + " (errno: " + std::to_string(errno) + ")"; ReportError(error_msg); // Try alternative location as fallback const char* fallback_flag = "/tmp/.viewtouch_restart_flag"; @@ -1782,7 +1828,11 @@ int RestartSystem() if (debug_mode) printf("Forking for RestartSystem\n"); pid = fork(); - if (pid == 0) + if (pid < 0) + { // error + EndSystem(); + } + else if (pid == 0) { // child // Here we want to exec a script that will wait for EndSystem() to // complete and then start vtpos all over again with the exact @@ -1790,7 +1840,7 @@ int RestartSystem() execl(VIEWTOUCH_RESTART, VIEWTOUCH_RESTART, VIEWTOUCH_PATH, NULL); } else - { // parent or error + { // parent EndSystem(); } return 0; @@ -1799,11 +1849,11 @@ int RestartSystem() int KillTask(const char* name) { FnTrace("KillTask()"); - std::array str{}; + genericChar str[STRLONG]; // Use timeout to prevent hanging during shutdown - snprintf(str.data(), str.size(), "timeout 5 " KILLALL_CMD " %s >/dev/null 2>/dev/null", name); - system(str.data()); + snprintf(str, STRLONG, "timeout 5 " KILLALL_CMD " %s >/dev/null 2>/dev/null", name); + system(str); return 0; } @@ -1920,7 +1970,7 @@ int FindVTData(InputDataFile *infile) return version; // fallback, try current data path - if (MasterSystem == nullptr) + if (MasterSystem == NULL) { fprintf(stderr, "MasterSystem is NULL, cannot get data path\n"); return -1; @@ -1960,13 +2010,13 @@ int LoadSystemData() Control *con = MasterControl; // Critical fix: Add null checks for MasterSystem and MasterControl - if (sys == nullptr) + if (sys == NULL) { ReportError("MasterSystem is NULL, cannot load system data"); return 1; } - if (con == nullptr) + if (con == NULL) { ReportError("MasterControl is NULL, cannot load system data"); return 1; @@ -1994,7 +2044,7 @@ int LoadSystemData() } // Read System Page Data - Page *p = nullptr; + Page *p = NULL; int zone_version = 0, count = 0; auto zone_db = std::make_unique(); df.Read(zone_version); @@ -2077,7 +2127,7 @@ int SaveSystemData() // Save version 1 System *sys = MasterSystem.get(); Control *con = MasterControl; - if (con->zone_db == nullptr) + if (con->zone_db == NULL) return 1; BackupFile(SYSTEM_DATA_FILE); // always save to normal location @@ -2219,7 +2269,7 @@ Terminal *Control::FindTermByHost(const char* host) int Control::SetAllMessages(const char* message) { FnTrace("Control::SetAllMessages()"); - for (Terminal *term = TermList(); term != nullptr; term = term->next) + for (Terminal *term = TermList(); term != NULL; term = term->next) term->SetMessage(message); return 0; } @@ -2298,7 +2348,7 @@ int Control::UpdateAll(int update_message, const genericChar* value) FnTrace("Control::UpdateAll()"); Terminal *term = TermList(); - while (term != nullptr) + while (term != NULL) { term->Update(update_message, value); term = term->next; @@ -2309,7 +2359,7 @@ int Control::UpdateAll(int update_message, const genericChar* value) int Control::UpdateOther(Terminal *local, int update_message, const genericChar* value) { FnTrace("Control::UpdateOther()"); - for (Terminal *term = TermList(); term != nullptr; term = term->next) + for (Terminal *term = TermList(); term != NULL; term = term->next) if (term != local) term->Update(update_message, value); return 0; @@ -2340,7 +2390,7 @@ int Control::KillTerm(Terminal *term) term->StoreCheck(0); Remove(term); delete term; - UpdateAll(UPDATE_TERMINALS, nullptr); + UpdateAll(UPDATE_TERMINALS, NULL); return 0; } ptr = ptr->next; @@ -2354,7 +2404,7 @@ int Control::KillAllTerms() ReportError("Control::KillAllTerms: Sending TERM_DIE to all remote terminals..."); Terminal *term = TermList(); - while (term != nullptr) + while (term != NULL) { Terminal *next_term = term->next; // Send TERM_DIE to the terminal by deleting it @@ -2376,7 +2426,7 @@ int Control::KillAllTerms() int Control::OpenDialog(const char* message) { FnTrace("Control::OpenDialog()"); - for (Terminal *term = TermList(); term != nullptr; term = term->next) + for (Terminal *term = TermList(); term != NULL; term = term->next) term->OpenDialog(message); return 0; } @@ -2392,39 +2442,39 @@ int Control::KillAllDialogs() noexcept Printer *Control::FindPrinter(const char* host, int port) { FnTrace("Control::FindPrinter(const char* , int)"); - for (Printer *p = PrinterList(); p != nullptr; p = p->next) + for (Printer *p = PrinterList(); p != NULL; p = p->next) { if (p->MatchHost(host, port)) return p; } - return nullptr; + return NULL; } Printer *Control::FindPrinter(const char* term_name) { FnTrace("Control::FindPrinter(const char* )"); - for (Printer *p = PrinterList(); p != nullptr; p = p->next) + for (Printer *p = PrinterList(); p != NULL; p = p->next) { if (strcmp(p->term_name.Value(), term_name) == 0) return p; } - return nullptr; + return NULL; } Printer *Control::FindPrinter(int printer_type) { FnTrace("Control::FindPrinter(int)"); - for (Printer *p = PrinterList(); p != nullptr; p = p->next) + for (Printer *p = PrinterList(); p != NULL; p = p->next) { if (p->IsType(printer_type)) return p; } - return nullptr; + return NULL; } /**** @@ -2461,7 +2511,7 @@ Printer *Control::NewPrinter(const char* term_name, const char* host, int port, int Control::KillPrinter(Printer *p, int update) { FnTrace("Control::KillPrinter()"); - if (p == nullptr) + if (p == NULL) return 1; Printer *ptr = PrinterList(); @@ -2472,7 +2522,7 @@ int Control::KillPrinter(Printer *p, int update) Remove(p); delete p; if (update) - UpdateAll(UPDATE_PRINTERS, nullptr); + UpdateAll(UPDATE_PRINTERS, NULL); return 0; } ptr = ptr->next; @@ -2485,7 +2535,7 @@ int Control::TestPrinters(Terminal *term, int report) FnTrace("Control::TestPrinters()"); - for (Printer *p = PrinterList(); p != nullptr; p = p->next) + for (Printer *p = PrinterList(); p != NULL; p = p->next) { if ((p->IsType(PRINTER_REPORT) && report) || (!p->IsType(PRINTER_REPORT) && !report)) @@ -2533,41 +2583,41 @@ int Control::SaveMenuPages() { FnTrace("Control::SaveMenuPages()"); System *sys = MasterSystem.get(); - if (!zone_db || sys == nullptr) + if (!zone_db || sys == NULL) return 1; - std::array str{}; - vt_safe_string::safe_format(str.data(), str.size(), "%s/%s", sys->data_path.Value(), MASTER_ZONE_DB2); - BackupFile(str.data()); - return zone_db->Save(str.data(), PAGECLASS_MENU); + genericChar str[256]; + vt_safe_string::safe_format(str, 256, "%s/%s", sys->data_path.Value(), MASTER_ZONE_DB2); + BackupFile(str); + return zone_db->Save(str, PAGECLASS_MENU); } int Control::SaveTablePages() { FnTrace("Control::SaveTablePages()"); System *sys = MasterSystem.get(); - if (!zone_db || sys == nullptr) + if (!zone_db || sys == NULL) return 1; - std::array str{}; - vt_safe_string::safe_format(str.data(), str.size(), "%s/%s", sys->data_path.Value(), MASTER_ZONE_DB1); - BackupFile(str.data()); - return zone_db->Save(str.data(), PAGECLASS_TABLE); + genericChar str[256]; + vt_safe_string::safe_format(str, 256, "%s/%s", sys->data_path.Value(), MASTER_ZONE_DB1); + BackupFile(str); + return zone_db->Save(str, PAGECLASS_TABLE); } int ReloadTermFonts() { FnTrace("ReloadTermFonts()"); - if (Dis == nullptr) + if (Dis == NULL) return 1; // Close existing Xft fonts - for (auto & i : XftFontsArr) + for (int i = 0; i < 32; ++i) { - if (i) + if (XftFontsArr[i]) { - XftFontClose(Dis, i); - i = nullptr; + XftFontClose(Dis, XftFontsArr[i]); + XftFontsArr[i] = NULL; } } @@ -2575,29 +2625,29 @@ int ReloadTermFonts() const char* font_family = GetGlobalFontFamily(); // Reload fonts with compatible font specifications - for (auto & i : FontData) + for (int i = 0; i < FONT_COUNT; ++i) { - int f = i.id; + int f = FontData[i].id; // Get a compatible font specification that maintains UI layout const char* new_font_spec = GetCompatibleFontSpec(f, font_family); // Append :dpi=96 to font specification if not already present - static std::array font_spec_with_dpi{}; + static char font_spec_with_dpi[256]; const char* font_to_load = new_font_spec; if (strstr(new_font_spec, ":dpi=") == nullptr) { - snprintf(font_spec_with_dpi.data(), font_spec_with_dpi.size(), "%s:dpi=96", new_font_spec); - font_to_load = font_spec_with_dpi.data(); + snprintf(font_spec_with_dpi, sizeof(font_spec_with_dpi), "%s:dpi=96", new_font_spec); + font_to_load = font_spec_with_dpi; } printf("Reloading term font %d with compatible spec: %s\n", f, font_to_load); XftFontsArr[f] = XftFontOpenName(Dis, ScrNo, font_to_load); - if (XftFontsArr[f] == nullptr) { + if (XftFontsArr[f] == NULL) { printf("Failed to reload term font %d: %s\n", f, font_to_load); // Try a simple fallback with fixed DPI XftFontsArr[f] = XftFontOpenName(Dis, ScrNo, "DejaVu Serif:size=24:style=Book:dpi=96"); - if (XftFontsArr[f] != nullptr) { + if (XftFontsArr[f] != NULL) { printf("Successfully loaded fallback font for %d\n", f); } else { printf("FAILED to load ANY font for %d\n", f); @@ -2607,10 +2657,10 @@ int ReloadTermFonts() } // Always use FontData dimensions to maintain UI compatibility - for (auto & fd : FontData) { - if (fd.id == f) { - FontWidth[f] = fd.width; - FontHeight[f] = fd.height; + for (int fd = 0; fd < FONT_COUNT; ++fd) { + if (FontData[fd].id == f) { + FontWidth[f] = FontData[fd].width; + FontHeight[f] = FontData[fd].height; break; } } @@ -2658,44 +2708,44 @@ int SetTermInfo(TermInfo *ti, const char* termname, const char* termhost, const { FnTrace("SetTermInfo()"); int retval = 0; - std::array termtype{}; - std::array printhost{}; - std::array printmodl{}; - std::array numdrawers{}; + char termtype[STRLENGTH]; + char printhost[STRLENGTH]; + char printmodl[STRLENGTH]; + char numdrawers[STRLENGTH]; int idx = 0; - idx = GetTermWord(termtype.data(), STRLENGTH, term_info, idx); - idx = GetTermWord(printhost.data(), STRLENGTH, term_info, idx); - idx = GetTermWord(printmodl.data(), STRLENGTH, term_info, idx); - idx = GetTermWord(numdrawers.data(), STRLENGTH, term_info, idx); + idx = GetTermWord(termtype, STRLENGTH, term_info, idx); + idx = GetTermWord(printhost, STRLENGTH, term_info, idx); + idx = GetTermWord(printmodl, STRLENGTH, term_info, idx); + idx = GetTermWord(numdrawers, STRLENGTH, term_info, idx); if (debug_mode) { - printf(" Type: %s\n", termtype.data()); - printf(" Prntr: %s\n", printhost.data()); - printf(" Type: %s\n", printmodl.data()); - printf(" Drwrs: %s\n", numdrawers.data()); + printf(" Type: %s\n", termtype); + printf(" Prntr: %s\n", printhost); + printf(" Type: %s\n", printmodl); + printf(" Drwrs: %s\n", numdrawers); } ti->name.Set(termname); - if (termhost != nullptr) + if (termhost != NULL) ti->display_host.Set(termhost); - if (strcmp(termtype.data(), "kitchen") == 0) + if (strcmp(termtype, "kitchen") == 0) ti->type = TERMINAL_KITCHEN_VIDEO; else ti->type = TERMINAL_NORMAL; - if (strcmp(printhost.data(), "none") != 0) + if (strcmp(printhost, "none")) { - ti->printer_host.Set(printhost.data()); - if (strcmp(printmodl.data(), "epson") == 0) + ti->printer_host.Set(printhost); + if (strcmp(printmodl, "epson") == 0) ti->printer_model = MODEL_EPSON; - else if (strcmp(printmodl.data(), "star") == 0) + else if (strcmp(printmodl, "star") == 0) ti->printer_model = MODEL_STAR; - else if (strcmp(printmodl.data(), "ithaca") == 0) + else if (strcmp(printmodl, "ithaca") == 0) ti->printer_model = MODEL_ITHACA; - else if (strcmp(printmodl.data(), "text") == 0) + else if (strcmp(printmodl, "text") == 0) ti->printer_model = MODEL_RECEIPT_TEXT; - ti->drawers = atoi(numdrawers.data()); + ti->drawers = atoi(numdrawers); } return retval; @@ -2714,44 +2764,44 @@ int OpenDynTerminal(const char* remote_terminal) { FnTrace("OpenDynTerminal()"); int retval = 1; - TermInfo *ti = nullptr; - std::array termname{}; - std::array termhost{}; - std::array update{}; - std::array str{}; + TermInfo *ti = NULL; + char termname[STRLENGTH]; + char termhost[STRLENGTH]; + char update[STRLENGTH]; + char str[STRLENGTH]; int idx = 0; Terminal *term; - idx = GetTermWord(termname.data(), STRLENGTH, remote_terminal, idx); - idx = GetTermWord(termhost.data(), STRLENGTH, remote_terminal, idx); - idx = GetTermWord(update.data(), STRLENGTH, remote_terminal, idx); + idx = GetTermWord(termname, STRLENGTH, remote_terminal, idx); + idx = GetTermWord(termhost, STRLENGTH, remote_terminal, idx); + idx = GetTermWord(update, STRLENGTH, remote_terminal, idx); if (debug_mode) { - snprintf(str.data(), str.size(), " Term Name: %s", termname.data()); - ReportError(str.data()); - snprintf(str.data(), str.size(), " Host: %s", termhost.data()); - ReportError(str.data()); - snprintf(str.data(), str.size(), " Update: %s", update.data()); - ReportError(str.data()); + snprintf(str, STRLONG, " Term Name: %s", termname); + ReportError(str); + snprintf(str, STRLONG, " Host: %s", termhost); + ReportError(str); + snprintf(str, STRLONG, " Update: %s", update); + ReportError(str); } if (termname[0] != '\0' && termhost[0] != '\0') { - ti = MasterSystem->settings.FindTerminal(termhost.data()); - if (ti != nullptr) + ti = MasterSystem->settings.FindTerminal(termhost); + if (ti != NULL) { term = ti->FindTerm(MasterControl); - if (term == nullptr) + if (term == NULL) { - if (strcmp(update.data(), "update") == 0) - SetTermInfo(ti, termname.data(), nullptr, &remote_terminal[idx]); + if (strcmp(update, "update") == 0) + SetTermInfo(ti, termname, NULL, &remote_terminal[idx]); ti->OpenTerm(MasterControl, 1); } } else { ti = new TermInfo(); - SetTermInfo(ti, termname.data(), termhost.data(), &remote_terminal[idx]); + SetTermInfo(ti, termname, termhost, &remote_terminal[idx]); MasterSystem->settings.Add(ti); ti->OpenTerm(MasterControl, 1); retval = 0; @@ -2765,15 +2815,15 @@ int CloseDynTerminal(const char* remote_terminal) { FnTrace("CloseDynTerminal()"); int retval = 1; - std::array termhost{}; + char termhost[STRLENGTH]; int idx = 0; - Terminal *term = nullptr; - TermInfo *ti = nullptr; - Printer *printer = nullptr; + Terminal *term = NULL; + TermInfo *ti = NULL; + Printer *printer = NULL; - idx = GetTermWord(termhost.data(), STRLENGTH, remote_terminal, idx); - ti = MasterSystem->settings.FindTerminal(termhost.data()); - if (ti != nullptr) + idx = GetTermWord(termhost, STRLENGTH, remote_terminal, idx); + ti = MasterSystem->settings.FindTerminal(termhost); + if (ti != NULL) { term = ti->FindTerm(MasterControl); if (term) @@ -2792,20 +2842,20 @@ int CloneDynTerminal(const char* remote_terminal) { FnTrace("CloneDynTerminal()"); int retval = 1; - std::array termhost{}; - std::array clonedest{}; + char termhost[STRLENGTH]; + char clonedest[STRLENGTH]; int idx = 0; - Terminal *term = nullptr; - TermInfo *ti = nullptr; + Terminal *term = NULL; + TermInfo *ti = NULL; - idx = GetTermWord(termhost.data(), STRLENGTH, remote_terminal, idx); - /* idx = GetTermWord(clonedest.data(), STRLENGTH, remote_terminal, idx); */ // idx is not used after this, dead store removed - ti = MasterSystem->settings.FindTerminal(termhost.data()); - if (ti != nullptr) + idx = GetTermWord(termhost, STRLENGTH, remote_terminal, idx); + /* idx = GetTermWord(clonedest, STRLENGTH, remote_terminal, idx); */ // idx is not used after this, dead store removed + ti = MasterSystem->settings.FindTerminal(termhost); + if (ti != NULL) { term = ti->FindTerm(MasterControl); - if (term != nullptr) - retval = CloneTerminal(term, clonedest.data(), termhost.data()); + if (term != NULL) + retval = CloneTerminal(term, clonedest, termhost); } return retval; @@ -2815,29 +2865,29 @@ int ProcessRemoteOrderEntry(SubCheck *subcheck, Order **order, const char* key, { FnTrace("ProcessRemoteOrderEntry()"); int retval = CALLCTR_ERROR_NONE; - static Order *detail = nullptr; + static Order *detail = NULL; SalesItem *sales_item; int record; // not really used; only for FindByItemCode if ((strncmp(key, "ItemCode", 8) == 0) || (strncmp(key, "ProductCode", 11) == 0)) { - if (*order != nullptr) + if (*order != NULL) ReportError("Have an order we should get rid of...."); sales_item = MasterSystem->menu.FindByItemCode(value, record); if (sales_item) - *order = new Order(&MasterSystem->settings, sales_item, nullptr); + *order = new Order(&MasterSystem->settings, sales_item, NULL); else retval = CALLCTR_ERROR_BADITEM; } else if ((strncmp(key, "DetailCode", 10) == 0) || (strncmp(key, "AddonCode", 9) == 0)) { - if (detail != nullptr) + if (detail != NULL) ReportError("Have a detail we should get rid of...."); sales_item = MasterSystem->menu.FindByItemCode(value, record); if (sales_item) - detail = new Order(&MasterSystem->settings, sales_item, nullptr); + detail = new Order(&MasterSystem->settings, sales_item, NULL); else retval = CALLCTR_ERROR_BADDETAIL; } @@ -2845,21 +2895,21 @@ int ProcessRemoteOrderEntry(SubCheck *subcheck, Order **order, const char* key, (strncmp(key, "EndProduct", 10) == 0)) { subcheck->Add(*order, &MasterSystem->settings); - *order = nullptr; + *order = NULL; } else if ((strncmp(key, "EndDetail", 9) == 0) || (strncmp(key, "EndAddon", 8) == 0)) { (*order)->Add(detail); - detail = nullptr; + detail = NULL; } - else if (*order != nullptr) + else if (*order != NULL) { if (strncmp(key, "ItemQTY", 7) == 0) - (*order)->count = static_cast(std::min(atoi(value), 32767)); + (*order)->count = atoi(value); else if (strncmp(key, "ProductQTY", 10) == 0) - (*order)->count = static_cast(std::min(atoi(value), 32767)); - else if (detail != nullptr && strncmp(key, "AddonQualifier", 14) == 0) + (*order)->count = atoi(value); + else if (detail != NULL && strncmp(key, "AddonQualifier", 14) == 0) detail->AddQualifier(value); } else if (debug_mode) @@ -2875,17 +2925,17 @@ int CompleteRemoteOrder(Check *check) FnTrace("CompleteRemoteOrder()"); int status = CALLCTR_STATUS_INCOMPLETE; int order_count = 0; - SubCheck *subcheck = nullptr; - Order *order = nullptr; - Printer *printer = nullptr; - Report *report = nullptr; + SubCheck *subcheck = NULL; + Order *order = NULL; + Printer *printer = NULL; + Report *report = NULL; Terminal *term = MasterControl->TermList(); subcheck = check->SubList(); - while (subcheck != nullptr) + while (subcheck != NULL) { order = subcheck->OrderList(); - while (order != nullptr) + while (order != NULL) { order_count += 1; order = order->next; @@ -2899,12 +2949,12 @@ int CompleteRemoteOrder(Check *check) check->date.Set(); check->FinalizeOrders(term); check->Save(); - MasterControl->UpdateAll(UPDATE_CHECKS, nullptr); + MasterControl->UpdateAll(UPDATE_CHECKS, NULL); check->current_sub = check->FirstOpenSubCheck(); // need to print the check printer = MasterControl->FindPrinter(PRINTER_REMOTEORDER); - if (printer != nullptr) { + if (printer != NULL) { report = new Report(); if (report) { @@ -2925,39 +2975,39 @@ int SendRemoteOrderResult(int socket, Check *check, int result_code, int status) { FnTrace("SendRemoteOrderResult()"); int retval = 0; - std::array result_str{}; + char result_str[STRLONG]; result_str[0] = '\0'; - snprintf(result_str.data(), result_str.size(), "%d:%d:", check->CallCenterID(), + snprintf(result_str, STRLONG, "%d:%d:", check->CallCenterID(), check->serial_number); if (result_code == CALLCTR_ERROR_NONE) { if (status == CALLCTR_STATUS_COMPLETE) - vt_safe_string::safe_concat(result_str.data(), STRLONG, "COMPLETE"); + vt_safe_string::safe_concat(result_str, STRLONG, "COMPLETE"); else if (status == CALLCTR_STATUS_INCOMPLETE) - vt_safe_string::safe_concat(result_str.data(), STRLONG, "INCOMPLETE"); + vt_safe_string::safe_concat(result_str, STRLONG, "INCOMPLETE"); else if (status == CALLCTR_STATUS_FAILED) - vt_safe_string::safe_concat(result_str.data(), STRLONG, "FAILED"); + vt_safe_string::safe_concat(result_str, STRLONG, "FAILED"); else - vt_safe_string::safe_concat(result_str.data(), STRLONG, "UNKNOWNSTAT"); + vt_safe_string::safe_concat(result_str, STRLONG, "UNKNOWNSTAT"); } else { if (result_code == CALLCTR_ERROR_BADITEM) - vt_safe_string::safe_concat(result_str.data(), STRLONG, "BADITEM"); + vt_safe_string::safe_concat(result_str, STRLONG, "BADITEM"); else if (result_code == CALLCTR_ERROR_BADDETAIL) - vt_safe_string::safe_concat(result_str.data(), STRLONG, "BADDETAIL"); + vt_safe_string::safe_concat(result_str, STRLONG, "BADDETAIL"); else - vt_safe_string::safe_concat(result_str.data(), STRLONG, "UNKNOWNERR"); + vt_safe_string::safe_concat(result_str, STRLONG, "UNKNOWNERR"); } - vt_safe_string::safe_concat(result_str.data(), STRLONG, ":"); + vt_safe_string::safe_concat(result_str, STRLONG, ":"); if (result_code == CALLCTR_ERROR_NONE) - vt_safe_string::safe_concat(result_str.data(), STRLONG, "PRINTED"); + vt_safe_string::safe_concat(result_str, STRLONG, "PRINTED"); else - vt_safe_string::safe_concat(result_str.data(), STRLONG, "NOTPRINTED"); + vt_safe_string::safe_concat(result_str, STRLONG, "NOTPRINTED"); - write(socket, result_str.data(), strlen(result_str.data())); + write(socket, result_str, strlen(result_str)); return retval; } @@ -2966,9 +3016,9 @@ int DeliveryToInt(const char* cost) { FnTrace("DeliveryToInt()"); int retval = 0; - double interm = atof(cost); + float interm = atof(cost); - retval = static_cast(interm * 100.0); + retval = (int)(interm * 100.0); return retval; } @@ -2978,13 +3028,13 @@ int ProcessRemoteOrder(int sock_fd) FnTrace("ProcessRemoteOrder()"); int retval = 0; KeyValueInputFile kvif; - std::array key{}; - std::array value{}; + char key[STRLONG]; + char value[STRLONG]; Settings *settings = &MasterSystem->settings; - Check *check = nullptr; - SubCheck *subcheck = nullptr; - Order *order = nullptr; - std::array StoreNum{}; + Check *check = NULL; + SubCheck *subcheck = NULL; + Order *order = NULL; + char StoreNum[STRSHORT]; int status = CALLCTR_STATUS_INCOMPLETE; kvif.Set(sock_fd); @@ -2992,77 +3042,82 @@ int ProcessRemoteOrder(int sock_fd) write(sock_fd, "SENDORDER\n", 10); check = new Check(settings, CHECK_DELIVERY); - if (check == nullptr) + if (check == NULL) return retval; subcheck = check->NewSubCheck(); - if (subcheck == nullptr) + if (subcheck == NULL) return retval; while ((status == CALLCTR_STATUS_INCOMPLETE) && (retval == CALLCTR_ERROR_NONE) && - (kvif.Read(key.data(), value.data(), STRLONG - 2) > 0)) + (kvif.Read(key, value, STRLONG - 2) > 0)) { if (debug_mode) - printf("Key: %s, Value: %s\n", key.data(), value.data()); - if (strncmp(key.data(), "OrderID", 7) == 0) - check->CallCenterID(atoi(value.data())); - else if (strncmp(key.data(), "OrderType", 9) == 0) + printf("Key: %s, Value: %s\n", key, value); + if (strncmp(key, "OrderID", 7) == 0) + check->CallCenterID(atoi(value)); + else if (strncmp(key, "OrderType", 9) == 0) check->CustomerType((value[0] == 'D') ? CHECK_DELIVERY : CHECK_TAKEOUT); - else if ( strncmp(key.data(), "OrderStatus", 11) == 0) + else if ( strncmp(key, "OrderStatus", 11) == 0) ; // ignore this - else if (strncmp(key.data(), "FirstName", 9) == 0) - check->FirstName(value.data()); - else if (strncmp(key.data(), "LastName", 8) == 0) - check->LastName(value.data()); - else if (strncmp(key.data(), "CustomerName", 12) == 0) - check->FirstName(value.data()); - else if (strncmp(key.data(), "PhoneNo", 7) == 0) - check->PhoneNumber(value.data()); - else if (strncmp(key.data(), "PhoneExt", 8) == 0) - check->Extension(value.data()); - else if (strncmp(key.data(), "Street", 6) == 0) - check->Address(value.data()); - else if (strncmp(key.data(), "Address", 7) == 0) - check->Address(value.data()); - else if (strncmp(key.data(), "Suite", 5) == 0) - check->Address2(value.data()); - else if (strncmp(key.data(), "CrossStreet", 11) == 0) - check->CrossStreet(value.data()); - else if (strncmp(key.data(), "City", 4) == 0) - check->City(value.data()); - else if (strncmp(key.data(), "State", 5) == 0) - check->State(value.data()); - else if (strncmp(key.data(), "Zip", 3) == 0) - check->Postal(value.data()); - else if (strncmp(key.data(), "DeliveryCharge", 14) == 0) - subcheck->delivery_charge = DeliveryToInt(value.data()); - else if (strncmp(key.data(), "RestaurantID", 12) == 0) - vt_safe_string::safe_copy(StoreNum.data(), StoreNum.size(), value.data()); - else if ( - (strncmp(key.data(), "Item", 4) == 0) || - (strncmp(key.data(), "Detail", 6) == 0) || - (strncmp(key.data(), "Product", 7) == 0) || - (strncmp(key.data(), "Addon", 5) == 0) || - (strncmp(key.data(), "SideNumber", 10) == 0) || - (strncmp(key.data(), "EndItem", 7) == 0) || - (strncmp(key.data(), "EndDetail", 9) == 0) || - (strncmp(key.data(), "EndProduct", 10) == 0) || - (strncmp(key.data(), "EndAddon", 8) == 0)) - { - retval = ProcessRemoteOrderEntry(subcheck, &order, key.data(), value.data()); - } - else if (strncmp(key.data(), "EndOrder", 8) == 0) + else if (strncmp(key, "FirstName", 9) == 0) + check->FirstName(value); + else if (strncmp(key, "LastName", 8) == 0) + check->LastName(value); + else if (strncmp(key, "CustomerName", 12) == 0) + check->FirstName(value); + else if (strncmp(key, "PhoneNo", 7) == 0) + check->PhoneNumber(value); + else if (strncmp(key, "PhoneExt", 8) == 0) + check->Extension(value); + else if (strncmp(key, "Street", 6) == 0) + check->Address(value); + else if (strncmp(key, "Address", 7) == 0) + check->Address(value); + else if (strncmp(key, "Suite", 5) == 0) + check->Address2(value); + else if (strncmp(key, "CrossStreet", 11) == 0) + check->CrossStreet(value); + else if (strncmp(key, "City", 4) == 0) + check->City(value); + else if (strncmp(key, "State", 5) == 0) + check->State(value); + else if (strncmp(key, "Zip", 3) == 0) + check->Postal(value); + else if (strncmp(key, "DeliveryCharge", 14) == 0) + subcheck->delivery_charge = DeliveryToInt(value); + else if (strncmp(key, "RestaurantID", 12) == 0) + strncpy(StoreNum, value, 10); // arbitrary limit on StoreNum + else if (strncmp(key, "Item", 4) == 0) + retval = ProcessRemoteOrderEntry(subcheck, &order, key, value); + else if (strncmp(key, "Detail", 6) == 0) + retval = ProcessRemoteOrderEntry(subcheck, &order, key, value); + else if (strncmp(key, "Product", 7) == 0) + retval = ProcessRemoteOrderEntry(subcheck, &order, key, value); + else if (strncmp(key, "Addon", 5) == 0) + retval = ProcessRemoteOrderEntry(subcheck, &order, key, value); + else if (strncmp(key, "SideNumber", 10) == 0) + retval = ProcessRemoteOrderEntry(subcheck, &order, key, value); + else if (strncmp(key, "EndItem", 7) == 0) + retval = ProcessRemoteOrderEntry(subcheck, &order, key, value); + else if (strncmp(key, "EndDetail", 9) == 0) + retval = ProcessRemoteOrderEntry(subcheck, &order, key, value); + else if (strncmp(key, "EndProduct", 10) == 0) + retval = ProcessRemoteOrderEntry(subcheck, &order, key, value); + else if (strncmp(key, "EndAddon", 8) == 0) + retval = ProcessRemoteOrderEntry(subcheck, &order, key, value); + else if (strncmp(key, "EndOrder", 8) == 0) status = CompleteRemoteOrder(check); else if (debug_mode) - printf("Unknown Key: %s, Value: %s\n", key.data(), value.data()); + printf("Unknown Key: %s, Value: %s\n", key, value); } - if (strncmp(key.data(), "EndOrder", 8) != 0) + if (strncmp(key, "EndOrder", 8)) { // There are still key/value pairs waiting, so we need to read them // all to clear out the queue. - while (kvif.Read(key.data(), value.data(), STRLONG - 2) > 0) + while (kvif.Read(key, value, STRLONG - 2) > 0) { - if (strncmp(key.data(), "EndOrder", 8) == 0) + if (strncmp(key, "EndOrder", 8) == 0) break; } } @@ -3075,8 +3130,8 @@ int CompareCardNumbers(const char* card1, const char* card2) { FnTrace("CompreCardNumbers()"); int retval = 0; - size_t len1 = 0; - size_t len2 = 0; + int len1 = 0; + int len2 = 0; if (card1[0] == 'x' || card2[0] == 'x') { @@ -3100,30 +3155,30 @@ int CompareCardNumbers(const char* card1, const char* card2) Check* FindCCData(const char* cardnum, int value) { FnTrace("FindCCData()"); - Check *ret_check = nullptr; - Check *curr_check = nullptr; - Archive *archive = nullptr; - SubCheck *subcheck = nullptr; - Payment *payment = nullptr; - Credit *credit = nullptr; - std::array cn{}; + Check *ret_check = NULL; + Check *curr_check = NULL; + Archive *archive = NULL; + SubCheck *subcheck = NULL; + Payment *payment = NULL; + Credit *credit = NULL; + char cn[STRLENGTH]; curr_check = MasterSystem->CheckList(); - while (ret_check == nullptr && archive != MasterSystem->ArchiveList()) + while (ret_check == NULL && archive != MasterSystem->ArchiveList()) { - while (curr_check != nullptr && ret_check == nullptr) + while (curr_check != NULL && ret_check == NULL) { subcheck = curr_check->SubList(); - while (subcheck != nullptr && ret_check == nullptr) + while (subcheck != NULL && ret_check == NULL) { payment = subcheck->PaymentList(); - while (payment != nullptr && ret_check == nullptr) + while (payment != NULL && ret_check == NULL) { - if (payment->credit != nullptr) + if (payment->credit != NULL) { credit = payment->credit; - vt_safe_string::safe_copy(cn.data(), STRLENGTH, credit->PAN(2)); - if (CompareCardNumbers(cn.data(), cardnum) && + vt_safe_string::safe_copy(cn, STRLENGTH, credit->PAN(2)); + if (CompareCardNumbers(cn, cardnum) && credit->FullAmount() == value) { ret_check = curr_check; } @@ -3134,9 +3189,9 @@ Check* FindCCData(const char* cardnum, int value) } curr_check = curr_check->next; } - if (ret_check == nullptr) + if (ret_check == NULL) { - if (archive == nullptr) + if (archive == NULL) archive = MasterSystem->ArchiveListEnd(); else archive = archive->fore; @@ -3153,16 +3208,16 @@ int GetCCData(const char* data) { FnTrace("GetCCData()"); int retval = 0; - std::array cardnum{}; - std::array camount{}; + char cardnum[STRLENGTH]; + char camount[STRLENGTH]; int amount; int sidx = 0; int didx = 0; int maxlen = 28; // arbitrary: 19 chars for PAN, 8 for amount, 1 for space - Check *check = nullptr; - SubCheck *subcheck = nullptr; - Payment *payment = nullptr; - Credit *credit = nullptr; + Check *check = NULL; + SubCheck *subcheck = NULL; + Payment *payment = NULL; + Credit *credit = NULL; // get cardnum while (data[sidx] != ' ' && data[sidx] != '\0' && sidx < maxlen) @@ -3182,20 +3237,20 @@ int GetCCData(const char* data) sidx += 1; } camount[didx] = '\0'; - amount = atoi(camount.data()); + amount = atoi(camount); - check = FindCCData(cardnum.data(), amount); + check = FindCCData(cardnum, amount); if (check) { - printf("Card %s was processed on %s\n", cardnum.data(), check->made_time.to_string().c_str()); + printf("Card %s was processed on %s\n", cardnum, check->made_time.to_string().c_str()); printf(" Check ID: %d\n", check->serial_number); subcheck = check->SubList(); - while (subcheck != nullptr) + while (subcheck != NULL) { payment = subcheck->PaymentList(); - while (payment != nullptr) + while (payment != NULL) { - if (payment->credit != nullptr) + if (payment->credit != NULL) { credit = payment->credit; printf(" Card Name: %s\n", credit->Name()); @@ -3216,7 +3271,7 @@ int ProcessSocketRequest(char* request) FnTrace("ProcessSocketRequest()"); int retval = 1; int idx = 0; - std::array str{}; + char str[STRLONG]; while (request[idx] != '\0' && request[idx] != '\n' && @@ -3227,8 +3282,8 @@ int ProcessSocketRequest(char* request) } request[idx] = '\0'; - snprintf(str.data(), str.size(), "Processing Request: %s", request); - ReportError(str.data()); + snprintf(str, STRLONG, "Processing Request: %s", request); + ReportError(str); if (strncmp(request, "openterm ", 9) == 0) retval = OpenDynTerminal(&request[9]); @@ -3248,7 +3303,7 @@ int ReadSocketRequest(int listen_sock) int retval = 1; static int open_sock = -1; static int count = 0; - std::array request{}; + char request[STRLONG] = ""; int bytes_read = 0; int sel_result; @@ -3262,19 +3317,18 @@ int ReadSocketRequest(int listen_sock) sel_result = SelectIn(open_sock, select_timeout); if (sel_result > 0) { - ssize_t read_result = read(open_sock, request.data(), request.size() - 1); - bytes_read = static_cast(std::min(read_result, static_cast(INT_MAX))); + bytes_read = read(open_sock, request, sizeof(request) - 1); if (bytes_read > 0) { // In most cases we're only going to read once and then close the socket. // This really isn't intended to be a conversation at this point. - if (strncmp(request.data(), "remoteorder", 11) == 0) + if (strncmp(request, "remoteorder", 11) == 0) retval = ProcessRemoteOrder(open_sock); else { request[bytes_read] = '\0'; write(open_sock, "ACK", 3); - retval = ProcessSocketRequest(request.data()); + retval = ProcessSocketRequest(request); } close(open_sock); open_sock = -1; @@ -3328,7 +3382,7 @@ void UpdateSystemCB(XtPointer client_data, XtIntervalId *time_id) if (UserRestart) { - if (MasterControl->TermList() != nullptr && + if (MasterControl->TermList() != NULL && MasterControl->TermList()->TermsInUse() == 0) { RestartSystem(); @@ -3367,7 +3421,7 @@ void UpdateSystemCB(XtPointer client_data, XtIntervalId *time_id) LastDay = day; } - if (sys->eod_term != nullptr && sys->eod_term->eod_processing != EOD_DONE) + if (sys->eod_term != NULL && sys->eod_term->eod_processing != EOD_DONE) { sys->eod_term->EndDay(); } @@ -3383,7 +3437,7 @@ void UpdateSystemCB(XtPointer client_data, XtIntervalId *time_id) int online_count = 0; int total_count = 0; - for (Printer *p = MasterControl->PrinterList(); p != nullptr; p = p->next) + for (Printer *p = MasterControl->PrinterList(); p != NULL; p = p->next) { // Attempt to reconnect offline remote printers (failure == 999) p->ReconnectIfOffline(); @@ -3441,7 +3495,7 @@ void UpdateSystemCB(XtPointer client_data, XtIntervalId *time_id) while (term) { Terminal *tnext = term->next; - if (term->reload_zone_db && term->user == nullptr) + if (term->reload_zone_db && term->user == NULL) { // Reload zone information if needed ReportError("Updating zone information"); @@ -3467,10 +3521,10 @@ void UpdateSystemCB(XtPointer client_data, XtIntervalId *time_id) if (term->page->IsTable() || term->page->IsKitchen()) u |= UPDATE_BLINK; // half second blink message for table pages if (u) - term->Update(u, nullptr); + term->Update(u, NULL); } - if (term->cdu != nullptr) + if (term->cdu != NULL) term->cdu->Refresh(); if (term->kill_me) @@ -3478,7 +3532,7 @@ void UpdateSystemCB(XtPointer client_data, XtIntervalId *time_id) term = tnext; } - if (con->TermList() == nullptr) + if (con->TermList() == NULL) { ReportError("All terminals lost - shutting down system"); EndSystem(); @@ -3518,17 +3572,17 @@ void UpdateSystemCB(XtPointer client_data, XtIntervalId *time_id) * have been processed (or if there is no command file) we delete the command * file and disable command processing until the next SIGUSR2 signal. ****/ -int RunUserCommand() +int RunUserCommand(void) { FnTrace("RunUserCommand()"); int retval = 0; - std::array key{}; - std::array value{}; + genericChar key[STRLENGTH]; + genericChar value[STRLENGTH]; static int working = 0; static int macros = 0; static int endday = 0; - static Printer *printer = nullptr; - static Report *report = nullptr; + static Printer *printer = NULL; + static Report *report = NULL; static KeyValueInputFile kvfile; static int exit_system = 0; @@ -3537,7 +3591,7 @@ int RunUserCommand() if (working) { - working = RunReport(nullptr, printer); + working = RunReport(NULL, printer); } else if (endday) { @@ -3547,28 +3601,28 @@ int RunUserCommand() { macros = RunMacros(); } - else if (kvfile.IsOpen() && kvfile.Read(key.data(), value.data(), STRLENGTH)) + else if (kvfile.IsOpen() && kvfile.Read(key, value, STRLENGTH)) { - if (strcmp(key.data(), "report") == 0) - working = RunReport(value.data(), printer); - else if (strcmp(key.data(), "printer") == 0) - printer = SetPrinter(value.data()); - else if (strcmp(key.data(), "nologin") == 0) + if (strcmp(key, "report") == 0) + working = RunReport(value, printer); + else if (strcmp(key, "printer") == 0) + printer = SetPrinter(value); + else if (strcmp(key, "nologin") == 0) AllowLogins = 0; - else if (strcmp(key.data(), "allowlogin") == 0) + else if (strcmp(key, "allowlogin") == 0) AllowLogins = 1; - else if (strcmp(key.data(), "exitsystem") == 0) + else if (strcmp(key, "exitsystem") == 0) exit_system = 1; - else if (strcmp(key.data(), "endday") == 0) + else if (strcmp(key, "endday") == 0) endday = RunEndDay(); - else if (strcmp(key.data(), "runmacros") == 0) + else if (strcmp(key, "runmacros") == 0) macros = RunMacros(); - else if (strcmp(key.data(), "ping") == 0) + else if (strcmp(key, "ping") == 0) PingCheck(); - else if (strcmp(key.data(), "usercount") == 0) + else if (strcmp(key, "usercount") == 0) UserCount(); - else if (strlen(key.data()) > 0) - fprintf(stderr, "Unknown external command: '%s'\n", key.data()); + else if (strlen(key) > 0) + fprintf(stderr, "Unknown external command: '%s'\n", key); } else { @@ -3577,9 +3631,9 @@ int RunUserCommand() kvfile.Reset(); unlink(VIEWTOUCH_COMMAND); } - if (printer != nullptr) + if (printer != NULL) delete printer; - if (report != nullptr) + if (report != NULL) delete report; // only allow system exit if we're running at startup (to be used to // run multiple reports for multiple data sets, not to be used for @@ -3620,17 +3674,17 @@ int UserCount() FnTrace("UserCount()"); int retval = 0; int count = 0; - std::array message{}; - Terminal *term = nullptr; + char message[STRLENGTH]; + Terminal *term = NULL; count = MasterControl->TermList()->TermsInUse(); - snprintf(message.data(), message.size(), "UserCount: %d users active", count); - ReportError(message.data()); + snprintf(message, STRLENGTH, "UserCount: %d users active", count); + ReportError(message); if (count > 0) { term = MasterControl->TermList(); - while (term != nullptr) + while (term != NULL) { if (term->user) { @@ -3682,16 +3736,16 @@ int RunEndDay() int RunMacros() { FnTrace("RunMacros()"); - static Terminal *term = nullptr; + static Terminal *term = NULL; static int count = 0; int retval = 0; - if (term == nullptr) + if (term == NULL) term = MasterControl->TermListEnd(); - while (term != nullptr && retval == 0) + while (term != NULL && retval == 0) { - if (term->page != nullptr) + if (term->page != NULL) { term->ReadRecordFile(); term = term->next; @@ -3721,17 +3775,17 @@ int RunReport(const genericChar* report_string, Printer *printer) { FnTrace("RunReport()"); int retval = 0; - static Report *report = nullptr; - std::array report_name{}; - std::array report_from{}; + static Report *report = NULL; + genericChar report_name[STRLONG] = ""; + genericChar report_from[STRLONG] = ""; TimeInfo from; - std::array report_to{}; + genericChar report_to[STRLONG] = ""; TimeInfo to; int idx = 0; Terminal *term = MasterControl->TermList(); System *system_data = term->system_data; - if (report == nullptr && report_string != nullptr) + if (report == NULL && report_string != NULL) { report = new Report; @@ -3740,13 +3794,13 @@ int RunReport(const genericChar* report_string, Printer *printer) // need to pull out "Report From To" // date will be in the format "DD/MM/YY,HH:MM" in 24hour format - if (NextToken(report_name.data(), report_string, ' ', &idx)) + if (NextToken(report_name, report_string, ' ', &idx)) { - if (NextToken(report_from.data(), report_string, ' ', &idx)) + if (NextToken(report_from, report_string, ' ', &idx)) { - from.Set(report_from.data()); - if (NextToken(report_to.data(), report_string, ' ', &idx)) - to.Set(report_to.data()); + from.Set(report_from); + if (NextToken(report_to, report_string, ' ', &idx)) + to.Set(report_to); } } if (!from.IsSet()) @@ -3761,38 +3815,38 @@ int RunReport(const genericChar* report_string, Printer *printer) to.Floor(); to -= std::chrono::seconds(1); } - if (strcmp(report_name.data(), "daily") == 0) - system_data->DepositReport(term, from, to, nullptr, report); - else if (strcmp(report_name.data(), "expense") == 0) - system_data->ExpenseReport(term, from, to, nullptr, report, nullptr); - else if (strcmp(report_name.data(), "revenue") == 0) + if (strcmp(report_name, "daily") == 0) + system_data->DepositReport(term, from, to, NULL, report); + else if (strcmp(report_name, "expense") == 0) + system_data->ExpenseReport(term, from, to, NULL, report, NULL); + else if (strcmp(report_name, "revenue") == 0) system_data->BalanceReport(term, from, to, report); - else if (strcmp(report_name.data(), "royalty") == 0) - system_data->RoyaltyReport(term, from, to, nullptr, report, nullptr); - else if (strcmp(report_name.data(), "sales") == 0) - system_data->SalesMixReport(term, from, to, nullptr, report); - else if (strcmp(report_name.data(), "audit") == 0) - system_data->AuditingReport(term, from, to, nullptr, report, nullptr); - else if (strcmp(report_name.data(), "batchsettle") == 0) + else if (strcmp(report_name, "royalty") == 0) + system_data->RoyaltyReport(term, from, to, NULL, report, NULL); + else if (strcmp(report_name, "sales") == 0) + system_data->SalesMixReport(term, from, to, NULL, report); + else if (strcmp(report_name, "audit") == 0) + system_data->AuditingReport(term, from, to, NULL, report, NULL); + else if (strcmp(report_name, "batchsettle") == 0) { MasterSystem->cc_report_type = CC_REPORT_BATCH; - system_data->CreditCardReport(term, from, to, nullptr, report, nullptr); + system_data->CreditCardReport(term, from, to, NULL, report, NULL); } else { - fprintf(stderr, "Unknown report '%s'\n", report_name.data()); + fprintf(stderr, "Unknown report '%s'\n", report_name); delete report; - report = nullptr; + report = NULL; } } - if (report != nullptr) + if (report != NULL) { if (report->is_complete > 0) { report->Print(printer); delete report; - report = nullptr; + report = NULL; retval = 0; } else @@ -3808,7 +3862,7 @@ int RunReport(const genericChar* report_string, Printer *printer) Printer *SetPrinter(const genericChar* printer_description) { FnTrace("SetPrinter()"); - Printer *retPrinter = nullptr; + Printer *retPrinter = NULL; retPrinter = NewPrinterFromString(printer_description); return retPrinter; @@ -3859,13 +3913,13 @@ void ShowRestartDialog() Terminal *term = MasterControl->TermList(); if (!term) return; - auto *sd = new SimpleDialog(GlobalTranslate("Scheduled Restart Time\\System needs to restart now.\\Choose an option:"), 1); + SimpleDialog *sd = new SimpleDialog(GlobalTranslate("Scheduled Restart Time\\System needs to restart now.\\Choose an option:"), 1); sd->Button(GlobalTranslate("Restart Now"), "restart_now"); sd->Button(GlobalTranslate("Postpone 1 Hour"), "restart_postpone"); // Set 5-minute auto-restart timeout restart_timeout_id = XtAppAddTimeOut(App, 5 * 60 * 1000, - (XtTimerCallbackProc) AutoRestartTimeoutCB, nullptr); + (XtTimerCallbackProc) AutoRestartTimeoutCB, NULL); term->OpenDialog(sd); } @@ -3928,7 +3982,7 @@ int GetFontSize(int font_id, int &w, int &h) int GetTextWidth(const char* my_string, int len, int font_id) { FnTrace("GetTextWidth()"); - if (my_string == nullptr || len <= 0) + if (my_string == NULL || len <= 0) return 0; else if (FontInfo[font_id]) return XTextWidth(FontInfo[font_id], my_string, len); @@ -3970,7 +4024,7 @@ int RemoveInputFn(unsigned long fn_id) if (fn_id > 0) { // Check if App context is still valid before removing input - if (App != nullptr) + if (App != NULL) { XtRemoveInput(fn_id); } @@ -3998,22 +4052,22 @@ int ReloadFonts() for (int f = 0; f < 32; ++f) { if (XftFontsArr[f]) { XftFontClose(Dis, XftFontsArr[f]); - XftFontsArr[f] = nullptr; + XftFontsArr[f] = NULL; } // Find the font in FontData array and use its specification directly int found = 0; - for (auto & fd : FontData) { - if (fd.id == f) { + for (int fd = 0; fd < FONT_COUNT; ++fd) { + if (FontData[fd].id == f) { // Use the font specification directly from FontData - const char* font_spec = fd.font; + const char* font_spec = FontData[fd].font; // Append :dpi=96 to font specification if not already present - static std::array font_spec_with_dpi; + static char font_spec_with_dpi[256]; const char* font_to_load = font_spec; if (strstr(font_spec, ":dpi=") == nullptr) { - snprintf(font_spec_with_dpi.data(), font_spec_with_dpi.size(), "%s:dpi=96", font_spec); - font_to_load = font_spec_with_dpi.data(); + snprintf(font_spec_with_dpi, sizeof(font_spec_with_dpi), "%s:dpi=96", font_spec); + font_to_load = font_spec_with_dpi; } // Load the font using the original specification with fixed DPI @@ -4033,10 +4087,10 @@ int ReloadFonts() } // Update font dimensions from FontData array to maintain UI layout compatibility - for (auto & fd : FontData) { - if (fd.id == f) { - FontWidth[f] = fd.width; - FontHeight[f] = fd.height; + for (int fd = 0; fd < FONT_COUNT; ++fd) { + if (FontData[fd].id == f) { + FontWidth[f] = FontData[fd].width; + FontHeight[f] = FontData[fd].height; break; } } @@ -4062,7 +4116,7 @@ int ReloadFonts() // Notify all terminals to reload fonts Terminal *term = MasterControl->TermList(); - while (term != nullptr) { + while (term != NULL) { if (term->socket_no > 0) { term->WInt8(TERM_RELOAD_FONTS); term->SendNow(); @@ -4103,19 +4157,19 @@ static const char* CompatibleFontFamilies[] = { "Nimbus Mono PS", // URW Courier equivalent "D050000L", // URW Dingbats "Z003", // URW Zapf Dingbats - nullptr + NULL }; // Lazy font loading function for performance optimization // Function to get a compatible font specification const char* GetCompatibleFontSpec(int font_id, const char* desired_family) { - static std::array font_spec; + static char font_spec[256]; // Find the base font data - const char* base_spec = nullptr; - for (auto & i : FontData) { - if (i.id == font_id) { - base_spec = i.font; + const char* base_spec = NULL; + for (int i = 0; i < FONT_COUNT; ++i) { + if (FontData[i].id == font_id) { + base_spec = FontData[i].font; break; } } @@ -4139,7 +4193,7 @@ const char* GetCompatibleFontSpec(int font_id, const char* desired_family) { // Check if desired family is compatible int is_compatible = 0; - for (int i = 0; CompatibleFontFamilies[i] != nullptr; ++i) { + for (int i = 0; CompatibleFontFamilies[i] != NULL; ++i) { if (strcmp(desired_family, CompatibleFontFamilies[i]) == 0) { is_compatible = 1; break; @@ -4149,42 +4203,42 @@ const char* GetCompatibleFontSpec(int font_id, const char* desired_family) { // If not compatible, use DejaVu Serif (guaranteed to work) const char* family = is_compatible ? desired_family : "DejaVu Serif"; - snprintf(font_spec.data(), font_spec.size(), "%s:pixelsize=%d:style=%s", + snprintf(font_spec, sizeof(font_spec), "%s:pixelsize=%d:style=%s", family, pixelsize, style); - return font_spec.data(); + return font_spec; } // Function to read global font family from configuration const char* GetGlobalFontFamily() { - static std::array font_family = {"DejaVu Serif"}; // default + static char font_family[256] = "DejaVu Serif"; // default // Try to read from configuration file const char* config_file = "/usr/viewtouch/dat/conf/font.conf"; FILE* fp = fopen(config_file, "r"); if (fp) { - std::array line; - if (fgets(line.data(), line.size(), fp)) { + char line[256]; + if (fgets(line, sizeof(line), fp)) { // Remove newline - line[line.size() > 0 ? strcspn(line.data(), "\n") : 0] = 0; + line[strcspn(line, "\n")] = 0; // Check if it's a valid font family int is_valid = 0; - for (int i = 0; CompatibleFontFamilies[i] != nullptr; ++i) { - if (strcmp(line.data(), CompatibleFontFamilies[i]) == 0) { + for (int i = 0; CompatibleFontFamilies[i] != NULL; ++i) { + if (strcmp(line, CompatibleFontFamilies[i]) == 0) { is_valid = 1; break; } } if (is_valid) { - std::strncpy(font_family.data(), line.data(), font_family.size() - 1); - font_family[font_family.size() - 1] = '\0'; - printf("Loaded font family from config: %s\n", font_family.data()); + strncpy(font_family, line, sizeof(font_family) - 1); + font_family[sizeof(font_family) - 1] = '\0'; + printf("Loaded font family from config: %s\n", font_family); } else { - printf("Invalid font family in config: %s, using default\n", line.data()); + printf("Invalid font family in config: %s, using default\n", line); } } fclose(fp); } - return font_family.data(); + return font_family; } diff --git a/main/data/manager.hh b/main/data/manager.hh index 3a832728..86a4c20c 100644 --- a/main/data/manager.hh +++ b/main/data/manager.hh @@ -19,14 +19,13 @@ * Standard POS utility functions */ -#ifndef MANAGER_HH -#define MANAGER_HH +#ifndef _MANAGER_HH +#define _MANAGER_HH #include "utility.hh" #include "list_utility.hh" -#include -#include #include +#include #define MASTER_USER_DB "employee.dat" #define MASTER_MENU_DB "menu.dat" @@ -59,9 +58,9 @@ /**** Types ****/ -using TimeOutFn = void (*)(); -using InputFn = void (*)(); -using WorkFn = int (*)(); +typedef void (* TimeOutFn)(); +typedef void (* InputFn)(); +typedef int (* WorkFn)(); class Settings; class Terminal; @@ -145,8 +144,8 @@ int ReportError(const std::string &message); // error logging & reporting functi int ReportLoader(const char* message); // gives a message to the loader program if it is still active char* PriceFormat(const Settings* s, int price, int use_sign, int use_comma, - genericChar* buffer = nullptr); // formats price into string -int ParsePrice(const char* source, int *val = nullptr); // returns price value from given string + genericChar* buffer = NULL); // formats price into string +int ParsePrice(const char* source, int *val = NULL); // returns price value from given string // Load/Save system pages & default system data - 'vt_data' file // (i.e. information specific to all pos systems) @@ -192,15 +191,15 @@ extern MachineInfo *ThisMachineInfo; // MachineInfo for this system extern int AllowLogins; // whether terms should permit logins // commonly used strings -extern const std::array DayName; -extern const std::array ShortDayName; -extern const std::array MonthName; -extern const std::array ShortMonthName; +extern const genericChar* DayName[]; +extern const genericChar* ShortDayName[]; +extern const genericChar* MonthName[]; +extern const genericChar* ShortMonthName[]; extern const genericChar* CheckRefName[]; extern int CheckRefValue[]; -extern const std::array TermTypeName; -extern const std::array TermTypeValue; -extern const std::array PrinterTypeName; -extern const std::array PrinterTypeValue; +extern const genericChar* TermTypeName[]; +extern int TermTypeValue[]; +extern const genericChar* PrinterTypeName[]; +extern int PrinterTypeValue[]; #endif diff --git a/main/data/settings.cc b/main/data/settings.cc index 416c3557..4d371304 100644 --- a/main/data/settings.cc +++ b/main/data/settings.cc @@ -19,7 +19,6 @@ */ #include -#include #include #include #include @@ -62,58 +61,74 @@ namespace fs = std::filesystem; ********************************************************************/ const char* StoreName[] = { - GlobalTranslate("Other"), nullptr}; + GlobalTranslate("Other"), NULL}; int StoreValue[] = { STORE_OTHER, -1}; const char* PayPeriodName[] = { - GlobalTranslate("Weekly"), GlobalTranslate("2 Weeks"), GlobalTranslate("4 Weeks"), GlobalTranslate("Semi Monthly"), GlobalTranslate("Semi Monthly 11/26"), GlobalTranslate("Monthly"), nullptr}; + GlobalTranslate("Weekly"), GlobalTranslate("2 Weeks"), GlobalTranslate("4 Weeks"), GlobalTranslate("Semi Monthly"), GlobalTranslate("Semi Monthly 11/26"), GlobalTranslate("Monthly"), NULL}; int PayPeriodValue[] = { PERIOD_WEEK, PERIOD_2WEEKS, PERIOD_4WEEKS, PERIOD_HALFMONTH, PERIOD_HM_11, PERIOD_MONTH, -1}; const char* MealStartName[] = { GlobalTranslate("Breakfast"), GlobalTranslate("Brunch"), GlobalTranslate("Lunch"), GlobalTranslate("Early Dinner"), - GlobalTranslate("Dinner"), GlobalTranslate("Late Night"), nullptr}; + GlobalTranslate("Dinner"), GlobalTranslate("Late Night"), NULL}; int MealStartValue[] = { INDEX_BREAKFAST, INDEX_BRUNCH, INDEX_LUNCH, INDEX_EARLY_DINNER, INDEX_DINNER, INDEX_LATE_NIGHT, -1}; -// DrawerMode values provided via DrawerModeType (settings_enums.hh) +const char* DrawerModeName[] = { + GlobalTranslate("Trusted"), GlobalTranslate("Assigned"), GlobalTranslate("Server Bank"), NULL}; +int DrawerModeValue[] = { + DRAWER_NORMAL, DRAWER_ASSIGNED, DRAWER_SERVER, -1}; const char* SaleCreditName[] = { - GlobalTranslate("First Server"), GlobalTranslate("Last Server"), nullptr}; + GlobalTranslate("First Server"), GlobalTranslate("Last Server"), NULL}; int SaleCreditValue[] = { 1, 0, -1}; const char* SalesPeriodName[] = { - GlobalTranslate("None"), GlobalTranslate("1 Week"), GlobalTranslate("2 Weeks"), GlobalTranslate("4 Weeks"), GlobalTranslate("Month"), GlobalTranslate("11/26"), nullptr}; + GlobalTranslate("None"), GlobalTranslate("1 Week"), GlobalTranslate("2 Weeks"), GlobalTranslate("4 Weeks"), GlobalTranslate("Month"), GlobalTranslate("11/26"), NULL}; int SalesPeriodValue[] = { SP_NONE, SP_WEEK, SP_2WEEKS, SP_4WEEKS, SP_MONTH, SP_HM_11, -1}; -// ReceiptPrint values are supplied via enum (ReceiptPrintType) in settings_enums.hh +const char* ReceiptPrintName[] = { + GlobalTranslate("Never"), GlobalTranslate("On Send"), GlobalTranslate("On Finalize"), GlobalTranslate("On Both"), NULL}; +int ReceiptPrintValue[] = { + RECEIPT_NONE, RECEIPT_SEND, RECEIPT_FINALIZE, RECEIPT_BOTH, -1}; -// DrawerPrint values are provided via DrawerPrintType (settings_enums.hh) +const char* DrawerPrintName[] = { + GlobalTranslate("On Pull"), GlobalTranslate("On Balance"), GlobalTranslate("On Both"), GlobalTranslate("Never"), NULL}; +int DrawerPrintValue[] = { + DRAWER_PRINT_PULL, DRAWER_PRINT_BALANCE, DRAWER_PRINT_BOTH, DRAWER_PRINT_NEVER, -1}; -// Rounding values are provided via PriceRoundingType (settings_enums.hh) +const char* RoundingName[] = { + GlobalTranslate("None"), GlobalTranslate("Drop Pennies"), GlobalTranslate("Round Up Gratuity"), NULL}; +int RoundingValue[] = { + ROUNDING_NONE, ROUNDING_DROP_PENNIES, ROUNDING_UP_GRATUITY, -1}; const char* PrinterName[] = { GlobalTranslate("None"), GlobalTranslate("Kitchen1"), GlobalTranslate("Kitchen2"), GlobalTranslate("Bar1"), GlobalTranslate("Bar2"), GlobalTranslate("Expediter"), GlobalTranslate("Kitchen1 notify2"), GlobalTranslate("Kitchen2 notify1"), GlobalTranslate("Remote Order"), - GlobalTranslate("Default"), nullptr}; + GlobalTranslate("Default"), NULL}; int PrinterValue[] = { PRINTER_NONE, PRINTER_KITCHEN1, PRINTER_KITCHEN2, PRINTER_BAR1, PRINTER_BAR2, PRINTER_EXPEDITER, PRINTER_KITCHEN1_NOTIFY, PRINTER_KITCHEN2_NOTIFY, PRINTER_REMOTEORDER, PRINTER_DEFAULT, -1}; -// MeasureSystem values are provided via MeasureSystemType (settings_enums.hh) +const char* MeasureSystemName[] = {GlobalTranslate("Standard U.S."), GlobalTranslate("Metric"), NULL}; +int MeasureSystemValue[] = {MEASURE_STANDARD, MEASURE_METRIC, -1}; -// DateFormat values are provided via DateFormatType (settings_enums.hh) +const char* DateFormatName[] = {GlobalTranslate("MM/DD/YY"), GlobalTranslate("DD/MM/YY"), NULL }; +int DateFormatValue[] = {DATE_MMDDYY, DATE_DDMMYY, -1}; -// NumberFormat values are provided via NumberFormatType (settings_enums.hh) +const char* NumberFormatName[] = {GlobalTranslate("1,000,000.00"), GlobalTranslate("1.000.000,00"), NULL}; +int NumberFormatValue[] = {NUMBER_STANDARD, NUMBER_EURO, -1}; -// TimeFormat values are provided via TimeFormatType (settings_enums.hh) +const char* TimeFormatName[] = {GlobalTranslate("12 hour"), GlobalTranslate("24 hour"), NULL}; +int TimeFormatValue[] = {TIME_12HOUR, TIME_24HOUR, -1}; #ifdef CREDITMCVE const char* AuthorizeName[] = {GlobalTranslate("None"), GlobalTranslate("MainStreet"), NULL}; @@ -124,18 +139,18 @@ const char* AuthorizeName[] = {GlobalTranslate("None"), GlobalTranslate("CreditC int AuthorizeValue[] = {CCAUTH_NONE, CCAUTH_CREDITCHEQ, -1}; int ccauth_defined = CCAUTH_CREDITCHEQ; #else -const char* AuthorizeName[] = {GlobalTranslate("None"), nullptr}; +const char* AuthorizeName[] = {GlobalTranslate("None"), NULL}; int AuthorizeValue[] = {CCAUTH_NONE, -1}; int ccauth_defined = CCAUTH_NONE; #endif -const char* MarkName[] = {" ", GlobalTranslate("X"), nullptr}; +const char* MarkName[] = {" ", GlobalTranslate("X"), NULL}; int MarkValue[] = {0, 1, -1}; const char* HourName[] = { GlobalTranslate("12am"), "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", GlobalTranslate("12pm"), "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", - GlobalTranslate("12am"), nullptr}; + GlobalTranslate("12am"), NULL}; int WeekDays[] = { WEEKDAY_SUNDAY, WEEKDAY_MONDAY, WEEKDAY_TUESDAY, WEEKDAY_WEDNESDAY, WEEKDAY_THURSDAY, WEEKDAY_FRIDAY, @@ -178,8 +193,8 @@ namespace confmap MoneyInfo::MoneyInfo() { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; id = -1; rounding = 0; round_amount = 1; @@ -219,8 +234,8 @@ int MoneyInfo::Write(OutputDataFile &df, int version) TaxInfo::TaxInfo() { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; id = -1; flags = 0; amount = 0; @@ -274,7 +289,7 @@ DiscountInfo::DiscountInfo() DiscountInfo *DiscountInfo::Copy() { FnTrace("DiscountInfo::Copy()"); - auto *retdiscount = new DiscountInfo(); + DiscountInfo *retdiscount = new DiscountInfo(); retdiscount->name.Set(name); retdiscount->id = id; retdiscount->amount = amount; @@ -325,7 +340,7 @@ CompInfo::CompInfo() CompInfo *CompInfo::Copy() { FnTrace("CompInfo::Copy()"); - auto *retcomp = new CompInfo(); + CompInfo *retcomp = new CompInfo(); retcomp->name.Set(name); retcomp->id = id; retcomp->flags = flags; @@ -389,7 +404,7 @@ CouponInfo::CouponInfo() CouponInfo *CouponInfo::Copy() { FnTrace("CouponInfo::Copy()"); - auto *retcoupon = new CouponInfo(); + CouponInfo *retcoupon = new CouponInfo(); retcoupon->name.Set(name); retcoupon->id = id; @@ -490,10 +505,10 @@ int CouponInfo::Apply(SubCheck *subcheck, Payment *payment) FnTrace("CouponInfo::Apply()"); int retval = 0; Order *order = subcheck->OrderList(); - SalesItem *item = nullptr; + SalesItem *item = NULL; int payment_value = 0; - while (order != nullptr) + while (order != NULL) { if (order->IsReduced() == 0 && order->IsEmployeeMeal() == 0) { @@ -506,9 +521,9 @@ int CouponInfo::Apply(SubCheck *subcheck, Payment *payment) } order = order->next; } - if (payment == nullptr) + if (payment == NULL) payment = subcheck->FindPayment(TENDER_COUPON, id); - if (payment != nullptr) + if (payment != NULL) { payment->amount = amount; payment->value = payment_value; @@ -528,10 +543,10 @@ int CouponInfo::Applies(SubCheck *subcheck, int aut) FnTrace("CouponInfo::Applies(SubCheck *, int)"); int retval = 1; - if (active == 0 || aut != automatic) - { + if (active == 0) + retval = 0; + else if (aut != automatic) retval = 0; - } else { retval = AppliesTime(); @@ -547,10 +562,12 @@ int CouponInfo::Applies(SalesItem *item, int aut) FnTrace("CouponInfo::Applies(SalesItem *, int)"); int retval = 0; - if (item == nullptr || active == 0 || aut != automatic) - { + if (item == NULL) + retval = 0; + else if (active == 0) + retval = 0; + else if (aut != automatic) retval = 0; - } else { retval = AppliesTime(); @@ -609,12 +626,12 @@ int CouponInfo::AppliesItem(SubCheck *subcheck) { FnTrace("CouponInfo::AppliesItem()"); int retval = 0; - Order *order = nullptr; + Order *order = NULL; - if (subcheck != nullptr) + if (subcheck != NULL) { order = subcheck->OrderList(); - while (order != nullptr) + while (order != NULL) { if (order->item_family == family) { @@ -638,19 +655,18 @@ int CouponInfo::AppliesItem(SalesItem *item) FnTrace("CouponInfo::AppliesItem()"); int retval = 0; - if (item != nullptr) + if (item != NULL) { if (flags & TF_ITEM_SPECIFIC) { - if (family != item->family || item_name.empty()) - { + if (family != item->family) retval = 0; - } - else if (strcmp(item_name.Value(), item->item_name.Value()) == 0 || - strcmp(item_name.Value(), ALL_ITEMS_STRING) == 0) - { + else if (item_name.empty()) + retval = 0; + else if (strcmp(item_name.Value(), item->item_name.Value()) == 0) + retval = 1; + else if (strcmp(item_name.Value(), ALL_ITEMS_STRING) == 0) retval = 1; - } } else retval = 1; @@ -676,7 +692,7 @@ int CouponInfo::Amount(SubCheck *subcheck) else if (flags & TF_ITEM_SPECIFIC) { item_count = Applies(subcheck); - if (item_count > 0 && subcheck->OrderList() != nullptr) + if (item_count > 0 && subcheck->OrderList() != NULL) { item_cost = subcheck->OrderList()->item_cost; if (item_cost > 0) @@ -705,7 +721,7 @@ int CouponInfo::CPAmount(SubCheck *subcheck) else if (flags & TF_ITEM_SPECIFIC) { item_count = Applies(subcheck); - if (item_count > 0 && subcheck->OrderList() != nullptr) + if (item_count > 0 && subcheck->OrderList() != NULL) { item_cost = subcheck->OrderList()->item_cost; if (item_cost > 0) @@ -782,7 +798,7 @@ CreditCardInfo::CreditCardInfo() CreditCardInfo *CreditCardInfo::Copy() { FnTrace("CreditCardInfo::Copy()"); - auto *retcreditcard = new CreditCardInfo(); + CreditCardInfo *retcreditcard = new CreditCardInfo(); retcreditcard->name.Set(name); retcreditcard->id = id; retcreditcard->local = local; @@ -828,7 +844,7 @@ MealInfo::MealInfo() MealInfo *MealInfo::Copy() { FnTrace("MealInfo::Copy()"); - auto *retmeal = new MealInfo(); + MealInfo *retmeal = new MealInfo(); retmeal->name.Set(name); retmeal->id = id; retmeal->amount = amount; @@ -870,8 +886,8 @@ int MealInfo::Write(OutputDataFile &df, int version) TermInfo::TermInfo() { FnTrace("TermInfo::TermInfo()"); - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; type = TERMINAL_NORMAL; sortorder = CHECK_ORDER_NEWOLD; printer_model = 0; @@ -888,8 +904,8 @@ TermInfo::TermInfo() print_workorder = 1; workorder_heading = 0; - for (int & i : tax_inclusive) - i = -1; + for (int i=0; i<4; i++) + tax_inclusive[i] = -1; cc_credit_termid.Set(""); cc_debit_termid.Set(""); @@ -935,8 +951,8 @@ int TermInfo::Read(InputDataFile &df, int version) error += df.Read(workorder_heading); if (version >= 94) { - for (int & i : tax_inclusive) - error += df.Read(i); + for (int i=0; i<4; i++) + error += df.Read(tax_inclusive[i]); } // dpulse is used when there are two drawers attached to one @@ -976,8 +992,8 @@ int TermInfo::Write(OutputDataFile &df, int version) error += df.Write(cc_debit_termid); error += df.Write(print_workorder); error += df.Write(workorder_heading); - for (int i : tax_inclusive) - error += df.Write(i); + for (int i=0; i<4; i++) + error += df.Write(tax_inclusive[i]); return error; } @@ -985,11 +1001,11 @@ int TermInfo::Write(OutputDataFile &df, int version) int TermInfo::OpenTerm(Control *control_db, int update) { FnTrace("TermInfo::OpenTerm()"); - if (control_db == nullptr) + if (control_db == NULL) return 1; Terminal *term = NewTerminal(display_host.Value(), term_hardware, isserver); - if (term == nullptr) + if (term == NULL) return 1; int flag = UPDATE_TERMINALS; @@ -1030,7 +1046,7 @@ int TermInfo::OpenTerm(Control *control_db, int update) term->printer_host.Value(), printer_port, printer_model); - if (printer != nullptr) + if (printer != NULL) { if (drawers == 1) printer->pulse = dpulse; @@ -1044,7 +1060,7 @@ int TermInfo::OpenTerm(Control *control_db, int update) if (update) { term->Initialize(); - control_db->UpdateAll(flag, nullptr); + control_db->UpdateAll(flag, NULL); } return 0; @@ -1053,12 +1069,12 @@ int TermInfo::OpenTerm(Control *control_db, int update) Terminal *TermInfo::FindTerm(Control *control_db) { FnTrace("TermInfo::FindTerm()"); - for (Terminal *term = control_db->TermList(); term != nullptr; term = term->next) + for (Terminal *term = control_db->TermList(); term != NULL; term = term->next) { if (term->host == display_host) return term; } - return nullptr; + return NULL; } Printer *TermInfo::FindPrinter(Control *control_db) @@ -1094,8 +1110,8 @@ int TermInfo::IsServer(int set) PrinterInfo::PrinterInfo() { FnTrace("PrinterInfo::PrinterInfo()"); - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; type = 0; model = 0; port = 0; @@ -1142,7 +1158,7 @@ int PrinterInfo::Write(OutputDataFile &df, int version) int PrinterInfo::OpenPrinter(Control *control_db, int update) { FnTrace("PrinterInfo::OpenPrinter()"); - if (control_db == nullptr) + if (control_db == NULL) return 1; Printer *p = control_db->NewPrinter(host.Value(), port, model); @@ -1152,7 +1168,7 @@ int PrinterInfo::OpenPrinter(Control *control_db, int update) p->SetKitchenMode(kitchen_mode); p->order_margin = order_margin; if (update) - control_db->UpdateAll(UPDATE_PRINTERS, nullptr); + control_db->UpdateAll(UPDATE_PRINTERS, NULL); } return 0; } @@ -1169,10 +1185,8 @@ const char* PrinterInfo::Name() if (name.size() > 0) return name.Value(); else - return FindStringByValue(type, - const_cast(PrinterTypeValue.data()), - const_cast(PrinterTypeName.data()), - UnknownStr); + return FindStringByValue(type, PrinterTypeValue, + PrinterTypeName, UnknownStr); } /**** @@ -1193,7 +1207,7 @@ void PrinterInfo::DebugPrint(int printall) printf(" Type: %d\n", type); printf(" Kitchen Mode: %d\n", kitchen_mode); - if (printall && next != nullptr) + if (printall && next != NULL) next->DebugPrint(printall); } @@ -1225,6 +1239,18 @@ Settings::Settings() quickbooks_auto_export = 0; // Default disabled quickbooks_export_format = 0; // Default to daily format + // Reverse SSH Tunnel Settings + reverse_ssh_enabled = 0; // Default disabled + reverse_ssh_server.Set(""); + reverse_ssh_port = 22; // Default SSH port + reverse_ssh_user.Set(""); + reverse_ssh_local_port = 22; // Default local SSH port + reverse_ssh_remote_port = 0; // Auto-assign remote port + reverse_ssh_key_path.Set("/usr/viewtouch/ssh/reverse_ssh_key"); + reverse_ssh_reconnect_interval = 30; // 30 seconds + reverse_ssh_health_check_interval = 60; // 60 seconds + reverse_ssh_max_retries = 10; // Maximum 10 retries + // Language Settings current_language = LANG_ENGLISH; // Default to English @@ -1583,7 +1609,7 @@ int Settings::Load(const char* file) df.Read(tmp); if (tmp != MODEL_NONE) { - auto *pi = new PrinterInfo; + PrinterInfo *pi = new PrinterInfo; pi->type = PRINTER_REPORT; #ifdef LINUX @@ -1646,11 +1672,10 @@ int Settings::Load(const char* file) // it has to be NONE. This prevents error that might otherwise // be caused by copying CREDITCHEQ data files into MAINSTREET // binaries. - if (authorize_method < 0 || authorize_method > CCAUTH_MAX || - authorize_method != ccauth_defined) - { + if (authorize_method < 0 || authorize_method > CCAUTH_MAX) + authorize_method = CCAUTH_NONE; + else if (authorize_method != ccauth_defined) authorize_method = CCAUTH_NONE; - } df.Read(always_open); } if (version >= 28) @@ -1741,7 +1766,7 @@ int Settings::Load(const char* file) df.Read(pmodel); if (phost.size() > 0) { - auto *pi = new PrinterInfo; + PrinterInfo *pi = new PrinterInfo; pi->host.Set(phost); pi->port = pport; pi->model = pmodel; @@ -1763,7 +1788,7 @@ int Settings::Load(const char* file) if (thost.size() > 0) { - auto *ti = new TermInfo; + TermInfo *ti = new TermInfo; vt_safe_string::safe_format(str, 256, "Term %d", i + 1); ti->name.Set(str); ti->type = ttype; @@ -1776,7 +1801,6 @@ int Settings::Load(const char* file) case 1: break; case 2: ti->drawers = 1; break; case 3: ti->drawers = 2; break; - default: break; } ti->kitchen = tkitchen; Add(ti); @@ -1795,7 +1819,7 @@ int Settings::Load(const char* file) ReportError("Unexpected end of terminals in settings"); return 1; } - auto *ti = new TermInfo; + TermInfo *ti = new TermInfo; ti->Read(df, version); Add(ti); } @@ -1808,7 +1832,7 @@ int Settings::Load(const char* file) ReportError("Unexpected end of printers in settings"); return 1; } - auto *pi = new PrinterInfo; + PrinterInfo *pi = new PrinterInfo; pi->Read(df, version); Add(pi); } @@ -1823,7 +1847,7 @@ int Settings::Load(const char* file) ReportError("Unexpected end of discounts in settings"); return 1; } - auto *ds = new DiscountInfo; + DiscountInfo *ds = new DiscountInfo; ds->Read(df, version); if (ds->name.size() > 0) { @@ -1842,7 +1866,7 @@ int Settings::Load(const char* file) ReportError("Unexpected end of coupons in settings"); return 1; } - auto *cp = new CouponInfo; + CouponInfo *cp = new CouponInfo; cp->Read(df, version); if (cp->name.size() > 0) { @@ -1861,7 +1885,7 @@ int Settings::Load(const char* file) ReportError("Unexpected end of credit cards in settings"); return 1; } - auto *cc = new CreditCardInfo; + CreditCardInfo *cc = new CreditCardInfo; cc->Read(df, version); if (cc->name.size() > 0) { @@ -1880,7 +1904,7 @@ int Settings::Load(const char* file) ReportError("Unexpected end of comps in settings"); return 1; } - auto *cm = new CompInfo; + CompInfo *cm = new CompInfo; cm->Read(df, version); if (cm->name.size() > 0) { @@ -1899,7 +1923,7 @@ int Settings::Load(const char* file) ReportError("Unexpected end of employee meals in settings"); return 1; } - auto *mi = new MealInfo; + MealInfo *mi = new MealInfo; mi->Read(df, version); if (mi->name.size() > 0) { @@ -1920,7 +1944,7 @@ int Settings::Load(const char* file) ReportError("Unexpected end of tax definitions in settings"); return 1; } - auto *tx = new TaxInfo; + TaxInfo *tx = new TaxInfo; tx->Read(df, version); Add(tx); } @@ -1934,7 +1958,7 @@ int Settings::Load(const char* file) ReportError("Unexpected end of money definitions in settings"); return 1; } - auto *my = new MoneyInfo; + MoneyInfo *my = new MoneyInfo; my->Read(df, version); Add(my); } @@ -2019,6 +2043,19 @@ int Settings::Load(const char* file) df.Read(quickbooks_auto_export); df.Read(quickbooks_export_format); } + if (version >= 105) // Reverse SSH tunnel settings + { + df.Read(reverse_ssh_enabled); + df.Read(reverse_ssh_server); + df.Read(reverse_ssh_port); + df.Read(reverse_ssh_user); + df.Read(reverse_ssh_local_port); + df.Read(reverse_ssh_remote_port); + df.Read(reverse_ssh_key_path); + df.Read(reverse_ssh_reconnect_interval); + df.Read(reverse_ssh_health_check_interval); + df.Read(reverse_ssh_max_retries); + } if (version >= 51) df.Read(fast_takeouts); if (version >= 53) @@ -2182,7 +2219,7 @@ int Settings::Load(const char* file) if (!std::ifstream(CONFIG_TAX_FILE).good()) { std::cerr << "Config file does not exist: '" - << CONFIG_TAX_FILE << "'" << '\n'; + << CONFIG_TAX_FILE << "'" << std::endl; } else { ConfFile conf(CONFIG_TAX_FILE, true); // GetValue modifies target only if key exists @@ -2202,7 +2239,7 @@ int Settings::Load(const char* file) if (!std::ifstream(CONFIG_FEES_FILE).good()) { std::cerr << "Config file does not exist: '" - << CONFIG_FEES_FILE << "'" << '\n'; + << CONFIG_FEES_FILE << "'" << std::endl; } else { ConfFile conf(CONFIG_FEES_FILE, true); conf.GetValue(royalty_rate, vars[V_ROYALTY_RATE], sects[S_MISC]); @@ -2219,7 +2256,7 @@ int Settings::Load(const char* file) if (!std::ifstream(CONFIG_FASTFOOD_FILE).good()) { std::cerr << "Config file does not exist: '" - << CONFIG_FASTFOOD_FILE << "'" << '\n'; + << CONFIG_FASTFOOD_FILE << "'" << std::endl; } else { ConfFile conf(CONFIG_FASTFOOD_FILE, true); conf.GetValue(personalize_fast_food, vars[V_PERSONALIZE_FAST_FOOD], sects[S_MISC]); @@ -2348,18 +2385,18 @@ int Settings::Save() } df.Write(term_list.Count()); - for (TermInfo *ti = term_list.Head(); ti != nullptr; ti = ti->next) + for (TermInfo *ti = term_list.Head(); ti != NULL; ti = ti->next) ti->Write(df, SETTINGS_VERSION); df.Write(printer_list.Count()); - for (PrinterInfo *pi = printer_list.Head(); pi != nullptr; pi = pi->next) + for (PrinterInfo *pi = printer_list.Head(); pi != NULL; pi = pi->next) pi->Write(df, SETTINGS_VERSION); df.Write(last_discount_id); count = DiscountCount(LOCAL_MEDIA); df.Write(count); DiscountInfo *discount = discount_list.Head(); - while (discount != nullptr) + while (discount != NULL) { if (discount->IsLocal()) discount->Write(df, SETTINGS_VERSION); @@ -2370,7 +2407,7 @@ int Settings::Save() count = CouponCount(LOCAL_MEDIA); df.Write(count); CouponInfo *coupon = coupon_list.Head(); - while (coupon != nullptr) + while (coupon != NULL) { if (coupon->IsLocal()) coupon->Write(df, SETTINGS_VERSION); @@ -2381,7 +2418,7 @@ int Settings::Save() count = CreditCardCount(LOCAL_MEDIA); df.Write(count); CreditCardInfo *creditcard = creditcard_list.Head(); - while (creditcard != nullptr) + while (creditcard != NULL) { if (creditcard->IsLocal()) creditcard->Write(df, SETTINGS_VERSION); @@ -2392,7 +2429,7 @@ int Settings::Save() count = CompCount(LOCAL_MEDIA); df.Write(count); CompInfo *comp = comp_list.Head(); - while (comp != nullptr) + while (comp != NULL) { if (comp->IsLocal()) comp->Write(df, SETTINGS_VERSION); @@ -2402,17 +2439,17 @@ int Settings::Save() df.Write(last_meal_id); count = meal_list.Count(); df.Write(count); - for (MealInfo *mi = meal_list.Head(); mi != nullptr; mi = mi->next) + for (MealInfo *mi = meal_list.Head(); mi != NULL; mi = mi->next) mi->Write(df, SETTINGS_VERSION); df.Write(last_tax_id); df.Write(tax_list.Count()); - for (TaxInfo *tx = tax_list.Head(); tx != nullptr; tx = tx->next) + for (TaxInfo *tx = tax_list.Head(); tx != NULL; tx = tx->next) tx->Write(df, SETTINGS_VERSION); df.Write(last_money_id); df.Write(money_list.Count()); - for (MoneyInfo *my = money_list.Head(); my != nullptr; my = my->next) + for (MoneyInfo *my = money_list.Head(); my != NULL; my = my->next) my->Write(df, SETTINGS_VERSION); for (i = 0; i < 4; ++i) @@ -2455,6 +2492,16 @@ int Settings::Save() df.Write(quickbooks_export_path); df.Write(quickbooks_auto_export); df.Write(quickbooks_export_format); + df.Write(reverse_ssh_enabled); + df.Write(reverse_ssh_server); + df.Write(reverse_ssh_port); + df.Write(reverse_ssh_user); + df.Write(reverse_ssh_local_port); + df.Write(reverse_ssh_remote_port); + df.Write(reverse_ssh_key_path); + df.Write(reverse_ssh_reconnect_interval); + df.Write(reverse_ssh_health_check_interval); + df.Write(reverse_ssh_max_retries); df.Write(fast_takeouts); df.Write(money_symbol); df.Write(require_drawer_balance); @@ -2539,7 +2586,7 @@ int Settings::Save() if (!fs::is_directory(CONFIG_DIR)) { std::cerr << "Config directory does not exist: '" - << CONFIG_DIR << "' creating it" << '\n'; + << CONFIG_DIR << "' creating it" << std::endl; fs::create_directory(CONFIG_DIR); fs::permissions(CONFIG_DIR, fs::perms::all); // be sure read/write/execute flags are set } @@ -2557,7 +2604,7 @@ int Settings::Save() error += conf.SetValue(tax_HST, vars[V_HST], sects[S_SALES_TAX_CANADA]); error += conf.SetValue(tax_QST, vars[V_QST], sects[S_SALES_TAX_CANADA]); if (! conf.Save()) { - std::cerr << " failed to save tax config file" << '\n'; + std::cerr << " failed to save tax config file" << std::endl; error++; } } @@ -2574,7 +2621,7 @@ int Settings::Save() error += conf.SetValue(credit_cost, vars[V_CREDIT_COST], sects[S_ELEC_TRANS]); error += conf.SetValue(line_item_cost, vars[V_LINE_ITEM_COST], sects[S_ELEC_TRANS]); if (! conf.Save()) { - std::cerr << " failed to save fees config file" << '\n'; + std::cerr << " failed to save fees config file" << std::endl; error++; } } @@ -2586,7 +2633,7 @@ int Settings::Save() error += conf.SetValue(tax_takeout_food, vars[V_TAX_TAKEOUT_FOOD], sects[S_MISC]); if (! conf.Save()) { - std::cerr << " failed to save fastfood config file" << '\n'; + std::cerr << " failed to save fastfood config file" << std::endl; error++; } } @@ -2605,14 +2652,14 @@ int Settings::MediaFirstID(MediaInfo *mi, int idnum) int retid = idnum; MediaInfo *curr = mi; - while (curr != nullptr && curr->Fore() != nullptr) + while (curr != NULL && curr->Fore() != NULL) curr = curr->Fore(); - while (curr != nullptr) + while (curr != NULL) { if (retid < curr->id) { - curr = nullptr; + curr = NULL; } else if (retid > curr->id) { @@ -2635,11 +2682,11 @@ int Settings::MediaIsDupe(MediaInfo *mi, int id, int thresh) int count = 0; // rewind to head - while (mi != nullptr && mi->Fore() != nullptr) + while (mi != NULL && mi->Fore() != NULL) mi = mi->Fore(); // now accumulate a count - while (mi != nullptr) + while (mi != NULL) { if (mi->id == id) count += 1; @@ -2658,13 +2705,16 @@ int Settings::DiscountCount(int local, int active) DiscountInfo *discount = discount_list.Head(); int count = 0; - while (discount != nullptr) + while (discount != NULL) { - if ((local == ALL_MEDIA || local == discount->local) && - (active == ALL_MEDIA || active == discount->active)) - { + if (local == ALL_MEDIA && active == ALL_MEDIA) + count += 1; + else if (local == ALL_MEDIA && active == discount->active) + count += 1; + else if (local == discount->local && active == ALL_MEDIA) + count += 1; + else if (local == discount->local && active == discount->active) count += 1; - } discount = discount->next; } @@ -2677,13 +2727,16 @@ int Settings::CouponCount(int local, int active) CouponInfo *coupon = coupon_list.Head(); int count = 0; - while (coupon != nullptr) + while (coupon != NULL) { - if ((local == ALL_MEDIA || local == coupon->local) && - (active == ALL_MEDIA || active == coupon->active)) - { + if (local == ALL_MEDIA && active == ALL_MEDIA) + count += 1; + else if (local == ALL_MEDIA && active == coupon->active) + count += 1; + else if (local == coupon->local && active == ALL_MEDIA) + count += 1; + else if (local == coupon->local && active == coupon->active) count += 1; - } coupon = coupon->next; } @@ -2696,13 +2749,16 @@ int Settings::CreditCardCount(int local, int active) CreditCardInfo *creditcard = creditcard_list.Head(); int count = 0; - while (creditcard != nullptr) + while (creditcard != NULL) { - if ((local == ALL_MEDIA || local == creditcard->local) && - (active == ALL_MEDIA || active == creditcard->active)) - { + if (local == ALL_MEDIA && active == ALL_MEDIA) + count += 1; + else if (local == ALL_MEDIA && active == creditcard->active) + count += 1; + else if (local == creditcard->local && active == ALL_MEDIA) + count += 1; + else if (local == creditcard->local && active == creditcard->active) count += 1; - } creditcard = creditcard->next; } @@ -2715,13 +2771,16 @@ int Settings::CompCount(int local, int active) CompInfo *comp = comp_list.Head(); int count = 0; - while (comp != nullptr) + while (comp != NULL) { - if ((local == ALL_MEDIA || local == comp->local) && - (active == ALL_MEDIA || active == comp->active)) - { + if (local == ALL_MEDIA && active == ALL_MEDIA) + count += 1; + else if (local == ALL_MEDIA && active == comp->active) + count += 1; + else if (local == comp->local && active == ALL_MEDIA) + count += 1; + else if (local == comp->local && active == comp->active) count += 1; - } comp = comp->next; } @@ -2734,13 +2793,16 @@ int Settings::MealCount(int local, int active) MealInfo *meal = meal_list.Head(); int count = 0; - while (meal != nullptr) + while (meal != NULL) { - if ((local == ALL_MEDIA || local == meal->local) && - (active == ALL_MEDIA || active == meal->active)) - { + if (local == ALL_MEDIA && active == ALL_MEDIA) + count += 1; + else if (local == ALL_MEDIA && active == meal->active) + count += 1; + else if (local == meal->local && active == ALL_MEDIA) + count += 1; + else if (local == meal->local && active == meal->active) count += 1; - } meal = meal->next; } @@ -2785,7 +2847,7 @@ int Settings::LoadMedia(const char* file) ReportError("Unexpected end of discounts in media file"); return 1; } - auto *ds = new DiscountInfo; + DiscountInfo *ds = new DiscountInfo; ds->Read(df, version); if (ds->id < GLOBAL_MEDIA_ID || MediaIsDupe(discount_list.Head(), ds->id)) { @@ -2812,7 +2874,7 @@ int Settings::LoadMedia(const char* file) ReportError("Unexpected end of coupons in media file"); return 1; } - auto *cp = new CouponInfo; + CouponInfo *cp = new CouponInfo; cp->Read(df, version); if (cp->id < GLOBAL_MEDIA_ID || MediaIsDupe(coupon_list.Head(), cp->id)) { @@ -2839,7 +2901,7 @@ int Settings::LoadMedia(const char* file) ReportError("Unexpected end of credit cards in media file"); return 1; } - auto *cc = new CreditCardInfo; + CreditCardInfo *cc = new CreditCardInfo; cc->Read(df, version); if (cc->id < GLOBAL_MEDIA_ID || MediaIsDupe(creditcard_list.Head(), cc->id)) { @@ -2866,7 +2928,7 @@ int Settings::LoadMedia(const char* file) ReportError("Unexpected end of comps in media file"); return 1; } - auto *cm = new CompInfo; + CompInfo *cm = new CompInfo; cm->Read(df, version); if (cm->id < GLOBAL_MEDIA_ID || MediaIsDupe(comp_list.Head(), cm->id)) { @@ -2895,7 +2957,7 @@ int Settings::LoadMedia(const char* file) ReportError("Unexpected end of meals in media file"); return 1; } - auto *mi = new MealInfo; + MealInfo *mi = new MealInfo; mi->Read(df, version); if (mi->id < GLOBAL_MEDIA_ID || MediaIsDupe(meal_list.Head(), mi->id)) { @@ -2935,7 +2997,7 @@ int Settings::SaveMedia() count = DiscountCount(GLOBAL_MEDIA); df.Write(count); DiscountInfo *discount = discount_list.Head(); - while (discount != nullptr) + while (discount != NULL) { if (discount->IsGlobal()) { @@ -2951,7 +3013,7 @@ int Settings::SaveMedia() count = CouponCount(GLOBAL_MEDIA); df.Write(count); CouponInfo *coupon = coupon_list.Head(); - while (coupon != nullptr) + while (coupon != NULL) { if (coupon->IsGlobal()) { @@ -2967,7 +3029,7 @@ int Settings::SaveMedia() count = CreditCardCount(GLOBAL_MEDIA); df.Write(count); CreditCardInfo *creditcard = creditcard_list.Head(); - while (creditcard != nullptr) + while (creditcard != NULL) { if (creditcard->IsGlobal()) { @@ -2983,7 +3045,7 @@ int Settings::SaveMedia() count = CompCount(GLOBAL_MEDIA); df.Write(count); CompInfo *comp = comp_list.Head(); - while (comp != nullptr) + while (comp != NULL) { if (comp->IsGlobal()) { @@ -2999,7 +3061,7 @@ int Settings::SaveMedia() count = MealCount(GLOBAL_MEDIA); df.Write(count); MealInfo *meal = meal_list.Head(); - while (meal != nullptr) + while (meal != NULL) { if (meal->IsGlobal()) { @@ -3042,7 +3104,7 @@ int Settings::SaveAltMedia(const genericChar* altmedia) // Write Discounts outfile.Write(DiscountCount()); DiscountInfo *discount = discount_list.Head(); - while (discount != nullptr) + while (discount != NULL) { if (discount->active > 0) discount->Write(outfile, SETTINGS_VERSION); @@ -3051,7 +3113,7 @@ int Settings::SaveAltMedia(const genericChar* altmedia) // Write Coupons outfile.Write(CouponCount()); CouponInfo *coupon = coupon_list.Head(); - while (coupon != nullptr) + while (coupon != NULL) { if (coupon->active > 0) coupon->Write(outfile, SETTINGS_VERSION); @@ -3060,7 +3122,7 @@ int Settings::SaveAltMedia(const genericChar* altmedia) // Write CreditCards outfile.Write(CreditCardCount()); CreditCardInfo *creditcard = creditcard_list.Head(); - while (creditcard != nullptr) + while (creditcard != NULL) { if (creditcard->active > 0) creditcard->Write(outfile, SETTINGS_VERSION); @@ -3069,7 +3131,7 @@ int Settings::SaveAltMedia(const genericChar* altmedia) // Write Comps outfile.Write(CompCount()); CompInfo *comp = comp_list.Head(); - while (comp != nullptr) + while (comp != NULL) { if (comp->active > 0) comp->Write(outfile, SETTINGS_VERSION); @@ -3078,7 +3140,7 @@ int Settings::SaveAltMedia(const genericChar* altmedia) // Write Meals outfile.Write(MealCount()); MealInfo *meal = meal_list.Head(); - while (meal != nullptr) + while (meal != NULL) { if (meal->active > 0) meal->Write(outfile, SETTINGS_VERSION); @@ -3426,9 +3488,6 @@ int Settings::SetPeriod(TimeInfo &ref, TimeInfo &start, TimeInfo &end, case SP_QUARTER: end += date::months(3); break; - default: - break; - break; case SP_YTD: end += date::years(1); break; @@ -3465,8 +3524,6 @@ int Settings::SetPeriod(TimeInfo &ref, TimeInfo &start, TimeInfo &end, case SP_YTD: start -= date::years(1); break; - default: - break; } // printf("Settings::SetPeriod(): end ref=%d/%d/%d : start=%d/%d/%d : end=%d/%d/%d\n", // ref.Month(), ref.Day(), ref.Year(), start.Month(), start.Day(), start.Year(), end.Month(), end.Day(), end.Year()); @@ -3519,7 +3576,7 @@ char* Settings::StoreNum(char* dest) FnTrace("Settings::StoreNum()"); static char buffer[STRLONG] = ""; - if (dest == nullptr) + if (dest == NULL) dest = buffer; vt_safe_string::safe_format(dest, STRLONG, "%d", store_code); @@ -3529,7 +3586,7 @@ char* Settings::StoreNum(char* dest) static inline int tax_calc(int amount, Flt tax) { - return static_cast(std::round(amount * tax)); + return int(amount * tax + 0.5); // round } int Settings::FigureFoodTax(int amount, TimeInfo &timevar, Flt tax) @@ -3586,7 +3643,7 @@ char* Settings::TenderName(int tender_type, int tender_id, genericChar* str) static const genericChar* name[] = { "Cash Received", "Check", "Gift Certificate", "House Account", "Overage", "Change", "Tip", "Payout", "Money Lost", "Gratuity", "Tips Paid", - "ATM/Debit Card", "Credit Card Tip", "Expenses", "Cash", "Credit Card Fee (Dollar)", "Credit Card Fee (Percent)", nullptr}; + "ATM/Debit Card", "Credit Card Tip", "Expenses", "Cash", "Credit Card Fee (Dollar)", "Credit Card Fee (Percent)", NULL}; static int value[] = { TENDER_CASH, TENDER_CHECK, TENDER_GIFT, TENDER_ACCOUNT, TENDER_OVERAGE, TENDER_CHANGE, TENDER_CAPTURED_TIP, TENDER_PAYOUT, TENDER_MONEY_LOST, @@ -3603,7 +3660,7 @@ char* Settings::TenderName(int tender_type, int tender_id, genericChar* str) Terminal *term = MasterControl->TermListEnd(); char str2[STRLENGTH]; - if (str == nullptr) + if (str == NULL) str = buffer; if (tender_type == TENDER_CHARGE_ROOM) @@ -3666,7 +3723,7 @@ char* Settings::TenderName(int tender_type, int tender_id, genericChar* str) else vt_safe_string::safe_copy(str, STRLENGTH, FindStringByValue(tender_type, value, name, UnknownStr)); - if (term != nullptr) + if (term != NULL) { vt_safe_string::safe_copy(str2, STRLENGTH, term->Translate(str)); vt_safe_string::safe_copy(str, STRLENGTH, str2); @@ -3678,19 +3735,19 @@ char* Settings::TenderName(int tender_type, int tender_id, genericChar* str) int Settings::Add(DiscountInfo *ds) { FnTrace("Settings::Add(DiscountInfo)"); - if (ds == nullptr) + if (ds == NULL) return 1; DiscountInfo *node = discount_list.Head(); if (ds->id < 1) { - if (node != nullptr) + if (node != NULL) ds->id = MediaFirstID(discount_list.Head(), 1); else ds->id = 1; } - while (node != nullptr) + while (node != NULL) { if (ds->id < node->id) { @@ -3700,7 +3757,7 @@ int Settings::Add(DiscountInfo *ds) else node = node->next; } - if (node == nullptr) + if (node == NULL) { discount_list.AddToTail(ds); } @@ -3711,19 +3768,19 @@ int Settings::Add(DiscountInfo *ds) int Settings::Add(CouponInfo *cp) { FnTrace("Settings::Add(CouponInfo)"); - if (cp == nullptr) + if (cp == NULL) return 1; CouponInfo *node = coupon_list.Head(); if (cp->id < 1) { - if (node != nullptr) + if (node != NULL) cp->id = MediaFirstID(coupon_list.Head(), 1); else cp->id = 1; } - while (node != nullptr) + while (node != NULL) { if (cp->id < node->id) { @@ -3733,7 +3790,7 @@ int Settings::Add(CouponInfo *cp) else node = node->next; } - if (node == nullptr) + if (node == NULL) coupon_list.AddToTail(cp); return 0; } @@ -3741,19 +3798,19 @@ int Settings::Add(CouponInfo *cp) int Settings::Add(CreditCardInfo *cc) { FnTrace("Settings::Add(CreditCardInfo)"); - if (cc == nullptr) + if (cc == NULL) return 1; CreditCardInfo *node = creditcard_list.Head(); if (cc->id < 1) { - if (node != nullptr) + if (node != NULL) cc->id = MediaFirstID(creditcard_list.Head(), 1); else cc->id = 1; } - while (node != nullptr) + while (node != NULL) { if (cc->id < node->id) { @@ -3764,7 +3821,7 @@ int Settings::Add(CreditCardInfo *cc) node = node->next; } - if (node == nullptr) + if (node == NULL) creditcard_list.AddToTail(cc); return 0; @@ -3773,19 +3830,19 @@ int Settings::Add(CreditCardInfo *cc) int Settings::Add(CompInfo *cm) { FnTrace("Settings::Add(CompInfo)"); - if (cm == nullptr) + if (cm == NULL) return 1; CompInfo *node = comp_list.Head(); if (cm->id < 1) { - if (node != nullptr) + if (node != NULL) cm->id = MediaFirstID(comp_list.Head(), 1); else cm->id = 1; } - while (node != nullptr) + while (node != NULL) { if (cm->id < node->id) { @@ -3795,7 +3852,7 @@ int Settings::Add(CompInfo *cm) else node = node->next; } - if (node == nullptr) + if (node == NULL) comp_list.AddToTail(cm); return 0; } @@ -3803,19 +3860,19 @@ int Settings::Add(CompInfo *cm) int Settings::Add(MealInfo *mi) { FnTrace("Settings::Add(MealInfo)"); - if (mi == nullptr) + if (mi == NULL) return 1; MealInfo *node = meal_list.Head(); if (mi->id < 1) { - if (node != nullptr) + if (node != NULL) mi->id = MediaFirstID(meal_list.Head(), 1); else mi->id = 1; } - while (node != nullptr) + while (node != NULL) { if (mi->id < node->id) { @@ -3825,7 +3882,7 @@ int Settings::Add(MealInfo *mi) else node = node->next; } - if (node == nullptr) + if (node == NULL) meal_list.AddToTail(mi); return 0; } @@ -3836,7 +3893,7 @@ int Settings::HaveServerTerm() int retval = 0; TermInfo *ti = TermList(); - while (ti != nullptr) + while (ti != NULL) { if (ti->IsServer()) retval += 1; @@ -3927,12 +3984,12 @@ int Settings::Remove(MoneyInfo *my) int Settings::DiscountReport(Terminal *t, Report *r) { FnTrace("Settings::DiscountReport()"); - if (r == nullptr) + if (r == NULL) return 1; int color = COLOR_DEFAULT; DiscountInfo *ds = discount_list.Head(); - if (ds == nullptr) + if (ds == NULL) { r->TextC(t->Translate("No Discount Definitions")); return 0; @@ -3968,12 +4025,12 @@ int Settings::DiscountReport(Terminal *t, Report *r) int Settings::CouponReport(Terminal *t, Report *r) { FnTrace("Settings::CouponReport()"); - if (r == nullptr) + if (r == NULL) return 1; int color = COLOR_DEFAULT; CouponInfo *cp = coupon_list.Head(); - if (cp == nullptr) + if (cp == NULL) { r->TextC(t->Translate("No Coupon Definitions")); return 0; @@ -4009,12 +4066,12 @@ int Settings::CouponReport(Terminal *t, Report *r) int Settings::CreditCardReport(Terminal *t, Report *r) { FnTrace("Settings::CreditCardReport()"); - if (r == nullptr) + if (r == NULL) return 1; int color = COLOR_DEFAULT; CreditCardInfo *cc = creditcard_list.Head(); - if (cc == nullptr) + if (cc == NULL) { r->TextC(t->Translate("No Card Definitions")); return 0; @@ -4045,12 +4102,12 @@ int Settings::CreditCardReport(Terminal *t, Report *r) int Settings::CompReport(Terminal *t, Report *r) { FnTrace("Settings::CompReport()"); - if (r == nullptr) + if (r == NULL) return 1; int color = COLOR_DEFAULT; CompInfo *cm = comp_list.Head(); - if (cm == nullptr) + if (cm == NULL) { r->TextC(t->Translate("No Whole Meal Comp Definitions")); return 0; @@ -4081,11 +4138,11 @@ int Settings::CompReport(Terminal *t, Report *r) int Settings::MealReport(Terminal *t, Report *r) { FnTrace("Settings::MealReport()"); - if (r == nullptr) + if (r == NULL) return 1; MealInfo *mi = meal_list.Head(); - if (mi == nullptr) + if (mi == NULL) { r->TextC(t->Translate("No Employee Discount Definitions")); return 0; @@ -4120,7 +4177,7 @@ int Settings::RemoveInactiveMedia() // Remove inactive discounts DiscountInfo *discount_node = discount_list.Head(); - while (discount_node != nullptr) + while (discount_node != NULL) { if (discount_node->active == 0) { @@ -4133,7 +4190,7 @@ int Settings::RemoveInactiveMedia() // Remove inactive coupons CouponInfo *coupon_node = coupon_list.Head(); - while (coupon_node != nullptr) + while (coupon_node != NULL) { if (coupon_node->active == 0) { @@ -4146,7 +4203,7 @@ int Settings::RemoveInactiveMedia() // Remove inactive comps CompInfo *comp_node = comp_list.Head(); - while (comp_node != nullptr) + while (comp_node != NULL) { if (comp_node->active == 0) { @@ -4159,7 +4216,7 @@ int Settings::RemoveInactiveMedia() // Remove inactive credit cards CreditCardInfo *creditcard_node = creditcard_list.Head(); - while (creditcard_node != nullptr) + while (creditcard_node != NULL) { if (creditcard_node->active == 0) { @@ -4172,7 +4229,7 @@ int Settings::RemoveInactiveMedia() // Remove inactive meals MealInfo *meal_node = meal_list.Head(); - while (meal_node != nullptr) + while (meal_node != NULL) { if (meal_node->active == 0) { @@ -4190,12 +4247,12 @@ int Settings::RemoveInactiveMedia() int Settings::TermReport(Terminal *t, Report *r) { FnTrace("Settings::TermReport()"); - if (r == nullptr) + if (r == NULL) return 1; r->update_flag = UPDATE_TERMINALS | UPDATE_USERS; TermInfo *ti = term_list.Head(); - if (ti == nullptr) + if (ti == NULL) { r->TextC(t->Translate("No Terminal Definitions")); return 0; @@ -4238,13 +4295,13 @@ int Settings::TermReport(Terminal *t, Report *r) int Settings::PrinterReport(Terminal *t, Report *r) { FnTrace("Settings::PrinterReport()"); - if (r == nullptr) + if (r == NULL) return 1; genericChar buffer[STRLENGTH]; r->update_flag = UPDATE_PRINTERS; PrinterInfo *pi = printer_list.Head(); - if (pi == nullptr) + if (pi == NULL) { r->TextC(t->Translate("No Printer Definitions")); return 0; @@ -4266,7 +4323,7 @@ int Settings::PrinterReport(Terminal *t, Report *r) } r->TextPosL(18, buffer); - int idx = CompareList(pi->type, const_cast(PrinterTypeValue.data())); + int idx = CompareList(pi->type, PrinterTypeValue); if (idx < 0) r->TextPosL(38, t->Translate("Unknown Type")); else @@ -4295,8 +4352,8 @@ DiscountInfo *Settings::FindDiscountByRecord(int record) FnTrace("Settings::FindDiscountByRecord()"); int idx = 0; DiscountInfo *discount = discount_list.Head(); - DiscountInfo *retdiscount = nullptr; - while ((discount != nullptr) && (retdiscount == nullptr)) + DiscountInfo *retdiscount = NULL; + while ((discount != NULL) && (retdiscount == NULL)) { if (discount->active) { @@ -4313,12 +4370,12 @@ DiscountInfo *Settings::FindDiscountByRecord(int record) DiscountInfo *Settings::FindDiscountByID(int id) { FnTrace("Settings::FindDiscountByID()"); - for (DiscountInfo *ds = discount_list.Head(); ds != nullptr; ds = ds->next) + for (DiscountInfo *ds = discount_list.Head(); ds != NULL; ds = ds->next) { if (ds->id == id) return ds; } - return nullptr; + return NULL; } CouponInfo *Settings::FindCouponByRecord(int record) @@ -4326,8 +4383,8 @@ CouponInfo *Settings::FindCouponByRecord(int record) FnTrace("Settings::FindCouponByRecord()"); int idx = 0; CouponInfo *coupon = coupon_list.Head(); - CouponInfo *retcoupon = nullptr; - while ((coupon != nullptr) && (retcoupon == nullptr)) + CouponInfo *retcoupon = NULL; + while ((coupon != NULL) && (retcoupon == NULL)) { if (coupon->active) { @@ -4344,26 +4401,26 @@ CouponInfo *Settings::FindCouponByRecord(int record) CouponInfo *Settings::FindCouponByID(int id) { FnTrace("Settings::FindCouponByID()"); - for (CouponInfo *cp = coupon_list.Head(); cp != nullptr; cp = cp->next) + for (CouponInfo *cp = coupon_list.Head(); cp != NULL; cp = cp->next) { if (cp->id == id) return cp; } - return nullptr; + return NULL; } CouponInfo *Settings::FindCouponByItem(SalesItem *item, int aut) { FnTrace("Settings::FindCouponByItem()"); - CouponInfo *retval = nullptr; + CouponInfo *retval = NULL; CouponInfo *coupon = coupon_list.Head(); - while (coupon != nullptr) + while (coupon != NULL) { if (coupon->Applies(item, aut)) { retval = coupon; - coupon = nullptr; + coupon = NULL; } else coupon = coupon->next; @@ -4377,8 +4434,8 @@ CompInfo *Settings::FindCompByRecord(int record) FnTrace("Settings::FindCompByRecord()"); int idx = 0; CompInfo *comp = comp_list.Head(); - CompInfo *retcomp = nullptr; - while ((comp != nullptr) && (retcomp == nullptr)) + CompInfo *retcomp = NULL; + while ((comp != NULL) && (retcomp == NULL)) { if (comp->active) { @@ -4395,12 +4452,12 @@ CompInfo *Settings::FindCompByRecord(int record) CompInfo *Settings::FindCompByID(int id) { FnTrace("Settings::FindCompByID()"); - for (CompInfo *cm = comp_list.Head(); cm != nullptr; cm = cm->next) + for (CompInfo *cm = comp_list.Head(); cm != NULL; cm = cm->next) { if (cm->id == id) return cm; } - return nullptr; + return NULL; } CreditCardInfo *Settings::FindCreditCardByRecord(int record) @@ -4408,8 +4465,8 @@ CreditCardInfo *Settings::FindCreditCardByRecord(int record) FnTrace("Settings::FindCreditCardByRecord()"); int idx = 0; CreditCardInfo *creditcard = creditcard_list.Head(); - CreditCardInfo *retcreditcard = nullptr; - while ((creditcard != nullptr) && (retcreditcard == nullptr)) + CreditCardInfo *retcreditcard = NULL; + while ((creditcard != NULL) && (retcreditcard == NULL)) { if (creditcard->active) { @@ -4426,12 +4483,12 @@ CreditCardInfo *Settings::FindCreditCardByRecord(int record) CreditCardInfo *Settings::FindCreditCardByID(int id) { FnTrace("Settings::FindCreditCardByID()"); - for (CreditCardInfo *cc = creditcard_list.Head(); cc != nullptr; cc = cc->next) + for (CreditCardInfo *cc = creditcard_list.Head(); cc != NULL; cc = cc->next) { if (cc->id == id) return cc; } - return nullptr; + return NULL; } MealInfo *Settings::FindMealByRecord(int record) @@ -4439,8 +4496,8 @@ MealInfo *Settings::FindMealByRecord(int record) FnTrace("Settings::FindMealByRecord()"); int idx = 0; MealInfo *meal = meal_list.Head(); - MealInfo *retmeal = nullptr; - while ((meal != nullptr) && (retmeal == nullptr)) + MealInfo *retmeal = NULL; + while ((meal != NULL) && (retmeal == NULL)) { if (meal->active) { @@ -4457,21 +4514,21 @@ MealInfo *Settings::FindMealByRecord(int record) MealInfo *Settings::FindMealByID(int id) { FnTrace("Settings::FindMealByID()"); - for (MealInfo *mi = meal_list.Head(); mi != nullptr; mi = mi->next) + for (MealInfo *mi = meal_list.Head(); mi != NULL; mi = mi->next) { if (mi->id == id) return mi; } - return nullptr; + return NULL; } TermInfo *Settings::FindServer(const genericChar* displaystr) { FnTrace("Settings::FindServer()"); - TermInfo *retti = nullptr; + TermInfo *retti = NULL; TermInfo *ti = term_list.Head(); - while (ti != nullptr) + while (ti != NULL) { if (ti->IsServer() || (strcmp(displaystr, ti->display_host.Value()) == 0)) { @@ -4481,7 +4538,7 @@ TermInfo *Settings::FindServer(const genericChar* displaystr) ti = ti->next; } - if (retti == nullptr) + if (retti == NULL) { retti = new TermInfo; retti->name.Set("Server"); @@ -4498,10 +4555,10 @@ TermInfo *Settings::FindServer(const genericChar* displaystr) TermInfo *Settings::FindTerminal(const char* displaystr) { FnTrace("Settings:FindTermEntry()"); - TermInfo *retti = nullptr; + TermInfo *retti = NULL; TermInfo *ti = term_list.Head(); - while (ti != nullptr && retti == nullptr) + while (ti != NULL && retti == NULL) { if (strcmp(displaystr, ti->display_host.Value()) == 0) retti = ti; @@ -4527,12 +4584,12 @@ PrinterInfo *Settings::FindPrinterByRecord(int record) PrinterInfo *Settings::FindPrinterByType(int type) { FnTrace("Settings::FindPrinterByType()"); - for (PrinterInfo *pi = printer_list.Head(); pi != nullptr; pi = pi->next) + for (PrinterInfo *pi = printer_list.Head(); pi != NULL; pi = pi->next) { if (pi->type == type) return pi; } - return nullptr; + return NULL; } int Settings::GetDrawerFloatValue() diff --git a/main/data/settings.hh b/main/data/settings.hh index d8f735f4..a23000ef 100644 --- a/main/data/settings.hh +++ b/main/data/settings.hh @@ -18,8 +18,8 @@ * General system settings */ -#ifndef SETTINGS_HH -#define SETTINGS_HH +#ifndef _SETTINGS_HH +#define _SETTINGS_HH #include "utility.hh" #include "list_utility.hh" @@ -42,28 +42,22 @@ constexpr int SETTINGS_VERSION = 106; // READ ABOVE #define MAX_FOOTER_LINES 4 #define MAX_JOBS 20 -// Receipt printing options (converted from macros to enum constants) -enum ReceiptPrintMode : std::uint8_t { - RECEIPT_NONE = 0, - RECEIPT_SEND = 1, - RECEIPT_FINALIZE = 2, - RECEIPT_BOTH = 3 -}; +// Receipt printing options +#define RECEIPT_SEND 1 +#define RECEIPT_FINALIZE 2 +#define RECEIPT_BOTH 3 +#define RECEIPT_NONE 0 -// Drawer report options (converted from macros to enum constants) -enum DrawerPrintMode : std::uint8_t { - DRAWER_PRINT_NEVER = 0, - DRAWER_PRINT_PULL = 1, - DRAWER_PRINT_BALANCE = 2, - DRAWER_PRINT_BOTH = 3 -}; +// Drawer report options +#define DRAWER_PRINT_PULL 1 +#define DRAWER_PRINT_BALANCE 2 +#define DRAWER_PRINT_BOTH 3 +#define DRAWER_PRINT_NEVER 0 -// Cash Drawer options (converted from macros to enum constants) -enum DrawerMode : std::uint8_t { - DRAWER_NORMAL = 0, // unrestricted access to drawers for employees - DRAWER_ASSIGNED = 1, // drawers must be assigned to be used - DRAWER_SERVER = 2 // each server has a drawer to maintain for shift -}; +// Cash Drawer options +#define DRAWER_NORMAL 0 // unrestricted access to drawers for employees +#define DRAWER_ASSIGNED 1 // drawers must be assigned to be used +#define DRAWER_SERVER 2 // each server has a drawer to maintain for shift // Terminal Hardware -- seems to be obsolete, BAK #define HARDWARE_NONE 0 // No additional hardware for terminal @@ -77,7 +71,7 @@ enum DrawerMode : std::uint8_t { #define ROUNDING_UP_GRATUITY 2 // price rounded up to nearest nickel // Meal periods -#define INDEX_ANY (-1) // any period +#define INDEX_ANY -1 // any period #define INDEX_GENERAL 0 // All day #define INDEX_BREAKFAST 1 #define INDEX_BRUNCH 2 @@ -214,7 +208,7 @@ extern int WeekDays[]; #define LOCAL_MEDIA 1 #define GLOBAL_MEDIA 0 -#define ALL_MEDIA (-1) +#define ALL_MEDIA -1 #define GLOBAL_MEDIA_ID 50000 #define ACTIVE_MEDIA 1 @@ -234,7 +228,8 @@ extern int PayPeriodValue[]; extern const genericChar* MealStartName[]; extern int MealStartValue[]; -// DrawerMode uses enum utilities (DrawerModeType) instead of static arrays +extern const genericChar* DrawerModeName[]; +extern int DrawerModeValue[]; extern const genericChar* SaleCreditName[]; extern int SaleCreditValue[]; @@ -242,19 +237,26 @@ extern int SaleCreditValue[]; extern const genericChar* SalesPeriodName[]; extern int SalesPeriodValue[]; -// ReceiptPrint uses enum utilities (ReceiptPrintType) instead of static arrays +extern const genericChar* ReceiptPrintName[]; +extern int ReceiptPrintValue[]; -// DrawerPrint uses enum utilities (DrawerPrintType) instead of static arrays +extern const genericChar* DrawerPrintName[]; +extern int DrawerPrintValue[]; -// Rounding uses enum utilities (PriceRoundingType) instead of static arrays +extern const genericChar* RoundingName[]; +extern int RoundingValue[]; extern const genericChar* PrinterName[]; extern int PrinterValue[]; -// MeasureSystem uses enum utilities (MeasureSystemType) instead of static arrays -// DateFormat uses enum utilities (DateFormatType) instead of static arrays -// NumberFormat uses enum utilities (NumberFormatType) instead of static arrays -// TimeFormat uses enum utilities (TimeFormatType) instead of static arrays +extern const genericChar* MeasureSystemName[]; +extern int MeasureSystemValue[]; +extern const genericChar* DateFormatName[]; +extern int DateFormatValue[]; +extern const genericChar* NumberFormatName[]; +extern int NumberFormatValue[]; +extern const genericChar* TimeFormatName[]; +extern int TimeFormatValue[]; extern const genericChar* AuthorizeName[]; extern int AuthorizeValue[]; @@ -322,7 +324,7 @@ public: int local; MediaInfo(); - virtual ~MediaInfo() = default; + virtual ~MediaInfo() {} virtual MediaInfo *Copy() = 0; virtual int Read(InputDataFile &df, int version) = 0; @@ -346,15 +348,15 @@ public: // Constructor DiscountInfo(); - ~DiscountInfo() override = default; + ~DiscountInfo() {} // Member Functions - DiscountInfo *Copy() override; - int Read(InputDataFile &df, int version) override; - int Write(OutputDataFile &df, int version) override; + DiscountInfo *Copy(); + int Read(InputDataFile &df, int version); + int Write(OutputDataFile &df, int version); - DiscountInfo *Next() override { return next; } - DiscountInfo *Fore() override { return fore; } + DiscountInfo *Next() { return next; } + DiscountInfo *Fore() { return fore; } }; class CompInfo : public MediaInfo @@ -367,15 +369,15 @@ public: // Constructor CompInfo(); - ~CompInfo() override = default; + ~CompInfo() {} // Member Functions - CompInfo *Copy() override; - int Read(InputDataFile &df, int version) override; - int Write(OutputDataFile &df, int version) override; + CompInfo *Copy(); + int Read(InputDataFile &df, int version); + int Write(OutputDataFile &df, int version); - CompInfo *Next() override { return next; } - CompInfo *Fore() override { return fore; } + CompInfo *Next() { return next; } + CompInfo *Fore() { return fore; } }; class CouponInfo : public MediaInfo @@ -399,16 +401,16 @@ public: // Constructor CouponInfo(); - ~CouponInfo() override = default; + ~CouponInfo() {} // Member Functions - CouponInfo *Copy() override; - int Read(InputDataFile &df, int version) override; - int Write(OutputDataFile &df, int version) override; + CouponInfo *Copy(); + int Read(InputDataFile &df, int version); + int Write(OutputDataFile &df, int version); - CouponInfo *Next() override { return next; } - CouponInfo *Fore() override { return fore; } - int Apply(SubCheck *subcheck, Payment *payment = nullptr); + CouponInfo *Next() { return next; } + CouponInfo *Fore() { return fore; } + int Apply(SubCheck *subcheck, Payment *payment = NULL); int Applies(SubCheck *subcheck, int aut = 0); int Applies(SalesItem *item, int aut = 0); int AppliesTime(); @@ -431,12 +433,12 @@ public: CreditCardInfo(); // Member Functions - CreditCardInfo *Copy() override; - int Read(InputDataFile &df, int version) override; - int Write(OutputDataFile &df, int version) override; + CreditCardInfo *Copy(); + int Read(InputDataFile &df, int version); + int Write(OutputDataFile &df, int version); - CreditCardInfo *Next() override { return next; } - CreditCardInfo *Fore() override { return fore; } + CreditCardInfo *Next() { return next; } + CreditCardInfo *Fore() { return fore; } }; class MealInfo : public MediaInfo @@ -452,12 +454,12 @@ public: MealInfo(); // Member Functions - MealInfo *Copy() override; - int Read(InputDataFile &df, int version) override; - int Write(OutputDataFile &df, int version) override; + MealInfo *Copy(); + int Read(InputDataFile &df, int version); + int Write(OutputDataFile &df, int version); - MediaInfo *Next() override { return next; } - MediaInfo *Fore() override { return fore; } + MediaInfo *Next() { return next; } + MediaInfo *Fore() { return fore; } }; class TermInfo @@ -535,11 +537,6 @@ public: void DebugPrint(int printall = 0); }; -#if defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wanalyzer-optin.performance.Padding" -#endif - class Settings { DList discount_list; @@ -582,8 +579,20 @@ public: int quickbooks_auto_export; // Enable automatic daily export int quickbooks_export_format; // Export format (0=daily, 1=monthly, 2=custom) + // Reverse SSH Tunnel Settings + int reverse_ssh_enabled; // Enable reverse SSH tunnel for remote access + Str reverse_ssh_server; // Management server hostname/IP + int reverse_ssh_port; // Management server SSH port (default: 22) + Str reverse_ssh_user; // Remote SSH username on management server + int reverse_ssh_local_port; // Local port to expose (default: 22 for SSH) + int reverse_ssh_remote_port; // Remote port on management server (0 = auto-assign) + Str reverse_ssh_key_path; // Path to SSH private key file + // Language Settings int current_language; // Current language setting (LANG_ENGLISH, LANG_SPANISH, etc.) + int reverse_ssh_reconnect_interval; // Seconds between reconnection attempts + int reverse_ssh_health_check_interval; // Seconds between health checks + int reverse_ssh_max_retries; // Maximum reconnection attempts before giving up // General Settings Str store_name; // printed on title bar @@ -832,11 +841,11 @@ public: char* TenderName( int tender_type, int tender_id, genericChar* str ); // returns text name of tender int LaborPeriod(TimeInfo &ref, TimeInfo &start, TimeInfo &end); - int SetPeriod(TimeInfo &ref, TimeInfo &start, TimeInfo &end, int period_view, TimeInfo *fiscal = nullptr); + int SetPeriod(TimeInfo &ref, TimeInfo &start, TimeInfo &end, int period_view, TimeInfo *fiscal = NULL); // Calculates start & end of periods given reference time int OvertimeWeek(const TimeInfo &ref, TimeInfo &start, TimeInfo &end); // Calculates wage overtime week for given time - char* StoreNum( char* dest = nullptr); + char* StoreNum( char* dest = 0); int MediaFirstID(MediaInfo *mi, int idnum); int MediaIsDupe(MediaInfo *mi, int id, int thresh = 0); @@ -906,7 +915,7 @@ public: // term functions TermInfo *TermList() { return term_list.Head(); } - TermInfo *FindServer(const genericChar* displaystr = nullptr); + TermInfo *FindServer(const genericChar* displaystr = NULL); TermInfo *FindTerminal(const char* displaystr); TermInfo *FindTermByRecord(int record); int TermCount() { return term_list.Count(); } @@ -928,8 +937,4 @@ public: int GetDrawerFloatValue(); }; -#if defined(__clang__) -#pragma clang diagnostic pop -#endif - #endif diff --git a/main/data/settings_enums.hh b/main/data/settings_enums.hh index cc8aab64..d6ae9c33 100644 --- a/main/data/settings_enums.hh +++ b/main/data/settings_enums.hh @@ -24,58 +24,44 @@ #include "src/utils/vt_enum_utils.hh" #include +// Example: Modernized drawer mode enum +enum class DrawerModeType { + Trusted = 0, // DRAWER_NORMAL + Assigned = 1, // DRAWER_ASSIGNED + ServerBank = 2 // DRAWER_SERVER +}; + // Receipt printing options - values must match RECEIPT_* constants -enum class ReceiptPrintType : std::uint8_t { +enum class ReceiptPrintType { Never = 0, // RECEIPT_NONE OnSend = 1, // RECEIPT_SEND OnFinalize = 2, // RECEIPT_FINALIZE OnBoth = 3 // RECEIPT_BOTH }; -// Drawer print options - values must match DRAWER_PRINT_* constants -enum class DrawerPrintType : std::uint8_t { - Never = 0, // DRAWER_PRINT_NEVER - OnPull = 1, // DRAWER_PRINT_PULL - OnBalance = 2, // DRAWER_PRINT_BALANCE - OnBoth = 3 // DRAWER_PRINT_BOTH -}; - -// Drawer mode options - values must match DRAWER_* constants -enum class DrawerModeType : std::uint8_t { - Trusted = 0, // DRAWER_NORMAL - Assigned = 1, // DRAWER_ASSIGNED - ServerBank = 2 // DRAWER_SERVER -}; - -// Price rounding options - values must match ROUNDING_* constants -enum class PriceRoundingType : std::uint8_t { +// Example: Price rounding options +enum class PriceRoundingType { None = 0, // ROUNDING_NONE DropPennies = 1, // ROUNDING_DROP_PENNIES RoundUpGratuity = 2 // ROUNDING_UP_GRATUITY }; -// Measurement system options - values must match MEASURE_* constants -enum class MeasureSystemType : std::uint8_t { - Standard = 1, // MEASURE_STANDARD (U.S./Imperial) - Metric = 2 // MEASURE_METRIC -}; - -// Time format options - values must match TIME_* constants -enum class TimeFormatType : std::uint8_t { - Hour12 = 1, // TIME_12HOUR - Hour24 = 2 // TIME_24HOUR +// Example: Time format options +enum class TimeFormatType { + Hour12 = 0, // TIME_12HOUR + Hour24 = 1 // TIME_24HOUR }; -// Date format options - values must match DATE_* constants -enum class DateFormatType : std::uint8_t { - MMDDYY = 1, // DATE_MMDDYY - DDMMYY = 2 // DATE_DDMMYY +// Example: Date format options +enum class DateFormatType { + MMDDYY = 0, // DATE_MMDDYY + DDMMYY = 1 // DATE_DDMMYY }; -// Number format options - values must match NUMBER_* constants -enum class NumberFormatType : std::uint8_t { - Standard = 1, // NUMBER_STANDARD (1,000,000.00) - Euro = 2 // NUMBER_EURO (1.000.000,00) +// Example: Number format options +enum class NumberFormatType { + Standard = 0, // NUMBER_STANDARD (1,000,000.00) + Euro = 1 // NUMBER_EURO (1.000.000,00) }; // Example: Sales period options @@ -107,18 +93,8 @@ namespace vt { // Helper functions to get display names (translated versions) // These can be used in UI dropdowns, reports, etc. -inline const char* GetReceiptPrintDisplayName(ReceiptPrintType type) { - switch (type) { - case ReceiptPrintType::OnSend: return "On Send"; - case ReceiptPrintType::OnFinalize: return "On Finalize"; - case ReceiptPrintType::OnBoth: return "On Both"; - case ReceiptPrintType::Never: return "Never"; - default: return "Unknown"; - } -} - -inline const char* GetDrawerModeDisplayName(DrawerModeType type) { - switch (type) { +inline const char* GetDrawerModeDisplayName(DrawerModeType mode) { + switch (mode) { case DrawerModeType::Trusted: return "Trusted"; case DrawerModeType::Assigned: return "Assigned"; case DrawerModeType::ServerBank: return "Server Bank"; @@ -126,29 +102,12 @@ inline const char* GetDrawerModeDisplayName(DrawerModeType type) { } } -inline const char* GetDrawerPrintDisplayName(DrawerPrintType type) { - switch (type) { - case DrawerPrintType::OnPull: return "On Pull"; - case DrawerPrintType::OnBalance: return "On Balance"; - case DrawerPrintType::OnBoth: return "On Both"; - case DrawerPrintType::Never: return "Never"; - default: return "Unknown"; - } -} - -inline const char* GetPriceRoundingDisplayName(PriceRoundingType type) { - switch (type) { - case PriceRoundingType::None: return "None"; - case PriceRoundingType::DropPennies: return "Drop Pennies"; - case PriceRoundingType::RoundUpGratuity: return "Round Up Gratuity"; - default: return "Unknown"; - } -} - -inline const char* GetMeasureSystemDisplayName(MeasureSystemType type) { +inline const char* GetReceiptPrintDisplayName(ReceiptPrintType type) { switch (type) { - case MeasureSystemType::Standard: return "Standard U.S."; - case MeasureSystemType::Metric: return "Metric"; + case ReceiptPrintType::OnSend: return "On Send"; + case ReceiptPrintType::OnFinalize: return "On Finalize"; + case ReceiptPrintType::OnBoth: return "On Both"; + case ReceiptPrintType::Never: return "Never"; default: return "Unknown"; } } @@ -193,30 +152,10 @@ inline auto GetAllReceiptPrintOptions() { return GetEnumPairs(); } -inline auto GetAllDrawerPrintOptions() { - return GetEnumPairs(); -} - -inline auto GetAllPriceRoundingOptions() { - return GetEnumPairs(); -} - -inline auto GetAllMeasureSystems() { - return GetEnumPairs(); -} - inline auto GetAllTimeFormats() { return GetEnumPairs(); } -inline auto GetAllDateFormats() { - return GetEnumPairs(); -} - -inline auto GetAllNumberFormats() { - return GetEnumPairs(); -} - } // namespace vt /* @@ -227,7 +166,7 @@ inline auto GetAllNumberFormats() { * --------------------------------------- * const char* DrawerModeName[] = { * GlobalTranslate("Trusted"), GlobalTranslate("Assigned"), - * GlobalTranslate("Server Bank"), nullptr}; + * GlobalTranslate("Server Bank"), NULL}; * int DrawerModeValue[] = { * DRAWER_NORMAL, DRAWER_ASSIGNED, DRAWER_SERVER, -1}; * @@ -245,7 +184,7 @@ inline auto GetAllNumberFormats() { * ✅ No manual array maintenance * ✅ Type-safe conversions * ✅ Compile-time validation - * ✅ No nullptr terminators to forget + * ✅ No NULL terminators to forget * ✅ Automatic JSON serialization * ✅ Better logging with vt::Logger */ diff --git a/main/data/system.cc b/main/data/system.cc index 5aee835a..bd221841 100644 --- a/main/data/system.cc +++ b/main/data/system.cc @@ -60,7 +60,7 @@ System::System() data_path.Set(VIEWTOUCH_PATH "/dat"); temp_path.Set("/tmp"); non_eod_settle = 0; - eod_term = nullptr; + eod_term = NULL; cc_void_db = std::make_unique(CC_DBTYPE_VOID); cc_exception_db = std::make_unique(CC_DBTYPE_EXCEPT); @@ -71,7 +71,7 @@ System::System() cc_details_results = std::make_unique(); cc_saf_details_results = std::make_unique(); cc_settle_results = std::make_unique(); - cc_finish = nullptr; + cc_finish = NULL; cc_report_type = CC_REPORT_BATCH; } @@ -85,7 +85,7 @@ System::~System() int System::InitCurrentDay() { FnTrace("System::InitCurrentDay()"); - for (Drawer *drawer = DrawerList(); drawer != nullptr; drawer = drawer->next) + for (Drawer *drawer = DrawerList(); drawer != NULL; drawer = drawer->next) drawer->Total(CheckList()); CreateFixedDrawers(); @@ -96,11 +96,11 @@ int System::InitCurrentDay() int System::LoadCurrentData(const char* path) { FnTrace("System::LoadCurrentData()"); - if (path == nullptr) + if (path == NULL) return 1; DIR *dp = opendir(path); - if (dp == nullptr) + if (dp == NULL) { ReportError("Can't find current data directory"); return 1; @@ -109,7 +109,7 @@ int System::LoadCurrentData(const char* path) current_path.Set(path); char str[256]; const char* name; - struct dirent *record = nullptr; + struct dirent *record = NULL; do { record = readdir(dp); @@ -122,8 +122,8 @@ int System::LoadCurrentData(const char* path) if (strncmp(name, "check_", 6) == 0) { vt_safe_string::safe_format(str, 256, "%s/%s", path, name); - auto *check = new Check; - if (check == nullptr) + Check *check = new Check; + if (check == NULL) ReportError("Couldn't create check"); else { @@ -139,8 +139,8 @@ int System::LoadCurrentData(const char* path) else if (strncmp(name, "drawer_", 7) == 0) { vt_safe_string::safe_format(str, 256, "%s/%s", path, name); - auto *drawer = new Drawer; - if (drawer == nullptr) + Drawer *drawer = new Drawer; + if (drawer == NULL) ReportError("Couldn't Create Drawer"); else { @@ -212,13 +212,13 @@ int System::ScanArchives(const char* path, const char* altmedia) archive_path.Set(path); DIR *dp = opendir(archive_path.Value()); - if (dp == nullptr) + if (dp == NULL) { ReportError("Can't find archive directory"); return 1; } - struct dirent *record = nullptr; + struct dirent *record = NULL; do { record = readdir(dp); @@ -235,9 +235,9 @@ int System::ScanArchives(const char* path, const char* altmedia) genericChar str[256]; vt_safe_string::safe_format(str, 256, "%s/%s", archive_path.Value(), name); - auto *archive = new Archive(&settings, str); + Archive *archive = new Archive(&settings, str); archive->altmedia.Set(altmedia); - if (archive == nullptr) + if (archive == NULL) ReportError("Couldn't create archive"); else { @@ -283,7 +283,7 @@ int System::UnloadArchives() FnTrace("System::UnloadArchives()"); Archive *archive = ArchiveList(); - while (archive != nullptr) + while (archive != NULL) { archive->Unload(); archive = archive->next; @@ -294,7 +294,7 @@ int System::UnloadArchives() int System::Add(Archive *archive) { FnTrace("System::Add(Archive)"); - if (archive == nullptr) + if (archive == NULL) return 1; // Add failed // start at end of list and work backwords @@ -314,9 +314,9 @@ int System::Remove(Archive *archive) Archive *System::NewArchive() { FnTrace("System::NewArchive()"); - auto *archive = new Archive(SystemTime); - if (archive == nullptr) - return nullptr; + Archive *archive = new Archive(SystemTime); + if (archive == NULL) + return NULL; genericChar str[256]; archive->id = ++last_archive_id; @@ -333,7 +333,7 @@ Archive *System::FindByTime(const TimeInfo &timevar) { FnTrace("System::FindByTime()"); Archive *archive = ArchiveListEnd(); - Archive *last = nullptr; + Archive *last = NULL; while (archive) { if (timevar >= archive->end_time) @@ -351,7 +351,7 @@ Archive *System::FindByStart(TimeInfo &timevar) return ArchiveList(); Archive *archive = ArchiveListEnd(); - Archive *last = nullptr; + Archive *last = NULL; while (archive) { if (timevar > archive->end_time) @@ -362,14 +362,14 @@ Archive *System::FindByStart(TimeInfo &timevar) if (last) return last->next; else - return nullptr; + return NULL; } int System::SaveChanged() { FnTrace("System::SaveChanged()"); - for (Archive *archive = ArchiveList(); archive != nullptr; archive = archive->next) + for (Archive *archive = ArchiveList(); archive != NULL; archive = archive->next) { if (archive->changed) archive->SavePacked(); @@ -384,7 +384,7 @@ int System::Add(Check *check) int retval = 0; int done = 0; Check *currcheck = CheckListEnd(); - if (check == nullptr) + if (check == NULL) return 1; if (check->serial_number <= 0) @@ -392,12 +392,12 @@ int System::Add(Check *check) if (check->serial_number > last_serial_number) last_serial_number = check->serial_number; - check->archive = nullptr; - if (currcheck == nullptr) + check->archive = NULL; + if (currcheck == NULL) retval = check_list.AddToTail(check); else { - while (currcheck != nullptr && !done) + while (currcheck != NULL && !done) { if (check->serial_number > currcheck->serial_number) { @@ -416,7 +416,7 @@ int System::Add(Check *check) int System::Remove(Check *check) { - if (check == nullptr || check->archive) + if (check == NULL || check->archive) return 1; return check_list.Remove(check); @@ -425,10 +425,10 @@ int System::Remove(Check *check) int System::Add(Drawer *drawer) { FnTrace("System::Add(Drawer)"); - if (drawer == nullptr) + if (drawer == NULL) return 1; - drawer->archive = nullptr; + drawer->archive = NULL; if (drawer->serial_number <= 0) drawer->serial_number = NewSerialNumber(); else if (drawer->serial_number > last_serial_number) @@ -444,7 +444,7 @@ int System::Add(Drawer *drawer) int System::Remove(Drawer *drawer) { - if (drawer == nullptr || drawer->archive) + if (drawer == NULL || drawer->archive) return 1; return drawer_list.Remove(drawer); @@ -499,7 +499,7 @@ int System::EndDay() tip_db.Update(this); Archive *archive = NewArchive(); - if (archive == nullptr) + if (archive == NULL) return 1; archive->cc_exception_db = cc_exception_db->Copy(); @@ -548,7 +548,7 @@ int System::EndDay() // Move all open checks to temp check list DList tmp_list; - Check *tmp = nullptr; + Check *tmp = NULL; check = CheckList(); while (check) { @@ -557,7 +557,7 @@ int System::EndDay() check = check_next; // Only add to list if ExtractOpenCheck returned a valid check - if (tmp != nullptr) + if (tmp != NULL) tmp_list.AddToTail(tmp); } @@ -598,31 +598,31 @@ int System::EndDay() // Copy media data into the archive DiscountInfo *discount = settings.DiscountList(); - while (discount != nullptr) + while (discount != NULL) { archive->Add(discount->Copy()); discount = discount->next; } CouponInfo *coupon = settings.CouponList(); - while (coupon != nullptr) + while (coupon != NULL) { archive->Add(coupon->Copy()); coupon = coupon->next; } CreditCardInfo *creditcard = settings.CreditCardList(); - while (creditcard != nullptr) + while (creditcard != NULL) { archive->Add(creditcard->Copy()); creditcard = creditcard->next; } CompInfo *comp = settings.CompList(); - while (comp != nullptr) + while (comp != NULL) { archive->Add(comp->Copy()); comp = comp->next; } MealInfo *meal = settings.MealList(); - while (meal != nullptr) + while (meal != NULL) { archive->Add(meal->Copy()); meal = meal->next; @@ -690,14 +690,14 @@ int System::CheckEndDay(Terminal *term) Drawer *drawer = DrawerList(); Check *check = CheckList(); - while (drawer != nullptr && retval == 0) + while (drawer != NULL && retval == 0) { if (!drawer->IsEmpty()) retval = 1; drawer = drawer->next; } - while (check != nullptr) + while (check != NULL) { retval += 1; check = check->next; @@ -709,7 +709,7 @@ int System::CheckEndDay(Terminal *term) int System::SetDataPath(const char* path) { FnTrace("System::SetDataPath()"); - if (path == nullptr) + if (path == NULL) return 1; genericChar str[256] = ""; @@ -862,7 +862,7 @@ char* System::FullPath(const char* filename, genericChar* buffer) FnTrace("System::FullPath()"); static genericChar str[256]; - if (buffer == nullptr) + if (buffer == NULL) buffer = str; vt_safe_string::safe_format(buffer, 256, "%s/%s", data_path.Value(), filename); @@ -903,7 +903,7 @@ char* System::NewPrintFile(char* str) FnTrace("System::NewPrintFile()"); static int counter = 0; static genericChar buffer[256]; - if (str == nullptr) + if (str == NULL) str = buffer; ++counter; @@ -989,7 +989,7 @@ int System::CountOpenChecks(Employee *e) now.Set(); now += std::chrono::minutes(60); - for (Check *check = CheckList(); check != nullptr; check = check->next) + for (Check *check = CheckList(); check != NULL; check = check->next) { if (check->IsTraining()) continue; @@ -1021,11 +1021,11 @@ int System::CountOpenChecks(Employee *e) int System::NumberStacked(const char* table, Employee *e) { FnTrace("System::NumberStacked()"); - if (e == nullptr) + if (e == NULL) return 0; int count = 0; - for (Check *check = CheckList(); check != nullptr; check = check->next) + for (Check *check = CheckList(); check != NULL; check = check->next) if (check->IsTraining() == e->training && check->GetStatus() == CHECK_OPEN && strcmp(check->Table(), table) == 0) ++count; @@ -1035,10 +1035,10 @@ int System::NumberStacked(const char* table, Employee *e) Check *System::FindOpenCheck(const char* table, Employee *e) { FnTrace("System::FindOpenCheck()"); - if (e == nullptr) - return nullptr; + if (e == NULL) + return NULL; - for (Check *check = CheckListEnd(); check != nullptr; check = check->fore) + for (Check *check = CheckListEnd(); check != NULL; check = check->fore) { if (check->IsTraining() == e->training && strcmp(check->Table(), table) == 0 && check->GetStatus() == CHECK_OPEN) @@ -1046,21 +1046,21 @@ Check *System::FindOpenCheck(const char* table, Employee *e) return check; } } - return nullptr; + return NULL; } Check *System::FindCheckByID(int check_id) { FnTrace("System::FindCheckByID()"); - Check *retval = nullptr; + Check *retval = NULL; Check *currcheck = CheckList(); - while (currcheck != nullptr) + while (currcheck != NULL) { if (currcheck->serial_number == check_id) { retval = currcheck; - currcheck = nullptr; + currcheck = NULL; } else currcheck = currcheck->next; @@ -1072,12 +1072,12 @@ Check *System::FindCheckByID(int check_id) Check *System::ExtractOpenCheck(Check *check) { FnTrace("System::ExtractOpenCheck()"); - if (check == nullptr || check->IsTraining()) - return nullptr; + if (check == NULL || check->IsTraining()) + return NULL; SubCheck *sc; int count = 0; - for (sc = check->SubList(); sc != nullptr; sc = sc->next) + for (sc = check->SubList(); sc != NULL; sc = sc->next) { if (sc->status == CHECK_OPEN) ++count; @@ -1090,9 +1090,9 @@ Check *System::ExtractOpenCheck(Check *check) return check; } else if (count <= 0) - return nullptr; // no closed sub-checks + return NULL; // no closed sub-checks - auto *oc = new Check; + Check *oc = new Check; oc->Table(check->Table()); oc->time_open = check->time_open; oc->user_open = check->user_open; @@ -1124,7 +1124,7 @@ Check *System::ExtractOpenCheck(Check *check) int System::SaveCheck(Check *check) { FnTrace("System::SaveCheck()"); - if (check == nullptr || check->IsTraining() || check->archive) + if (check == NULL || check->IsTraining() || check->archive) return 1; if (check->serial_number <= 0) @@ -1178,7 +1178,7 @@ int System::DestroyCheck(Check *check) return 1; check->DestroyFile(); } - check->customer = nullptr; + check->customer = NULL; delete check; return 0; } @@ -1186,10 +1186,10 @@ int System::DestroyCheck(Check *check) Drawer *System::GetServerBank(Employee *e) { FnTrace("System::GetServerBank()"); - if (e == nullptr || e->training) - return nullptr; + if (e == NULL || e->training) + return NULL; - Drawer *drawer = nullptr; + Drawer *drawer = NULL; if (DrawerList()) drawer = DrawerList()->FindByOwner(e, DRAWER_OPEN); if (drawer) @@ -1209,14 +1209,14 @@ int System::CreateFixedDrawers() // Scan System for drawers that need to be created int drawer_no = 1; - for (Terminal *term = MasterControl->TermList(); term != nullptr; term = term->next) + for (Terminal *term = MasterControl->TermList(); term != NULL; term = term->next) { for (int i = 0; i < term->drawer_count; ++i) { - Drawer *drawer = nullptr; + Drawer *drawer = NULL; if (DrawerList()) drawer = DrawerList()->FindByNumber(drawer_no); - if (drawer == nullptr) + if (drawer == NULL) { drawer = new Drawer(SystemTime); Add(drawer); @@ -1256,7 +1256,7 @@ int System::CountDrawersOwned(int user_id) { FnTrace("System::CoundDrawersOwned()"); int count = 0; - for (Drawer *drawer = DrawerList(); drawer != nullptr; drawer = drawer->next) + for (Drawer *drawer = DrawerList(); drawer != NULL; drawer = drawer->next) if (drawer->owner_id == user_id && drawer->GetStatus() == DRAWER_OPEN) ++count; return count; @@ -1265,7 +1265,7 @@ int System::CountDrawersOwned(int user_id) int System::AllDrawersPulled() { FnTrace("System::AllDrawersPulled()"); - for (Drawer *drawer = DrawerList(); drawer != nullptr; drawer = drawer->next) + for (Drawer *drawer = DrawerList(); drawer != NULL; drawer = drawer->next) if (drawer->GetStatus() == DRAWER_OPEN && !drawer->IsEmpty()) return 0; // false return 1; // true @@ -1275,13 +1275,13 @@ int System::AddBatch(long long batchnum) { FnTrace("System::AddBatch()"); int retval = 0; - BatchItem *newbatch = nullptr; + BatchItem *newbatch = NULL; BatchItem *currbatch = BatchList.Head(); int done = 1; if (batchnum > 0) { - if (currbatch == nullptr) + if (currbatch == NULL) { newbatch = new BatchItem(batchnum); BatchList.AddToHead(newbatch); @@ -1290,7 +1290,7 @@ int System::AddBatch(long long batchnum) { while (!done) { - if (currbatch == nullptr) + if (currbatch == NULL) { // add to tail newbatch = new BatchItem(batchnum); BatchList.AddToTail(newbatch); @@ -1343,7 +1343,7 @@ void System::ClearCapturedTips(TimeInfo &start_time, { if (check->IsTraining() > 0) continue; - for (SubCheck *subcheck = check->SubList(); subcheck != nullptr; subcheck = subcheck->next) + for (SubCheck *subcheck = check->SubList(); subcheck != NULL; subcheck = subcheck->next) subcheck->ClearTips(); } @@ -1353,7 +1353,7 @@ void System::ClearCapturedTips(TimeInfo &start_time, else tip_db.ClearHeld(); - if (a == nullptr || archive) + if (a == NULL || archive) break; if (a->end_time >= end) break; diff --git a/main/data/system.hh b/main/data/system.hh index fa2fae2c..755cca5e 100644 --- a/main/data/system.hh +++ b/main/data/system.hh @@ -18,8 +18,8 @@ * Data storage & report generation for current/previous business days */ -#ifndef SYSTEM_HH -#define SYSTEM_HH +#ifndef _SYSTEM_HH +#define _SYSTEM_HH #include "tips.hh" #include "labor.hh" @@ -159,7 +159,7 @@ public: int SetDataPath(const char* path); // specify directory where system data is kept int CheckFileUpdates(); - genericChar* FullPath(const char* filename, genericChar* buffer = nullptr); + genericChar* FullPath(const char* filename, genericChar* buffer = NULL); // returns string containing full filename for system datafile int LoadCurrentData(const char* path); // loads current day's data ('current' directory) @@ -199,9 +199,9 @@ public: // adds check to current data int Remove(Check *check); // removes check from current check list (doesn't delete) - Check *FirstCheck(Archive *archive = nullptr); + Check *FirstCheck(Archive *archive = NULL); // returns first check of archive or current checks - int CountOpenChecks(Employee *e = nullptr); + int CountOpenChecks(Employee *e = NULL); // counts open checks owned by user (or by everyone) int NumberStacked(const char* table, Employee *e); // Returns number of open checks at tables @@ -220,7 +220,7 @@ public: // adds drawer to current data int Remove(Drawer *drawer); // removes drawer from current drawer list (doesn't delete) - Drawer *FirstDrawer(Archive *archive = nullptr); + Drawer *FirstDrawer(Archive *archive = NULL); // returns first drawer of archive or current drawers Drawer *GetServerBank(Employee *e); // returns server bank for user (creates new one if needed) @@ -234,11 +234,11 @@ public: // boolean - are all drawers pulled or balanced? // Exception functions - ItemException *FirstItemException(Archive *archive = nullptr); + ItemException *FirstItemException(Archive *archive = NULL); // returns first item exception of archive or current exceptions - TableException *FirstTableException(Archive *archive = nullptr); + TableException *FirstTableException(Archive *archive = NULL); // returns first table exception of archive or current exceptions - RebuildException *FirstRebuildException(Archive *archive = nullptr); + RebuildException *FirstRebuildException(Archive *archive = NULL); // returns first rebuild exception of archive or current exceptions // report functions (see system_report.cc) @@ -269,7 +269,7 @@ public: Archive *archive, Report *report, ReportZone *rzone); int CreditCardReport(Terminal *term, TimeInfo &start_time, TimeInfo &end_time, Archive *archive, Report *report, ReportZone *rzone); - int QuickBooksCSVExport(Terminal *term, const TimeInfo& start_time, const TimeInfo& end_time, + int QuickBooksCSVExport(Terminal *term, TimeInfo start_time, TimeInfo end_time, PrinterQuickBooksCSV *printer); int AddBatch(long long batchnum); }; diff --git a/main/hardware/cdu.cc b/main/hardware/cdu.cc index 5c093d0d..6f683531 100644 --- a/main/hardware/cdu.cc +++ b/main/hardware/cdu.cc @@ -155,7 +155,8 @@ int CDUString::IsBlank() * class CDUStrings ********************************************************************/ CDUStrings::CDUStrings() -= default; +{ +} int CDUStrings::Read(InputDataFile &infile, int version) { @@ -181,7 +182,7 @@ int CDUStrings::Write(OutputDataFile &outfile, int version) CDUString *currString = strings.Head(); outfile.Write(strings.Count()); - while (currString != nullptr) + while (currString != NULL) { currString->Write(outfile, version); currString = currString->next; @@ -197,7 +198,7 @@ int CDUStrings::Load(const char* path) int version = 0; int result = 0; - if (path != nullptr) + if (path != NULL) vt_safe_string::safe_copy(filename, STRLONG, path); result = infile.Open(filename, version); @@ -213,7 +214,7 @@ int CDUStrings::Save(const char* path) OutputDataFile outfile; int result = 0; - if (path != nullptr) + if (path != NULL) vt_safe_string::safe_copy(filename, STRLONG, path); RemoveBlank(); @@ -228,14 +229,14 @@ int CDUStrings::RemoveBlank() { FnTrace("CDUStrings::RemoveBlank()"); CDUString *currString = strings.Head(); - CDUString *prevString = nullptr; + CDUString *prevString = NULL; - while (currString != nullptr) + while (currString != NULL) { if (currString->IsBlank()) { Remove(currString); - if (prevString != nullptr) + if (prevString != NULL) currString = prevString->next; else currString = strings.Head(); @@ -253,7 +254,7 @@ int CDUStrings::RemoveBlank() int CDUStrings::Remove(CDUString *cdustring) { FnTrace("CDUStrings::Remove()"); - if (cdustring == nullptr) + if (cdustring == NULL) return 1; strings.RemoveSafe(cdustring); @@ -263,7 +264,7 @@ int CDUStrings::Remove(CDUString *cdustring) CDUString *CDUStrings::GetString(int idx) { FnTrace("CDUStrings::GetString()"); - CDUString *retString = nullptr; + CDUString *retString = NULL; CDUString *currString = strings.Head(); int record = 0; int count = strings.Count(); @@ -279,7 +280,7 @@ CDUString *CDUStrings::GetString(int idx) randnum = count - 1; idx = randnum; } - while ((currString != nullptr) && (record <= idx)) + while ((currString != NULL) && (record <= idx)) { if (record == idx) retString = currString; @@ -298,10 +299,10 @@ CDUString *CDUStrings::FindByRecord(int record) CDUString *CDUStrings::FindByID(int id) { FnTrace("CDUStrings::FindByID()"); - CDUString *retString = nullptr; + CDUString *retString = NULL; CDUString *currString = strings.Head(); - while (currString != nullptr && retString == nullptr) + while (currString != NULL && retString == NULL) { if (id == currString->id) retString = currString; @@ -322,7 +323,7 @@ CDUString *CDUStrings::NewString() CDUString *newstring = new CDUString(); CDUString *laststring = strings.Tail(); - if (laststring == nullptr) + if (laststring == NULL) newstring->id = 1; else newstring->id = laststring->id + 1; @@ -403,7 +404,8 @@ CustDispUnit::CustDispUnit(const char* filename, int verbose, int allow_delay) // Destructor CustDispUnit::~CustDispUnit() -= default; +{ +} int CustDispUnit::ParseFileName() { @@ -459,7 +461,7 @@ int CustDispUnit::SocketOpen() struct sockaddr_in their_addr; // connector's address information he = gethostbyname(target); // get the host info - if (he == nullptr) { + if (he == NULL) { perror("gethostbyname"); return -1; } @@ -614,12 +616,12 @@ int CustDispUnit::Refresh(int cycles) int CustDispUnit::ShowString(CDUStrings *stringlist, int idx, int style) { FnTrace("CustDispUnit::ShowString()"); - CDUString *cdustring = nullptr; + CDUString *cdustring = NULL; int retval = 0; int randnum; cdustring = stringlist->GetString(idx); - if (cdustring == nullptr) + if (cdustring == NULL) return 1; if (style == CDU_STYLE_RANDOM) @@ -752,7 +754,8 @@ EpsonDispUnit::EpsonDispUnit(const char* filename, int verbose, int allow_delay) } EpsonDispUnit::~EpsonDispUnit() -= default; +{ +} int EpsonDispUnit::SetAttributes(int fd) { @@ -895,7 +898,8 @@ BA63DispUnit::BA63DispUnit(const char* filename, int verbose, int allow_delay) } BA63DispUnit::~BA63DispUnit() -= default; +{ +} int BA63DispUnit::SetAttributes(int fd) { @@ -979,7 +983,7 @@ int BA63DispUnit::Brightness(int level) CustDispUnit *NewCDUObject(const char* filename, int type) { FnTrace("NewCDUObject()"); - CustDispUnit *CDURetval = nullptr; + CustDispUnit *CDURetval = NULL; if (type == CDU_TYPE_EPSON) CDURetval = new EpsonDispUnit(filename); if (type == CDU_TYPE_BA63) diff --git a/main/hardware/cdu.hh b/main/hardware/cdu.hh index 21c7a241..502f1104 100644 --- a/main/hardware/cdu.hh +++ b/main/hardware/cdu.hh @@ -93,7 +93,7 @@ public: int Read(InputDataFile &infile, int version); int Write(OutputDataFile &outfile, int version); int Load(const char* path); - int Save(const char* path = nullptr); + int Save(const char* path = NULL); int RemoveBlank(); int Remove(CDUString *cdustr); CDUString *GetString(int idx = -1); @@ -167,18 +167,18 @@ public: EpsonDispUnit(const char* filename, int verbose); EpsonDispUnit(const char* filename, int verbose, int allow_delay); - ~EpsonDispUnit() override; + virtual ~EpsonDispUnit(); - int Type() override { return CDU_TYPE_EPSON; } - int SetAttributes(int fd) override; - int NewLine() override; - int Home() override; - int ToPos(int x, int y) override; - int Clear() override; - int Test() override; - int SetTimer(int hour = -1, int minute = -1) override; - int Timer() override; - int Brightness(int level) override; + virtual int Type() { return CDU_TYPE_EPSON; } + virtual int SetAttributes(int fd); + virtual int NewLine(); + virtual int Home(); + virtual int ToPos(int x, int y); + virtual int Clear(); + virtual int Test(); + virtual int SetTimer(int hour = -1, int minute = -1); + virtual int Timer(); + virtual int Brightness(int level); }; /*-------------------------------------------------------------------- @@ -190,18 +190,18 @@ public: BA63DispUnit(const char* filename); BA63DispUnit(const char* filename, int verbose); BA63DispUnit(const char* filename, int verbose, int allow_delay); - ~BA63DispUnit() override; - - int Type() override { return CDU_TYPE_EPSON; } - int SetAttributes(int fd) override; - int NewLine() override; - int Home() override; - int ToPos(int x, int y) override; - int Clear() override; - int Test() override; - int SetTimer(int hour = -1, int minute = -1) override; - int Timer() override; - int Brightness(int level) override; + virtual ~BA63DispUnit(); + + virtual int Type() { return CDU_TYPE_EPSON; } + virtual int SetAttributes(int fd); + virtual int NewLine(); + virtual int Home(); + virtual int ToPos(int x, int y); + virtual int Clear(); + virtual int Test(); + virtual int SetTimer(int hour = -1, int minute = -1); + virtual int Timer(); + virtual int Brightness(int level); }; /*-------------------------------------------------------------------- diff --git a/main/hardware/drawer.cc b/main/hardware/drawer.cc index 2aded603..9361e321 100644 --- a/main/hardware/drawer.cc +++ b/main/hardware/drawer.cc @@ -42,8 +42,8 @@ // Constructors DrawerPayment::DrawerPayment() { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; tender_type = TENDER_CASH; amount = 0; user_id = 0; @@ -52,8 +52,8 @@ DrawerPayment::DrawerPayment() DrawerPayment::DrawerPayment(int tender, int amt, int user, TimeInfo &timevar, int target) { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; tender_type = tender; amount = amt; user_id = user; @@ -96,8 +96,8 @@ int DrawerPayment::Write(OutputDataFile &df, [[maybe_unused]] int version) // Contructor DrawerBalance::DrawerBalance() { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; tender_type = TENDER_CHECK; tender_id = 0; amount = 0; @@ -107,8 +107,8 @@ DrawerBalance::DrawerBalance() DrawerBalance::DrawerBalance(int type, int id) { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; tender_type = type; tender_id = id; amount = 0; @@ -149,7 +149,7 @@ Drawer::Drawer() owner_id = 0; puller_id = 0; - term = nullptr; + term = NULL; serial_number = 0; number = 0; total_difference = 0; @@ -157,7 +157,7 @@ Drawer::Drawer() total_payments = 0; position = 0; media_balanced = 0; - archive = nullptr; + archive = NULL; } Drawer::Drawer(TimeInfo &timevar) @@ -167,7 +167,7 @@ Drawer::Drawer(TimeInfo &timevar) start_time = timevar; owner_id = 0; puller_id = 0; - term = nullptr; + term = NULL; serial_number = 0; number = 0; total_difference = 0; @@ -175,7 +175,7 @@ Drawer::Drawer(TimeInfo &timevar) total_payments = 0; position = 0; media_balanced = 0; - archive = nullptr; + archive = NULL; } // Member Functions @@ -289,13 +289,13 @@ int Drawer::Write(OutputDataFile &df, int version) // save drawer balances int count = 0; - for (balance = balance_list.Head(); balance != nullptr; balance = balance->next) + for (balance = balance_list.Head(); balance != NULL; balance = balance->next) { if (balance->entered) ++count; } error += df.Write(count, 1); - for (balance = balance_list.Head(); balance != nullptr; balance = balance->next) + for (balance = balance_list.Head(); balance != NULL; balance = balance->next) { if (balance->entered) error += balance->Write(df, version); @@ -303,7 +303,7 @@ int Drawer::Write(OutputDataFile &df, int version) // save drawer payments error += df.Write(payment_list.Count(), 1); - for (dpaymnt = payment_list.Head(); dpaymnt != nullptr; dpaymnt = dpaymnt->next) + for (dpaymnt = payment_list.Head(); dpaymnt != NULL; dpaymnt = dpaymnt->next) { error += dpaymnt->Write(df, version); } @@ -409,20 +409,20 @@ int Drawer::Count() { FnTrace("Drawer::Count()"); int count = 1; - for (Drawer *d = next; d != nullptr; d = d->next) + for (Drawer *d = next; d != NULL; d = d->next) ++count; return count; } -#define COL (-9) +#define COL -9 int Drawer::MakeReport(Terminal *my_term, Check *check_list, Report *r) { FnTrace("Drawer::MakeReport()"); - if (r == nullptr) + if (r == NULL) return 1; r->update_flag = UPDATE_ARCHIVE | UPDATE_CHECKS | UPDATE_SERVER; - if (term == nullptr) + if (term == NULL) term = my_term; System *sys = term->system_data; Settings *s = &(sys->settings); @@ -446,14 +446,14 @@ int Drawer::MakeReport(Terminal *my_term, Check *check_list, Report *r) // write hostname Terminal *termlist = my_term->parent->TermList(); - while (termlist != nullptr) + while (termlist != NULL) { if (termlist->host == host) { snprintf(str, 256, "Host: %s", termlist->name.Value()); r->TextL(str); r->NewLine(); - termlist = nullptr; + termlist = NULL; } else { @@ -629,7 +629,7 @@ int Drawer::MakeReport(Terminal *my_term, Check *check_list, Report *r) //as the new method simultaneously. The assumption is that there //will be overlap only during a transition stage. // Credit Cards, original - for (CreditCardInfo *cc = s->CreditCardList(); cc != nullptr; cc = cc->next) + for (CreditCardInfo *cc = s->CreditCardList(); cc != NULL; cc = cc->next) { db = FindBalance(TENDER_CHARGE_CARD, cc->id); if (db && (db->amount != 0 || db->entered != 0)) @@ -714,7 +714,7 @@ int Drawer::MakeReport(Terminal *my_term, Check *check_list, Report *r) // Discounts r->Mode(PRINT_RED); - for (CouponInfo *cp = s->CouponList(); cp != nullptr; cp = cp->next) + for (CouponInfo *cp = s->CouponList(); cp != NULL; cp = cp->next) { db = FindBalance(TENDER_COUPON, cp->id); if (db && (db->amount != 0 || db->entered != 0)) @@ -732,7 +732,7 @@ int Drawer::MakeReport(Terminal *my_term, Check *check_list, Report *r) } } - for (CompInfo *cm = s->CompList(); cm != nullptr; cm = cm->next) + for (CompInfo *cm = s->CompList(); cm != NULL; cm = cm->next) { db = FindBalance(TENDER_COMP, cm->id); if (db && (db->amount != 0 || db->entered != 0)) @@ -783,7 +783,7 @@ int Drawer::MakeReport(Terminal *my_term, Check *check_list, Report *r) r->NewLine(); } - for (DiscountInfo *ds = s->DiscountList(); ds != nullptr; ds = ds->next) + for (DiscountInfo *ds = s->DiscountList(); ds != NULL; ds = ds->next) { db = FindBalance(TENDER_DISCOUNT, ds->id); if (db && (db->amount != 0 || db->entered != 0)) @@ -810,7 +810,7 @@ int Drawer::MakeReport(Terminal *my_term, Check *check_list, Report *r) } } - for (MealInfo *mi = s->MealList(); mi != nullptr; mi = mi->next) + for (MealInfo *mi = s->MealList(); mi != NULL; mi = mi->next) { db = FindBalance(TENDER_EMPLOYEE_MEAL, mi->id); if (db && (db->amount != 0 || db->entered != 0)) @@ -937,7 +937,7 @@ int Drawer::Open() if (IsServerBank()) return 1; - if (term == nullptr) + if (term == NULL) term = MasterControl->FindTermByHost(host.Value()); if (term) @@ -949,7 +949,7 @@ int Drawer::Open() int Drawer::Total(Check *check_list, int force) { FnTrace("Drawer::Total()"); - if (check_list == nullptr && force != 1) + if (check_list == NULL && force != 1) return 1; int i; @@ -964,7 +964,7 @@ int Drawer::Total(Check *check_list, int force) total_payments = 0; total_difference = 0; - for (balance = balance_list.Head(); balance != nullptr; balance = balance->next) + for (balance = balance_list.Head(); balance != NULL; balance = balance->next) { //FIX BAK-->This may or may not need to be fixed: // TENDER_EXPENSE totals are calculated by @@ -991,12 +991,12 @@ int Drawer::Total(Check *check_list, int force) } // Go through checks - for (check = check_list; check != nullptr; check = check->next) + for (check = check_list; check != NULL; check = check->next) { if (check->IsTraining() > 0) continue; - for (subcheck = check->SubList(); subcheck != nullptr; subcheck = subcheck->next) + for (subcheck = check->SubList(); subcheck != NULL; subcheck = subcheck->next) { if (subcheck->drawer_id != serial_number) continue; @@ -1008,7 +1008,7 @@ int Drawer::Total(Check *check_list, int force) ++count[TENDER_ITEM_COMP]; } - for (payment = subcheck->PaymentList(); payment != nullptr; payment = payment->next) + for (payment = subcheck->PaymentList(); payment != NULL; payment = payment->next) { int idx = payment->tender_type; int pid = payment->tender_id; @@ -1038,7 +1038,7 @@ int Drawer::Total(Check *check_list, int force) } // Go through payments - for (dpaymnt = payment_list.Head(); dpaymnt != nullptr; dpaymnt = dpaymnt->next) + for (dpaymnt = payment_list.Head(); dpaymnt != NULL; dpaymnt = dpaymnt->next) { ++total_payments; int idx = dpaymnt->tender_type; @@ -1075,20 +1075,20 @@ int Drawer::Total(Check *check_list, int force) // on the drawer balancing page while the drawer is pulled and also on the // Final Balance Report. DrawerBalance *cash_avail = FindBalance(TENDER_CASH_AVAIL, 0, 1); - if (cash_avail != nullptr) + if (cash_avail != NULL) { int cashamount = 0; int cashentered = 0; int expenseamount = 0; int expenseentered = 0; DrawerBalance *cash = FindBalance(TENDER_CASH, 0); - if (cash != nullptr) + if (cash != NULL) { cashamount = cash->amount; cashentered = cash->entered; } DrawerBalance *expenses = FindBalance(TENDER_EXPENSE, 0); - if (expenses != nullptr) + if (expenses != NULL) { expenseamount = expenses->amount; expenseentered = expenses->entered; @@ -1113,7 +1113,7 @@ int Drawer::Total(Check *check_list, int force) total_payments += balance->count; // Calculate total difference - for (balance = balance_list.Head(); balance != nullptr; balance = balance->next) + for (balance = balance_list.Head(); balance != NULL; balance = balance->next) { if (media_balanced & (1 << balance->tender_type)) { @@ -1137,7 +1137,7 @@ int Drawer::ChangeOwner(int user_id) int Drawer::RecordSale(SubCheck *sc) { FnTrace("Drawer::RecordSale()"); - if (sc == nullptr) + if (sc == NULL) return 1; if (sc->drawer_id > 0) @@ -1164,7 +1164,7 @@ int Drawer::TotalPaymentAmount(int tender_type) DrawerPayment *currPayment = payment_list.Head(); int retval = 0; - while (currPayment != nullptr) + while (currPayment != NULL) { if (currPayment->tender_type == tender_type) retval += currPayment->amount; @@ -1203,7 +1203,7 @@ int Drawer::IsEmpty() { FnTrace("Drawer::IsEmpty()"); int no_checks = (total_checks <= 0); - int empty_payment_list = (payment_list.Head() == nullptr); + int empty_payment_list = (payment_list.Head() == NULL); int no_payments = (total_payments <= 0); return (no_checks && empty_payment_list && no_payments); @@ -1214,7 +1214,7 @@ DrawerBalance *Drawer::FindBalance(int tender, int id, int make_new) FnTrace("Drawer::FindBalance()"); DrawerBalance *balance; - for (balance = balance_list.Head(); balance != nullptr; balance = balance->next) + for (balance = balance_list.Head(); balance != NULL; balance = balance->next) { if (balance->tender_type == tender && balance->tender_id == id) { @@ -1228,7 +1228,7 @@ DrawerBalance *Drawer::FindBalance(int tender, int id, int make_new) Add(balance); return balance; } - return nullptr; + return NULL; } /**** @@ -1240,7 +1240,7 @@ void Drawer::ListBalances() DrawerBalance *balance = balance_list.Head(); printf("Listing Balances for Drawer %d\n", serial_number); - while (balance != nullptr) + while (balance != NULL) { printf(" Type: %d\n", balance->tender_type); printf(" ID: %d\n", balance->tender_id); @@ -1254,7 +1254,7 @@ void Drawer::ListBalances() int Drawer::Balance(int tender, int id) { FnTrace("Drawer::Balance(int, int)"); - for (DrawerBalance *b = balance_list.Head(); b != nullptr; b = b->next) + for (DrawerBalance *b = balance_list.Head(); b != NULL; b = b->next) { if (b->tender_type == tender && b->tender_id == id) { @@ -1274,7 +1274,7 @@ int Drawer::TotalBalance(int tender) int amount_total = 0; int retval = 0; - for (DrawerBalance *b = balance_list.Head(); b != nullptr; b = b->next) + for (DrawerBalance *b = balance_list.Head(); b != NULL; b = b->next) { if (b->tender_type == tender) { @@ -1293,33 +1293,33 @@ int Drawer::TotalBalance(int tender) Drawer *Drawer::FindBySerial(int serial) { FnTrace("Drawer::FindBySerial()"); - for (Drawer *d = this; d != nullptr; d = d->next) + for (Drawer *d = this; d != NULL; d = d->next) { if (d->serial_number == serial) return d; } - return nullptr; + return NULL; } Drawer *Drawer::FindByNumber(int no, int status) { FnTrace("Drawer::FindByNumber()"); - for (Drawer *d = this; d != nullptr; d = d->next) + for (Drawer *d = this; d != NULL; d = d->next) if (d->number == no && d->GetStatus() == status) return d; - return nullptr; + return NULL; } Drawer *Drawer::FindByOwner(Employee *e, int status) { FnTrace("Drawer::FindByOwner()"); if (e->training) - return nullptr; + return NULL; - for (Drawer *d = this; d != nullptr; d = d->next) + for (Drawer *d = this; d != NULL; d = d->next) if (d->owner_id == e->id && d->GetStatus() == status) return d; - return nullptr; + return NULL; } int Drawer::Balance([[maybe_unused]] int user_id) @@ -1392,10 +1392,10 @@ int Drawer::MergeServerBanks() { drawer_change = 1; // Reassign drawer_id in checks - for (Check *c = check_list; c != nullptr; c = c->next) + for (Check *c = check_list; c != NULL; c = c->next) { check_change = 0; - for (SubCheck *sc = c->SubList(); sc != nullptr; sc = sc->next) + for (SubCheck *sc = c->SubList(); sc != NULL; sc = sc->next) if (sc->drawer_id == d->serial_number) { check_change = 1; @@ -1416,7 +1416,7 @@ int Drawer::MergeServerBanks() dp = dp_next; } // Move balances - for (DrawerBalance *b = d->balance_list.Head(); b != nullptr; b = b->next) + for (DrawerBalance *b = d->balance_list.Head(); b != NULL; b = b->next) { DrawerBalance *mdb = FindBalance(b->tender_type, b->tender_id, 1); mdb->entered += b->entered; @@ -1485,10 +1485,10 @@ int Drawer::MergeSystems(int mergeall) { drawer_change = 1; // Reassign drawer_id in checks - for (Check *c = check_list; c != nullptr; c = c->next) + for (Check *c = check_list; c != NULL; c = c->next) { check_change = 0; - for (SubCheck *sc = c->SubList(); sc != nullptr; sc = sc->next) + for (SubCheck *sc = c->SubList(); sc != NULL; sc = sc->next) if (sc->drawer_id == d->serial_number) { check_change = 1; @@ -1509,7 +1509,7 @@ int Drawer::MergeSystems(int mergeall) dp = dp_next; } // Move balances - for (DrawerBalance *b = d->balance_list.Head(); b != nullptr; b = b->next) + for (DrawerBalance *b = d->balance_list.Head(); b != NULL; b = b->next) { DrawerBalance *mdb = FindBalance(b->tender_type, b->tender_id, 1); mdb->entered += b->entered; @@ -1575,23 +1575,23 @@ int MergeSystems(Terminal *term, int mergeall) // gather drawers attached to terminals Terminal *termlist = term->parent->TermList(); - while (termlist != nullptr) + while (termlist != NULL) { // count the drawers for this hostname count = 0; currdrawer = firstdrawer; - mergedrawer = nullptr; - while (currdrawer != nullptr) + mergedrawer = NULL; + while (currdrawer != NULL) { if (currdrawer->host == termlist->host) { - if (mergedrawer == nullptr) + if (mergedrawer == NULL) mergedrawer = currdrawer; count += 1; } currdrawer = currdrawer->next; } - if (count > 1 && mergedrawer != nullptr) + if (count > 1 && mergedrawer != NULL) { mergedrawer->MergeSystems(); retval = 1; @@ -1602,18 +1602,18 @@ int MergeSystems(Terminal *term, int mergeall) // now gather the drawers that have no assigned host count = 0; currdrawer = firstdrawer; - mergedrawer = nullptr; - while (currdrawer != nullptr) + mergedrawer = NULL; + while (currdrawer != NULL) { if (currdrawer->host.empty()) { - if (mergedrawer == nullptr) + if (mergedrawer == NULL) mergedrawer = currdrawer; count += 1; } currdrawer = currdrawer->next; } - if (count > 1 && mergedrawer != nullptr) + if (count > 1 && mergedrawer != NULL) { mergedrawer->MergeSystems(); retval = 0; diff --git a/main/hardware/drawer.hh b/main/hardware/drawer.hh index 984bebff..37d9b769 100644 --- a/main/hardware/drawer.hh +++ b/main/hardware/drawer.hh @@ -18,8 +18,8 @@ * Drawer balance, report, use classes */ -#ifndef DRAWER_HH -#define DRAWER_HH +#ifndef _DRAWER_HH +#define _DRAWER_HH #include "utility.hh" #include "list_utility.hh" @@ -86,7 +86,7 @@ public: // Member Functions int Read(InputDataFile &df, [[maybe_unused]] int version); int Write(OutputDataFile &df, [[maybe_unused]] int version); - genericChar* Description(Settings *s, genericChar* str = nullptr); + genericChar* Description(Settings *s, genericChar* str = NULL); }; class Drawer @@ -97,7 +97,7 @@ class Drawer public: Drawer *next; Drawer *fore; // linked list pointers - Archive *archive; // parent archive (nullptr if current drawer) + Archive *archive; // parent archive (NULL if current drawer) TimeInfo start_time; // time of drawer initialization TimeInfo pull_time; // time of drawer pull TimeInfo balance_time; // time of drawer balance diff --git a/main/hardware/printer.cc b/main/hardware/printer.cc index 3d08f397..ef1ba913 100644 --- a/main/hardware/printer.cc +++ b/main/hardware/printer.cc @@ -61,7 +61,7 @@ const genericChar* PrinterModelName[] = { "No Printer", "Epson", "Star", "HP", "Toshiba", "Ithaca", "HTML", "PostScript", "PDF", "Receipt Text", - "Report Text", "QuickBooks CSV", nullptr}; + "Report Text", "QuickBooks CSV", NULL}; int PrinterModelValue[] = { MODEL_NONE, MODEL_EPSON, MODEL_STAR, MODEL_HP, MODEL_TOSHIBA, MODEL_ITHACA, MODEL_HTML, MODEL_POSTSCRIPT, MODEL_PDF, MODEL_RECEIPT_TEXT, @@ -75,7 +75,7 @@ int PrinterModelValue[] = { const genericChar* ReceiptPrinterModelName[] = { "No Printer", "Epson", "Star", "HP", "Toshiba", "Ithaca", "HTML", "PostScript", "PDF", "Receipt Text", - "Report Text", "QuickBooks CSV", nullptr}; + "Report Text", "QuickBooks CSV", NULL}; int ReceiptPrinterModelValue[] = { MODEL_NONE, MODEL_EPSON, MODEL_STAR, MODEL_HP, MODEL_TOSHIBA, MODEL_ITHACA, MODEL_HTML, MODEL_POSTSCRIPT, MODEL_PDF, MODEL_RECEIPT_TEXT, @@ -83,7 +83,7 @@ int ReceiptPrinterModelValue[] = { const genericChar* ReportPrinterModelName[] = { "No Printer", "HP", "Toshiba", "HTML", "PostScript", - "PDF", "Text", "QuickBooks CSV", nullptr}; + "PDF", "Text", "QuickBooks CSV", NULL}; int ReportPrinterModelValue[] = { MODEL_NONE, MODEL_HP, MODEL_TOSHIBA, MODEL_HTML, MODEL_POSTSCRIPT, MODEL_PDF, MODEL_REPORT_TEXT, MODEL_QUICKBOOKS_CSV, -1}; @@ -92,7 +92,7 @@ int ReportPrinterModelValue[] = { const genericChar* PortName[] = { "XCD Parallel", "XCD Serial", "Explora Parallel", "Explora Serial", - "VT Daemon", "Device On Server", nullptr}; + "VT Daemon", "Device On Server", NULL}; int PortValue[] = { PORT_XCD_PARALLEL, PORT_XCD_SERIAL, PORT_EXPLORA_PARALLEL, PORT_EXPLORA_SERIAL, PORT_VT_DAEMON, PORT_SERVER_DEVICE, -1}; @@ -105,9 +105,9 @@ int PortValue[] = { Printer::Printer() { - next = nullptr; - fore = nullptr; - parent = nullptr; + next = NULL; + fore = NULL; + parent = NULL; last_mode = 0; last_color = 0; last_uni = 0; @@ -130,9 +130,9 @@ Printer::Printer() Printer::Printer(const genericChar* host, int port, const genericChar* targetstr, int type) { - next = nullptr; - fore = nullptr; - parent = nullptr; + next = NULL; + fore = NULL; + parent = NULL; last_mode = 0; last_color = 0; last_uni = 0; @@ -154,7 +154,8 @@ Printer::Printer(const genericChar* host, int port, const genericChar* targetstr } Printer::~Printer() -= default; +{ +} /**** * MatchHost: This is fairly rudimentary. It only checks the hostname. I can only @@ -168,7 +169,7 @@ int Printer::MatchHost(const genericChar* host, int /*port*/) FnTrace("Printer::MatchHost()"); int retval = 1; - if (strcmp(host_name.Value(), host) != 0) + if (strcmp(host_name.Value(), host)) retval = 0; return retval; @@ -179,7 +180,7 @@ int Printer::MatchTerminal(const genericChar* termname) FnTrace("Printer::MatchTerminal()"); int retval = 1; - if (strcmp(term_name.Value(), termname) != 0) + if (strcmp(term_name.Value(), termname)) retval = 0; return retval; @@ -331,7 +332,7 @@ int Printer::ParallelPrint() while (bytes > 0) { bytes = write(outfd, buff, static_cast(bytes)); - select(0, nullptr, nullptr, nullptr, &timeout); + select(0, NULL, NULL, NULL, &timeout); if (bytes > 0) bytes = read(infd, buff, STRLENGTH); } @@ -397,7 +398,7 @@ int Printer::SocketPrint() struct sockaddr_in their_addr; // connector's address information he = gethostbyname(target.Value()); // get the host info - if (he == nullptr) + if (he == NULL) { vt::Logger::error("SocketPrint: Failed to resolve host '{}'", target.Value()); perror("gethostbyname"); @@ -490,7 +491,7 @@ int Printer::MakeFileName(genericChar* buffer, const genericChar* source, const const genericChar* title_source; // Select the source string without copying - if (source != nullptr) + if (source != NULL) title_source = source; else if (have_title) title_source = page_title.c_str(); @@ -516,7 +517,7 @@ int Printer::MakeFileName(genericChar* buffer, const genericChar* source, const buffidx += snprintf(buffer + buffidx, max_len - buffidx, "-%02d-%02d-%d", now.Day(), now.Month(), now.Year()); - if (ext == nullptr) + if (ext == NULL) { // append an extension switch (Model()) @@ -594,7 +595,7 @@ int Printer::GetFilePath(char* dest) if (IsDirectory(target.Value())) { - MakeFileName(filename, nullptr, nullptr, STRLENGTH); + MakeFileName(filename, NULL, NULL, STRLENGTH); vt_safe_string::safe_format(dest, STRLENGTH, "%s/%s", target.Value(), filename); } else @@ -824,7 +825,7 @@ void Printer::DebugPrint(int printall) printf(" Have Title: %d\n", have_title); printf(" Kitchen Mode: %d\n", kitchen_mode); - if (printall && next != nullptr) + if (printall && next != NULL) next->DebugPrint(printall); } @@ -834,9 +835,9 @@ void Printer::DebugPrint(int printall) ********************************************************************/ PrinterIthaca::PrinterIthaca(const genericChar* host, int port, const genericChar* targetstr, int type) { - next = nullptr; - fore = nullptr; - parent = nullptr; + next = NULL; + fore = NULL; + parent = NULL; last_mode = 0; last_color = 0; last_uni = 0; @@ -1026,9 +1027,9 @@ int PrinterIthaca::CutPaper(int partial_only) ********************************************************************/ PrinterStar::PrinterStar(const genericChar* host, int port, const genericChar* targetstr, int type) { - next = nullptr; - fore = nullptr; - parent = nullptr; + next = NULL; + fore = NULL; + parent = NULL; last_mode = 0; last_color = 0; last_uni = 0; @@ -1257,9 +1258,9 @@ int PrinterStar::CutPaper(int partial_only) ********************************************************************/ PrinterEpson::PrinterEpson(const genericChar* host, int port, const genericChar* targetstr, int type) { - next = nullptr; - fore = nullptr; - parent = nullptr; + next = NULL; + fore = NULL; + parent = NULL; last_mode = 0; last_color = 0; last_uni = 0; @@ -1478,9 +1479,9 @@ int PrinterEpson::CutPaper(int partial_only) PrinterHP::PrinterHP(const genericChar* host, int port, const genericChar* targetstr, int type) { - next = nullptr; - fore = nullptr; - parent = nullptr; + next = NULL; + fore = NULL; + parent = NULL; last_mode = 0; last_color = 0; last_uni = 0; @@ -1655,9 +1656,9 @@ int PrinterHP::CutPaper(int partial_only) ********************************************************************/ PrinterHTML::PrinterHTML(const genericChar* host, int port, const genericChar* targetstr, int type) { - next = nullptr; - fore = nullptr; - parent = nullptr; + next = NULL; + fore = NULL; + parent = NULL; last_mode = 0; last_color = 0; last_uni = 0; @@ -1803,9 +1804,9 @@ int PrinterHTML::LineFeed(int lines) ********************************************************************/ PrinterPostScript::PrinterPostScript() { - next = nullptr; - fore = nullptr; - parent = nullptr; + next = NULL; + fore = NULL; + parent = NULL; last_mode = 0; last_color = 0; last_uni = 0; @@ -1829,9 +1830,9 @@ PrinterPostScript::PrinterPostScript() PrinterPostScript::PrinterPostScript(const genericChar* host, int port, const genericChar* targetstr, int type) { - next = nullptr; - fore = nullptr; - parent = nullptr; + next = NULL; + fore = NULL; + parent = NULL; last_mode = 0; last_color = 0; last_uni = 0; @@ -1963,13 +1964,13 @@ int PrinterPostScript::Init() "RegularFont\n", "} def\n", "NewPage\n", - nullptr + NULL }; if (temp_fd <= 0) return 1; - while (lines[idx] != nullptr) + while (lines[idx] != NULL) { if (write(temp_fd, lines[idx], strlen(lines[idx])) < 0) break; @@ -2207,9 +2208,9 @@ int PrinterPostScript::Put(genericChar c, int flags) PrinterPDF::PrinterPDF() { - next = nullptr; - fore = nullptr; - parent = nullptr; + next = NULL; + fore = NULL; + parent = NULL; last_mode = 0; last_color = 0; last_uni = 0; @@ -2231,9 +2232,9 @@ PrinterPDF::PrinterPDF() PrinterPDF::PrinterPDF(const genericChar* host, int port, const genericChar* targetstr, int type) { - next = nullptr; - fore = nullptr; - parent = nullptr; + next = NULL; + fore = NULL; + parent = NULL; last_mode = 0; last_color = 0; last_uni = 0; @@ -2266,7 +2267,7 @@ int PrinterPDF::Close() close(temp_fd); // create the PDF filename and convert the temp file - MakeFileName(filename, nullptr, ".pdf", STRLONG); + MakeFileName(filename, NULL, ".pdf", STRLONG); vt_safe_string::safe_format(pdffullpath, STRLONG, "/tmp/%s", filename); vt_safe_string::safe_format(command, STRLONG, "ps2pdf %s %s", temp_name.Value(), pdffullpath); system(command); @@ -2291,9 +2292,9 @@ int PrinterPDF::Close() ********************************************************************/ PrinterReceiptText::PrinterReceiptText() { - next = nullptr; - fore = nullptr; - parent = nullptr; + next = NULL; + fore = NULL; + parent = NULL; last_mode = 0; last_color = 0; last_uni = 0; @@ -2315,9 +2316,9 @@ PrinterReceiptText::PrinterReceiptText() PrinterReceiptText::PrinterReceiptText(const genericChar* host, int port, const genericChar* targetstr, int type) { - next = nullptr; - fore = nullptr; - parent = nullptr; + next = NULL; + fore = NULL; + parent = NULL; last_mode = 0; last_color = 0; last_uni = 0; @@ -2397,9 +2398,9 @@ int PrinterReceiptText::LineFeed(int lines) ********************************************************************/ PrinterReportText::PrinterReportText(const genericChar* host, int port, const genericChar* targetstr, int type) { - next = nullptr; - fore = nullptr; - parent = nullptr; + next = NULL; + fore = NULL; + parent = NULL; last_mode = 0; last_color = 0; last_uni = 0; @@ -2540,7 +2541,7 @@ int ParseDestination(int &type, genericChar* target, int &port, const genericCha Printer *NewPrinterObj(const genericChar* destination, int port, int model, int no) { FnTrace("NewPrinterObj()"); - Printer *retPrinter = nullptr; + Printer *retPrinter = NULL; genericChar target[STRLENGTH] = ""; int target_type; @@ -2584,7 +2585,7 @@ Printer *NewPrinterObj(const genericChar* destination, int port, int model, int retPrinter = new PrinterQuickBooksCSV(destination, port, target, target_type); break; default: - retPrinter = nullptr; + retPrinter = NULL; break; } } @@ -2595,7 +2596,7 @@ Printer *NewPrinterObj(const genericChar* destination, int port, int model, int Printer *NewPrinterFromString(const genericChar* specification) { FnTrace("NewPrinterFromString()"); - Printer *retPrinter = nullptr; + Printer *retPrinter = NULL; genericChar destination[STRLONG] = ""; genericChar modelstr[STRLONG] = ""; int model = MODEL_HTML; // use default model @@ -2651,9 +2652,9 @@ Printer *NewPrinterFromString(const genericChar* specification) ********************************************************************/ PrinterQuickBooksCSV::PrinterQuickBooksCSV(const genericChar* host, int port, const genericChar* targetstr, int type) { - next = nullptr; - fore = nullptr; - parent = nullptr; + next = NULL; + fore = NULL; + parent = NULL; last_mode = 0; last_color = 0; last_uni = 0; diff --git a/main/hardware/printer.hh b/main/hardware/printer.hh index 2fb94148..01095317 100644 --- a/main/hardware/printer.hh +++ b/main/hardware/printer.hh @@ -18,25 +18,22 @@ * Definition of printer device class */ -#ifndef PRINTER_HH -#define PRINTER_HH +#ifndef _PRINTER_HH +#define _PRINTER_HH #include "utility.hh" #include /**** Definitions ****/ -// Printer style flags (converted from macros to enum constants) -enum PrintModeFlags : std::uint8_t { - PRINT_RED = 1, // use red ink (if available) - PRINT_BOLD = 2, // bold text - PRINT_UNDERLINE = 4, // underline text - PRINT_NARROW = 8, // condensed width text - PRINT_WIDE = 16, // print double width only - PRINT_TALL = 32, // print double height only - PRINT_LARGE = 48, // print double width & height - PRINT_BLUE = 64 // blue text (if available) -}; +#define PRINT_RED 1 // use red ink (if available) +#define PRINT_BOLD 2 // bold text +#define PRINT_UNDERLINE 4 // underline text +#define PRINT_NARROW 8 // condensed width text +#define PRINT_WIDE 16 // print double width only +#define PRINT_TALL 32 // print double height only +#define PRINT_LARGE 48 // print double width & height +#define PRINT_BLUE 64 // blue text (if available) #define EPSON_WIDE 32 #define EPSON_TALL 16 @@ -53,7 +50,7 @@ enum PrintModeFlags : std::uint8_t { #define TARGET_TYPE_EMAIL "email" #define TARGET_TYPE_QUICKBOOKS_CSV "quickbooks_csv" -enum targettype : std::uint8_t { +enum targettype { TARGET_NONE, TARGET_PARALLEL, TARGET_LPD, @@ -63,7 +60,7 @@ enum targettype : std::uint8_t { TARGET_QUICKBOOKS_CSV }; -enum printer_models : std::uint8_t { +enum printer_models { MODEL_NONE, MODEL_EPSON, MODEL_STAR, @@ -189,82 +186,82 @@ public: class PrinterIthaca : public Printer { - int WriteFlags(int flags) override; + virtual int WriteFlags(int flags); public: PrinterIthaca(const genericChar* host, int port, const genericChar* targetstr, int type); - int Model() override { return MODEL_ITHACA; } - int Start() override; - int End() override; - int Init() override; - int NewLine() override; - int LineFeed(int lines = 1) override; - int FormFeed() override; - int MaxWidth() override; - int MaxLines() override; - int Width(int flags = 0) override; - int StopPrint() override; - int OpenDrawer(int drawer) override; - int CutPaper(int partial_only = 0) override; + virtual int Model() { return MODEL_ITHACA; } + virtual int Start(); + virtual int End(); + virtual int Init(); + virtual int NewLine(); + virtual int LineFeed(int lines = 1); + virtual int FormFeed(); + virtual int MaxWidth(); + virtual int MaxLines(); + virtual int Width(int flags = 0); + virtual int StopPrint(); + virtual int OpenDrawer(int drawer); + virtual int CutPaper(int partial_only = 0); }; class PrinterStar : public Printer { - int WriteFlags(int flags) override; + virtual int WriteFlags(int flags); public: PrinterStar(const genericChar* host, int port, const genericChar* targetstr, int type); - int Model() override { return MODEL_STAR; } - int Start() override; - int End() override; - int Init() override; - int NewLine() override; - int LineFeed(int lines = 1) override; - int FormFeed() override; - int MaxWidth() override; - int MaxLines() override; - int Width(int flags = 0) override; - int StopPrint() override; - int OpenDrawer(int drawer) override; - int CutPaper(int partial_only = 0) override; + virtual int Model() { return MODEL_STAR; } + virtual int Start(); + virtual int End(); + virtual int Init(); + virtual int NewLine(); + virtual int LineFeed(int lines = 1); + virtual int FormFeed(); + virtual int MaxWidth(); + virtual int MaxLines(); + virtual int Width(int flags = 0); + virtual int StopPrint(); + virtual int OpenDrawer(int drawer); + virtual int CutPaper(int partial_only = 0); }; class PrinterEpson : public Printer { - int WriteFlags(int flags) override; + virtual int WriteFlags(int flags); public: PrinterEpson(const genericChar* host, int port, const genericChar* targetstr, int type); - int Model() override { return MODEL_EPSON; } - int Start() override; - int End() override; - int Init() override; - int NewLine() override; - int LineFeed(int lines = 1) override; - int FormFeed() override; - int MaxWidth() override; - int MaxLines() override; - int Width(int flags = 0) override; - int StopPrint() override; - int OpenDrawer(int drawer) override; - int CutPaper(int partial_only = 0) override; + virtual int Model() { return MODEL_EPSON; } + virtual int Start(); + virtual int End(); + virtual int Init(); + virtual int NewLine(); + virtual int LineFeed(int lines = 1); + virtual int FormFeed(); + virtual int MaxWidth(); + virtual int MaxLines(); + virtual int Width(int flags = 0); + virtual int StopPrint(); + virtual int OpenDrawer(int drawer); + virtual int CutPaper(int partial_only = 0); }; class PrinterHP : public Printer { - int WriteFlags(int flags) override; + virtual int WriteFlags(int flags); public: PrinterHP(const genericChar* host, int port, const genericChar* targetstr, int type); - int Model() override { return MODEL_HP; } - int Start() override; - int End() override; - int Init() override; - int NewLine() override; - int LineFeed(int lines = 1) override; - int FormFeed() override; - int MaxWidth() override; - int MaxLines() override; - int Width(int flags = 0) override; - int StopPrint() override; - int OpenDrawer(int drawer) override; - int CutPaper(int partial_only = 0) override; + virtual int Model() { return MODEL_HP; } + virtual int Start(); + virtual int End(); + virtual int Init(); + virtual int NewLine(); + virtual int LineFeed(int lines = 1); + virtual int FormFeed(); + virtual int MaxWidth(); + virtual int MaxLines(); + virtual int Width(int flags = 0); + virtual int StopPrint(); + virtual int OpenDrawer(int drawer); + virtual int CutPaper(int partial_only = 0); }; class PrinterHTML : public Printer diff --git a/main/hardware/remote_printer.cc b/main/hardware/remote_printer.cc index 0e84cc32..071b387e 100644 --- a/main/hardware/remote_printer.cc +++ b/main/hardware/remote_printer.cc @@ -120,9 +120,9 @@ class RemotePrinter : public Printer // Member Functions int WInt8(int val); - int RInt8(int *val = nullptr); + int RInt8(int *val = NULL); int WStr(const char* str, int len = 0); - const genericChar* RStr(char* str = nullptr); // Changed to non-const for GetString + const genericChar* RStr(char* str = NULL); // Changed to non-const for GetString int Send(); int SendNow(); int Reconnect(); // Critical fix: Add reconnection method @@ -218,7 +218,7 @@ RemotePrinter::~RemotePrinter() RemoveInputFn(input_id); if (socket_no >= 0) { - WInt8(ToInt(PrinterProtocol::Die)); + WInt8(PRINTER_DIE); SendNow(); close(socket_no); } @@ -241,7 +241,7 @@ int RemotePrinter::RInt8(int *val) int RemotePrinter::WStr(const char* s, int len) { - if (s == nullptr) + if (s == NULL) return buffer_out->PutString("", 0); else return buffer_out->PutString(s, len); @@ -250,7 +250,7 @@ int RemotePrinter::WStr(const char* s, int len) const char* RemotePrinter::RStr(char* s) { static std::array buffer{}; - if (s == nullptr) + if (s == NULL) s = buffer.data(); if (buffer_in->GetString(s, buffer.size())) { @@ -372,7 +372,7 @@ int RemotePrinter::Reconnect() // Update UI to show printer as online if (parent) - parent->UpdateAll(UPDATE_PRINTERS, nullptr); + parent->UpdateAll(UPDATE_PRINTERS, NULL); return 0; } @@ -405,13 +405,13 @@ int RemotePrinter::IsOnline() const int RemotePrinter::StopPrint() { - WInt8(ToInt(PrinterProtocol::Cancel)); + WInt8(PRINTER_CANCEL); return SendNow(); } int RemotePrinter::OpenDrawer(int drawer) { - WInt8(ToInt(PrinterProtocol::OpenDrawer)); + WInt8(PRINTER_OPENDRAWER); return SendNow(); } @@ -537,7 +537,7 @@ int RemotePrinter::End() close(device_no); device_no = 0; - WInt8(ToInt(PrinterProtocol::File)); + WInt8(PRINTER_FILE); WStr(filename.Value()); return SendNow(); } @@ -591,7 +591,7 @@ void PrinterCB(XtPointer client_data, int *fid, XtInputId *id) // Mark printer as offline but keep it in the list for reconnection attempts p->failure = 999; // Special value to indicate offline status // Update UI to show printer as offline - db->UpdateAll(UPDATE_PRINTERS, nullptr); + db->UpdateAll(UPDATE_PRINTERS, NULL); } return; } @@ -607,7 +607,7 @@ void PrinterCB(XtPointer client_data, int *fid, XtInputId *id) // Update UI to show printer as online if (db) - db->UpdateAll(UPDATE_PRINTERS, nullptr); + db->UpdateAll(UPDATE_PRINTERS, NULL); } std::array str{}; @@ -616,14 +616,14 @@ void PrinterCB(XtPointer client_data, int *fid, XtInputId *id) int code = p->RInt8(); switch (code) { - case ToInt(ServerProtocol::SrvError): + case SERVER_ERROR: snprintf(str.data(), str.size(), "PrinterError: %s", p->RStr()); ReportError(str.data()); break; - case ToInt(ServerProtocol::SrvPrinterDone): + case SERVER_PRINTER_DONE: DeleteFile(p->RStr()); break; - case ToInt(ServerProtocol::SrvBadFile): + case SERVER_BADFILE: p->RStr(); break; } @@ -635,13 +635,13 @@ void PrinterCB(XtPointer client_data, int *fid, XtInputId *id) Printer *NewRemotePrinter(const char* host, int port, int model, int no) { RemotePrinter *p = new RemotePrinter(host, port, model, no); - if (p == nullptr) - return nullptr; + if (p == NULL) + return NULL; if (p->socket_no < 0) { delete p; - return nullptr; + return NULL; } p->input_id = AddInputFn((InputFn) PrinterCB, p->socket_no, p); diff --git a/main/hardware/remote_printer.hh b/main/hardware/remote_printer.hh index db7a9aae..bbe7fd19 100644 --- a/main/hardware/remote_printer.hh +++ b/main/hardware/remote_printer.hh @@ -19,7 +19,7 @@ */ #ifndef _REMOTE_PRINTER_HH -#define REMOTE_PRINTER_HH +#define _REMOTE_PRINTER_HH /**** Types ****/ class Printer; diff --git a/main/hardware/terminal.cc b/main/hardware/terminal.cc index 8b624d16..728e8b80 100644 --- a/main/hardware/terminal.cc +++ b/main/hardware/terminal.cc @@ -38,7 +38,6 @@ #include "manager.hh" #include "printer.hh" #include "remote_link.hh" -#include "src/utils/vt_enum_utils.hh" #include "report.hh" #include "sales.hh" #include "settings.hh" @@ -255,21 +254,9 @@ void TermCB(XtPointer client_data, int *fid, XtInputId * /*id*/) { int code = term->RInt8(); term->buffer_in->SetCode("vt_main", code); - - auto protocol = vt::IntToEnum(code); - if (!protocol) { - snprintf(str, STRLENGTH, GlobalTranslate("Cannot process unknown code: %d"), code); - ReportError(str); - snprintf(str, STRLENGTH, GlobalTranslate(" Last code processed was %d"), last_code); - ReportError(str); - printf("Terminating due to unforseen error....\n"); - EndSystem(); - break; - } - - switch (*protocol) + switch (code) { - case ServerProtocol::SrvTermInfo: + case SERVER_TERMINFO: term->size = term->RInt8(); term->width = term->RInt16(); term->height = term->RInt16(); @@ -328,12 +315,12 @@ void TermCB(XtPointer client_data, int *fid, XtInputId * /*id*/) } break; - case ServerProtocol::SrvError: + case SERVER_ERROR: vt_safe_string::safe_format(str, STRLENGTH, "TermError: %s", term->RStr()); ReportError(str); break; - case ServerProtocol::SrvTouch: + case SERVER_TOUCH: term->time_out = SystemTime; term->last_input = SystemTime; { @@ -349,7 +336,7 @@ void TermCB(XtPointer client_data, int *fid, XtInputId * /*id*/) } break; - case ServerProtocol::SrvKey: + case SERVER_KEY: { term->RInt16(); // win id - ignored genericChar key = (genericChar) term->RInt16(); @@ -361,7 +348,7 @@ void TermCB(XtPointer client_data, int *fid, XtInputId * /*id*/) } break; - case ServerProtocol::SrvMouse: + case SERVER_MOUSE: { int my_id = term->RInt16(); int my_code = term->RInt8(); @@ -380,28 +367,28 @@ void TermCB(XtPointer client_data, int *fid, XtInputId * /*id*/) } break; - case ServerProtocol::SrvZoneData: + case SERVER_ZONEDATA: fprintf(stderr, "SERVER_ZONEDATA received, calling ReadZone()\n"); term->ReadZone(); fprintf(stderr, "SERVER_ZONEDATA: ReadZone() returned\n"); break; - case ServerProtocol::SrvZoneChanges: + case SERVER_ZONECHANGES: term->ReadMultiZone(); break; - case ServerProtocol::SrvPageData: + case SERVER_PAGEDATA: term->ReadPage(); break; - case ServerProtocol::SrvKillZone: + case SERVER_KILLZONE: term->KillZone(); break; - case ServerProtocol::SrvKillPage: + case SERVER_KILLPAGE: term->KillPage(); break; - case ServerProtocol::SrvDefPage: + case SERVER_DEFPAGE: term->ReadDefaults(); break; - case ServerProtocol::SrvTranslate: + case SERVER_TRANSLATE: { int no = term->RInt8(); // translation count const genericChar* s1; @@ -425,10 +412,10 @@ void TermCB(XtPointer client_data, int *fid, XtInputId * /*id*/) } } break; - case ServerProtocol::SrvListSelect: + case SERVER_LISTSELECT: term->JumpList(term->RInt32()); break; - case ServerProtocol::SrvSwipe: + case SERVER_SWIPE: { const char* s1 = term->RStr(); if (strlen(s1) < STRLENGTH) @@ -439,17 +426,17 @@ void TermCB(XtPointer client_data, int *fid, XtInputId * /*id*/) } } break; - case ServerProtocol::SrvButtonPress: + case SERVER_BUTTONPRESS: term->RInt16(); // layer id term->ButtonCommand(term->RInt16()); break; - case ServerProtocol::SrvShutdown: // only allow easy exits on debug platforms + case SERVER_SHUTDOWN: // only allow easy exits on debug platforms if (term->user != nullptr && (term->user->id == 1 || term->user->id == 2)) EndSystem(); // superuser and developer can end system else if (debug_mode) EndSystem(); // anyone in debug mode can end system break; - case ServerProtocol::SrvCcProcessed: + case SERVER_CC_PROCESSED: if (term != nullptr) { term->ReadCreditCard(); @@ -459,26 +446,26 @@ void TermCB(XtPointer client_data, int *fid, XtInputId * /*id*/) term->Signal("ccprocessed", 0); } break; - case ServerProtocol::SrvCcSettled: + case SERVER_CC_SETTLED: term->CC_GetSettlementResults(); term->eod_failed = 0; break; - case ServerProtocol::SrvCcInit: + case SERVER_CC_INIT: term->CC_GetInitResults(); break; - case ServerProtocol::SrvCcTotals: + case SERVER_CC_TOTALS: term->CC_GetTotalsResults(); break; - case ServerProtocol::SrvCcDetails: + case SERVER_CC_DETAILS: term->CC_GetDetailsResults(); break; - case ServerProtocol::SrvCcSafCleared: + case SERVER_CC_SAFCLEARED: term->CC_GetSAFClearedResults(); break; - case ServerProtocol::SrvCcSafDetails: + case SERVER_CC_SAFDETAILS: term->CC_GetSAFDetails(); break; - case ServerProtocol::SrvCcSettleFailed: + case SERVER_CC_SETTLEFAILED: { term->cc_processing = 0; term->eod_failed = 1; @@ -496,9 +483,17 @@ void TermCB(XtPointer client_data, int *fid, XtInputId * /*id*/) } break; } - case ServerProtocol::SrvCcSafClearFailed: + case SERVER_CC_SAFCLEARFAILED: term->cc_processing = 0; term->eod_failed = 1; + break; + default: + snprintf(str, STRLENGTH, GlobalTranslate("Cannot process unknown code: %d"), code); + ReportError(str); + snprintf(str, STRLENGTH, GlobalTranslate(" Last code processed was %d"), last_code); + ReportError(str); + printf("Terminating due to unforseen error....\n"); + EndSystem(); break; } //end switch last_code = code; @@ -990,8 +985,6 @@ int Terminal::RunScript(const genericChar* script, int jump_type, int jump_id) PushPage(p->id); } break; - default: - break; } for (int i = jump_count - 1; i >= 0; --i) @@ -1641,8 +1634,6 @@ SignalResult Terminal::Signal(const genericChar* message, int group_id) return SIGNAL_OKAY; } - default: - break; } return SIGNAL_IGNORED; @@ -3108,7 +3099,7 @@ int Terminal::EditTerm(int save_data, int edit_mode) WInt16(64); // y WInt16(180); // width (increased from 120) WInt16(360); // height - WInt8(ToInt(WindowFrame::FrameBorder) | ToInt(WindowFrame::FrameTitle) | ToInt(WindowFrame::FrameMove)); + WInt8(WINFRAME_BORDER | WINFRAME_TITLE | WINFRAME_MOVE); WStr("Edit ToolBar"); WInt8(TERM_PUSHBUTTON); @@ -3243,7 +3234,7 @@ int Terminal::UpdateZoneDB(Control *con) } org_page_id = 0; - // ServerProtocol::SrvTermInfo command from term will cause jump to login page + // SERVER_TERMINFO command from term will cause jump to login page return 0; } @@ -3779,16 +3770,16 @@ int Terminal::RenderBlankPage() if (page == nullptr) return 1; - auto mode = OperationMode::OpNone; + int mode = MODE_NONE; if (record_activity) - mode = OperationMode::OpMacro; + mode = MODE_MACRO; else if (edit) - mode = OperationMode::OpEdit; + mode = MODE_EDIT; else if (user && user->training) - mode = OperationMode::OpTraining; + mode = MODE_TRAINING; WInt8(TERM_BLANKPAGE); - WInt8(ToInt(mode)); + WInt8(mode); if (page->image == IMAGE_DEFAULT) WInt8(zone_db->default_image); else @@ -3934,7 +3925,6 @@ int Terminal::RenderText(const std::string &str, int x, int y, int color, int fo case FONT_COURIER_20: font = FONT_COURIER_20B; break; case FONT_COURIER_18B: font = FONT_COURIER_18; break; case FONT_COURIER_20B: font = FONT_COURIER_20; break; - default: break; } } if (mode & PRINT_UNDERLINE) @@ -3988,7 +3978,6 @@ int Terminal::RenderTextLen(const genericChar* str, int len, int x, int y, int c case FONT_COURIER_20: font = FONT_COURIER_20B; break; case FONT_COURIER_18B: font = FONT_COURIER_18; break; case FONT_COURIER_20B: font = FONT_COURIER_20; break; - default: break; } } if (mode & PRINT_UNDERLINE) @@ -4756,9 +4745,9 @@ int Terminal::SendNow() } #define MOVE_RIGHT 5 -#define MOVE_LEFT (-5) +#define MOVE_LEFT -5 #define MOVE_DOWN 5 -#define MOVE_UP (-5) +#define MOVE_UP -5 int Terminal::KeyboardInput(genericChar key, int my_code, int state) { FnTrace("Terminal::KeyboardInput()"); @@ -4775,7 +4764,6 @@ int Terminal::KeyboardInput(genericChar key, int my_code, int state) return EditTerm(0); // Exit edit without saving, if we're in edit mode else return EditTerm(1); // EditTerm defaults to 1 anyway - break; case XK_F3: // record activity if (system_data->settings.enable_f3_f4_recording) { @@ -4835,8 +4823,6 @@ int Terminal::KeyboardInput(genericChar key, int my_code, int state) ForePage(); return 0; case XK_Page_Down: NextPage(); return 0; - default: - break; } } if (edit == 0) @@ -4876,9 +4862,6 @@ int Terminal::KeyboardInput(genericChar key, int my_code, int state) else zone_db->PositionEdit(this, grid_x, 0); break; - default: - break; - break; case XK_KP_3: if (state & ControlMask) zone_db->CopyEdit(this, MOVE_RIGHT, MOVE_DOWN); @@ -5174,8 +5157,6 @@ int Terminal::ButtonCommand(int command) WInt8(TERM_ICONIFY); SendNow(); break; - default: - break; } if (edit == 0) @@ -5204,8 +5185,6 @@ int Terminal::ButtonCommand(int command) case WB_PRIOR: ForePage(); break; - default: - break; case WB_NEXT: NextPage(); break; @@ -5636,7 +5615,7 @@ int Terminal::ReadZone() FnTrace("Terminal::ReadZone()"); FILE *debugfile = fopen("/tmp/viewtouch_debug.log", "a"); if (debugfile) { - fprintf(debugfile, "=== ReadZone() called at %ld ===\n", time(nullptr)); + fprintf(debugfile, "=== ReadZone() called at %ld ===\n", time(NULL)); fclose(debugfile); } fprintf(stderr, "=== ReadZone() called ===\n"); diff --git a/main/hardware/terminal.hh b/main/hardware/terminal.hh index 388214f2..47c6a4c7 100644 --- a/main/hardware/terminal.hh +++ b/main/hardware/terminal.hh @@ -18,8 +18,8 @@ * POS terminal state class */ -#ifndef TERMINAL_HH -#define TERMINAL_HH +#ifndef _TERMINAL_HH +#define _TERMINAL_HH #include "cdu.hh" #include "credit.hh" @@ -30,7 +30,6 @@ #include #include #include -#include // FIX - split Terminal into core class and PosTerm @@ -47,7 +46,7 @@ #define EOD_NOSETTLE 4 -enum page_id : std::int8_t { +enum page_id { /************************************************************* * NOTE: enums always increment. Initializing this structure to * -10 is done for consistancy with original #define @@ -67,7 +66,7 @@ enum page_id : std::int8_t { PAGEID_LOGIN }; -enum jump_tags : std::uint8_t { +enum jump_tags { JUMP_NONE, // Don't jump JUMP_NORMAL, // Jump to page, push current page onto stack JUMP_STEALTH, // Jump to page (don't put current page on stack) @@ -84,7 +83,7 @@ constexpr int SCRIPT_STACK_SIZE = 32; constexpr int TITLE_HEIGHT = 32; // Terminal Types -enum term_types : std::uint8_t { +enum term_types { TERMINAL_ORDER_ONLY, // can order but no settling at this term TERMINAL_NORMAL, // normal operation TERMINAL_BAR, // alternate menu index, pay & settle at once @@ -151,7 +150,7 @@ constexpr int COLOR_PAGE_DEFAULT = 254; // color determined by page setting constexpr int COLOR_CLEAR = 253; // text not rendered constexpr int COLOR_UNCHANGED = 252; // don't change value (or treat as default) -enum colors : std::uint8_t { +enum colors { COLOR_BLACK, COLOR_WHITE, COLOR_RED, COLOR_GREEN, COLOR_BLUE, COLOR_YELLOW, COLOR_BROWN, COLOR_ORANGE, COLOR_PURPLE, COLOR_TEAL, COLOR_GRAY, COLOR_MAGENTA, @@ -163,14 +162,14 @@ enum colors : std::uint8_t { constexpr int SHADOW_DEFAULT = 256; // Text Alignment -enum text_align : std::uint8_t { +enum text_align { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT }; // Shape Types -enum shapes : std::uint8_t { +enum shapes { SHAPE_RECTANGLE = 1, SHAPE_DIAMOND, SHAPE_CIRCLE, @@ -185,7 +184,7 @@ constexpr int FRAME_INSET = 32; // top-bottom, left-right colors switched constexpr int FRAME_2COLOR = 64; // 2 colors used instead of 4 // Fonts -enum font_info : std::uint8_t { +enum font_info { FONT_DEFAULT = 0, FONT_TIMES_48 = 1, FONT_TIMES_48B = 2, @@ -260,7 +259,7 @@ enum font_info : std::uint8_t { #define TABOPEN_CANCEL 4 // Cursor Types -enum cursors_style : std::uint8_t { +enum cursors_style { CURSOR_DEFAULT, CURSOR_BLANK, CURSOR_POINTER, @@ -288,11 +287,6 @@ class CharQueue; class Settings; struct BatchItem; -#if defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wanalyzer-optin.performance.Padding" -#endif - class Terminal { // private data @@ -484,7 +478,7 @@ public: int PushPage(int page_id); // puts page id on stack int RunScript(const char* script, int jump_type, int jump_id); int FastStartLogin(); - int OpenTab(int phase = TABOPEN_START, const char* message = nullptr); + int OpenTab(int phase = TABOPEN_START, const char* message = NULL); int ContinueTab(int serial_number = -1); int CloseTab(int serial_number = -1); int OpenTabList(const char* message); @@ -615,7 +609,7 @@ public: bool BeginZoneDragPreview(); bool AddZoneDragDelta(int dx, int dy); void EndZoneDragPreview(bool apply_move); - [[nodiscard]] bool HasActiveZoneDrag() const noexcept { return edit_drag_active; } + bool HasActiveZoneDrag() const noexcept { return edit_drag_active; } int ButtonCommand(int command); int EditZone(Zone *z); @@ -636,26 +630,26 @@ public: // Data read/write functions int WInt8(int val); int WInt8(int *val); - int RInt8(int *val = nullptr); + int RInt8(int *val = NULL); int WInt16(int val); int WInt16(int *val); - int RInt16(int *val = nullptr); + int RInt16(int *val = NULL); int WInt32(int val); int WInt32(int *val); - int RInt32(int *val = nullptr); + int RInt32(int *val = NULL); long WLong(long val); long WLong(long *val); - long RLong(long *val = nullptr); + long RLong(long *val = NULL); long long WLLong(long long val); long long WLLong(long long *val); - long long RLLong(long long *val = nullptr); + long long RLLong(long long *val = NULL); int WFlt(Flt val); int WFlt(Flt *val); - Flt RFlt(Flt *val = nullptr); + Flt RFlt(Flt *val = NULL); int WStr(const std::string &s, int len = 0); int WStr(const Str &s); int WStr(const Str *s); - genericChar* RStr(char* s = nullptr); + genericChar* RStr(char* s = NULL); genericChar* RStr(Str *s); int Send(); int SendNow(); @@ -675,9 +669,9 @@ public: Terminal *CC_NextTermWithID(Terminal *cc_term); int CC_NextTermID( int* cc_state, char* termid ); int CC_NextBatch(int *state, BatchItem **currbatch, long long *batch); - int CC_Settle(const char* batch = nullptr, int reset = 0); + int CC_Settle(const char* batch = NULL, int reset = 0); int CC_Init(); - int CC_Totals(const char* batch = nullptr); + int CC_Totals(const char* batch = NULL); int CC_Details(); int CC_ClearSAF(int reset = 0); int CC_SAFDetails(); @@ -694,10 +688,6 @@ public: friend int CloneTerminal(Terminal *, const char* , const char* ); }; -#if defined(__clang__) -#pragma clang diagnostic pop -#endif - /**** Funtions ****/ int OpenTerminalSocket(const char* hostname, int hardware_type = 0, int isserver = 0, diff --git a/main/ui/chart.cc b/main/ui/chart.cc index b413a3c5..6b2e293b 100644 --- a/main/ui/chart.cc +++ b/main/ui/chart.cc @@ -30,8 +30,8 @@ // Constructor ChartCell::ChartCell() { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; align = ALIGN_LEFT; color = COLOR_DEFAULT; } @@ -40,8 +40,8 @@ ChartCell::ChartCell() // Constructor ChartRow::ChartRow() { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; id = 0; } @@ -49,7 +49,7 @@ ChartRow::ChartRow() // Constructor Chart::Chart() { - current_row = nullptr; + current_row = NULL; } // Member Functions @@ -75,7 +75,7 @@ int Chart::SortByColumn(int id) int Chart::AddRowCell(const char* text) { - if (current_row == nullptr) + if (current_row == NULL) { ChartRow *r = new ChartRow(); if (row_list.Tail()) @@ -95,6 +95,6 @@ int Chart::AddRowCell(const char* text) int Chart::EndRow() { - current_row = nullptr; + current_row = NULL; return 0; } diff --git a/main/ui/chart.hh b/main/ui/chart.hh index cf9f65b0..9af6a320 100644 --- a/main/ui/chart.hh +++ b/main/ui/chart.hh @@ -19,7 +19,7 @@ */ #ifndef _CHART_HH -#define CHART_HH +#define _CHART_HH #include "list_utility.hh" #include "utility.hh" diff --git a/main/ui/labels.cc b/main/ui/labels.cc index a5b37385..5aa42883 100644 --- a/main/ui/labels.cc +++ b/main/ui/labels.cc @@ -67,7 +67,7 @@ const genericChar* FullZoneTypeName[] = { "Expire Messages", "Image Button", "Menu Item", "Modifier", "Non-Tracking Modifier", "Menu Item + Substitute", "Priced By Weight", "Event Admission", - "Index Tab", nullptr + "Index Tab", NULL }; int FullZoneTypeValue[] = { @@ -108,13 +108,13 @@ int FullZoneTypeValue[] = { }; const genericChar* ZoneTypeName[] = { - "Menu Item", "Modifier", "Non-Tracking Modifier", "Menu Item + Substitute", "Priced By Weight", "Event Admission", "Table", "Qualifier", "Image", "Simple", "Index Tab", nullptr}; + "Menu Item", "Modifier", "Non-Tracking Modifier", "Menu Item + Substitute", "Priced By Weight", "Event Admission", "Table", "Qualifier", "Image", "Simple", "Index Tab", NULL}; int ZoneTypeValue[] = { ZONE_ITEM_NORMAL, ZONE_ITEM_MODIFIER, ZONE_ITEM_METHOD, ZONE_ITEM_SUBSTITUTE, ZONE_ITEM_POUND, ZONE_ITEM_ADMISSION, ZONE_TABLE, ZONE_QUALIFIER, ZONE_IMAGE_BUTTON, ZONE_SIMPLE, ZONE_INDEX_TAB, -1}; const genericChar* ZoneBehaveName[] = { "No Response", "Blink", "Toggle", "Turn On", "Double Touch", - "Touches Pass Through", nullptr}; + "Touches Pass Through", NULL}; int ZoneBehaveValue[] = { BEHAVE_NONE, BEHAVE_BLINK, BEHAVE_TOGGLE, BEHAVE_SELECT, BEHAVE_DOUBLE, BEHAVE_MISS, -1}; @@ -124,7 +124,7 @@ const genericChar* ZoneFrameName[] = { "Raised Edge", "Inset Edge", "Double Raised Edge", "Raised Border", "Clear Border", "Sand Border", "Lit Sand Border", "Inset Border", "Parchment Border", - "Double Border", "Lit Double Border", nullptr}; + "Double Border", "Lit Double Border", NULL}; int ZoneFrameValue[] = { ZF_DEFAULT, ZF_HIDDEN, ZF_NONE, ZF_RAISED, ZF_INSET, ZF_DOUBLE, @@ -169,7 +169,7 @@ const genericChar* TextureName[] = { "Bread", "Lava", "Dark Marble", - nullptr + NULL }; int TextureValue[] = { @@ -221,7 +221,7 @@ const genericChar* PageTypeName[] = { "Kitchen 1 Page", "Kitchen 2 Page", "Bar 1 Page", "Bar 2 Page", "Modifier Page with Keyboard", "Index with Tabs", - nullptr}; + NULL}; int PageTypeValue[] = { PAGE_TABLE, PAGE_TABLE2, @@ -238,7 +238,7 @@ const genericChar* PageType2Name[] = { "Table Page", "Table Page Showing Guest Check", "Index Page", "Menu Item Page", "Modifier Page", "Modifier Page without Continue", - "Modifier Page without Continue or Complete", "Menu Board Page", nullptr}; + "Modifier Page without Continue or Complete", "Menu Board Page", NULL}; int PageType2Value[] = { PAGE_TABLE, PAGE_TABLE2, @@ -248,7 +248,7 @@ int PageType2Value[] = { const genericChar* JumpTypeName[] = { "* No Jump *", "Jump", "Move", - "Return From A Jump", "Follow A Script", "Return to Index", nullptr}; + "Return From A Jump", "Follow A Script", "Return to Index", NULL}; int JumpTypeValue[] = { JUMP_NONE, JUMP_NORMAL, JUMP_STEALTH, JUMP_RETURN, JUMP_SCRIPT, JUMP_INDEX, -1}; @@ -257,24 +257,24 @@ const genericChar* FullJumpTypeName[] = { "Remain On This Page", "Jump To A Modifier Page", "Move To A Menu Item Page", "Return From A Jump", "Follow The Script", "Return to Index", "Return To The Starting Page", - "Query Password Then Jump", nullptr}; + "Query Password Then Jump", NULL}; int FullJumpTypeValue[] = { JUMP_NONE, JUMP_NORMAL, JUMP_STEALTH, JUMP_RETURN, JUMP_SCRIPT, JUMP_INDEX, JUMP_HOME, JUMP_PASSWORD, -1}; const genericChar* ShadowName[] = { - "Default", "No Shadow", "Minimal", "Normal", "Maximum", nullptr}; + "Default", "No Shadow", "Minimal", "Normal", "Maximum", NULL}; int ShadowValue[] = { 256, 0, 4, 6, 9, -1}; const genericChar* PageShadowName[] = { - "No Shadow", "Minimal", "Normal", "Maximum", nullptr}; + "No Shadow", "Minimal", "Normal", "Maximum", NULL}; int PageShadowValue[] = { 0, 4, 6, 9, -1}; const genericChar* PageSizeName[] = { "640x480", "768x1024", "800x480", "800x600", "1024x600", "1024x768", "1280x800", "1280x1024", "1366x768", "1440x900", "1600x900", "1600x1200", "1680x1050", - "1920x1080", "1920x1200", "2560x1440", "2560x1600", nullptr}; + "1920x1080", "1920x1200", "2560x1440", "2560x1600", NULL}; int PageSizeValue[] = { SIZE_640x480, SIZE_768x1024, SIZE_800x480, SIZE_800x600, SIZE_1024x600, SIZE_1024x768, SIZE_1280x800, SIZE_1280x1024, SIZE_1366x768, SIZE_1440x900, SIZE_1600x900, SIZE_1600x1200, SIZE_1680x1050, SIZE_1920x1080, SIZE_1920x1200, SIZE_2560x1440, SIZE_2560x1600, -1}; @@ -284,7 +284,7 @@ const genericChar* ColorName[] = { "Brown", "Orange", "Purple", "Teal", "Gray", "Magenta", "Red-Orange", "Sea Green", "Dark Brown", "Dark Red", "Dark Green", "Dark Blue", "Dark Teal", "Dark Magenta", "Dark Sea Green", - "Transparent", nullptr}; + "Transparent", NULL}; int ColorValue[] = { COLOR_PAGE_DEFAULT, COLOR_BLACK, COLOR_WHITE, COLOR_RED, COLOR_GREEN, COLOR_BLUE, COLOR_YELLOW, COLOR_BROWN, COLOR_ORANGE, COLOR_PURPLE, @@ -312,7 +312,7 @@ const genericChar* FontName[] = { "Liberation Serif 20pt", "Liberation Serif 18pt Bold", "Liberation Serif 20pt Bold", - nullptr}; + NULL}; int FontValue[] = { FONT_DEFAULT, // Core working fonts only @@ -338,7 +338,7 @@ const genericChar* IndexName[] = { "General", "Breakfast", "Brunch", "Lunch", "Early Dinner", "Dinner", "Late Night", "Bar", "Wine", "Cafe", - "Room", "Retail", nullptr }; + "Room", "Retail", NULL }; int IndexValue[] = { INDEX_GENERAL, INDEX_BREAKFAST, INDEX_BRUNCH, INDEX_LUNCH, @@ -347,13 +347,13 @@ int IndexValue[] = { INDEX_ROOM, INDEX_RETAIL, -1 }; const genericChar* ShapeName[] = { - "Rectangle", "Diamond", "Circle", "Hexagon", "Octagon", "Triangle", nullptr }; + "Rectangle", "Diamond", "Circle", "Hexagon", "Octagon", "Triangle", NULL }; int ShapeValue[] = { SHAPE_RECTANGLE, SHAPE_DIAMOND, SHAPE_CIRCLE, SHAPE_HEXAGON, SHAPE_OCTAGON, SHAPE_TRIANGLE, -1 }; const genericChar* ItemTypeName[] = { - "Menu Item", "Modifier", "Non-Tracking Modifier", "Menu Item + Substitute", "Priced By Weight", "Event Admission", nullptr }; + "Menu Item", "Modifier", "Non-Tracking Modifier", "Menu Item + Substitute", "Priced By Weight", "Event Admission", NULL }; int ItemTypeValue[] = { ITEM_NORMAL, ITEM_MODIFIER, ITEM_METHOD, ITEM_SUBSTITUTE, ITEM_POUND, ITEM_ADMISSION, -1}; @@ -368,7 +368,7 @@ const genericChar* FamilyName[] = { "Beverage", "Beer", "Bottled Beer", "Wine", "Bottled Wine", "Alcohol", "Cocktail", "Malt Beverage", "Modifier", "Reorder", - "Merchandise", "Room", nullptr}; + "Merchandise", "Room", NULL}; int FamilyValue[] = { FAMILY_ALACARTE, FAMILY_APPETIZERS, FAMILY_BREAKFAST_ENTREES, @@ -397,7 +397,7 @@ const genericChar* SalesTypeName[] = { "Merchandise", "Merchandise (No Comp or Discount)", "Not Taxed (No Comp or Discount)", - nullptr}; + NULL}; int SalesTypeValue[] = { SALES_FOOD, @@ -416,7 +416,7 @@ int SalesTypeValue[] = { -1}; const genericChar* CallOrderName[] = { - "1st (top)", "2nd", "3rd (middle)", "4th", "5th (bottom)", nullptr}; + "1st (top)", "2nd", "3rd (middle)", "4th", "5th (bottom)", NULL}; int CallOrderValue[] = { 0, 1, 2, 3, 4, -1}; @@ -424,12 +424,12 @@ const genericChar* QualifierName[] = { "No", "Sub", "On Side", "Lite", "Only", "Extra", "Double", "Dry", "Plain", "Toast", "UnToast", "Crisp", "Soft", "Hard", "Grill", "< Left", "Right >", "Whole", "Cut/2", "Cut/3", "Cut/4", - "Easy", "Add", "Senior Share", nullptr}; + "Easy", "Add", "Senior Share", NULL}; const genericChar* QualifierShortName[] = { "no", "sub", "side", "lite", "only", "extra", "double", "dry", "plain", "toast", "untoast", "crisp", "soft", "hard", "grill", "< left", "right >", "whole", "cut/2", "cut/3", "cut/4", - "easy", "add", "senior share", nullptr}; + "easy", "add", "senior share", NULL}; int QualifierValue[] = { QUALIFIER_NO, QUALIFIER_SUB, QUALIFIER_SIDE, QUALIFIER_LITE, QUALIFIER_ONLY, QUALIFIER_EXTRA, QUALIFIER_DOUBLE, QUALIFIER_DRY, QUALIFIER_PLAIN, QUALIFIER_TOASTED, QUALIFIER_UNTOASTED, QUALIFIER_CRISPY, QUALIFIER_SOFT, QUALIFIER_HARD, QUALIFIER_GRILLED, @@ -450,7 +450,7 @@ const genericChar* SwitchName[] = { "Show Modifiers", "Allow Multiple Coupons", "Print All Modifiers on Receipt", "Auto Print Drawer Report", "Balance Automatic Coupons", "Enable F3/F4 Recording/Replay", "Auto-Update vt_data on Startup", - "Show Button Images", nullptr}; + "Show Button Images", NULL}; int SwitchValue[] = { SWITCH_SEATS, SWITCH_DRAWER_MODE, SWITCH_PASSWORDS, SWITCH_SALE_CREDIT, SWITCH_DISCOUNT_ALCOHOL, SWITCH_CHANGE_FOR_CHECKS, @@ -472,7 +472,7 @@ const genericChar* ReportTypeName[] = { "Server Labor", "Item Comp Exception", "Item Void Exception", "Table Exception", "Check Rebuild Exception", "Customer Detail", "Expenses", "Royalty", - "Auditing", "CreditCard", nullptr}; + "Auditing", "CreditCard", NULL}; int ReportTypeValue[] = { REPORT_SERVER, REPORT_CLOSEDCHECK, REPORT_DRAWER, REPORT_CHECK, REPORT_SALES, REPORT_BALANCE, REPORT_DEPOSIT, @@ -482,20 +482,20 @@ int ReportTypeValue[] = { REPORT_AUDITING, REPORT_CREDITCARD, -1}; const genericChar* CheckDisplayOrderName[] = { - "Oldest to Newest", "Newest to Oldest", nullptr }; + "Oldest to Newest", "Newest to Oldest", NULL }; int CheckDisplayOrderValue[] = { CHECK_ORDER_OLDNEW, CHECK_ORDER_NEWOLD, -1 }; const genericChar* ReportPrintName[] = { "Don't Print On Touch", "Print On Local Printer", "Print On Report Printer", - "Ask User", nullptr}; + "Ask User", NULL}; int ReportPrintValue[] = { RP_NO_PRINT, RP_PRINT_LOCAL, RP_PRINT_REPORT, RP_ASK, -1}; const genericChar* TenderName[] = { "Cash", "Check", "Gift Certificate", "House Account", "Charge Room", "Gratuity", "Credit Card", "Discount", - "Coupon", "Comp", "Employee Meal", "Tip", "Credit Card Fee (Dollar)", "Credit Card Fee (Percent)", nullptr}; + "Coupon", "Comp", "Employee Meal", "Tip", "Credit Card Fee (Dollar)", "Credit Card Fee (Percent)", NULL}; int TenderValue[] = { TENDER_CASH, TENDER_CHECK, TENDER_GIFT, TENDER_ACCOUNT, TENDER_CHARGE_ROOM, TENDER_GRATUITY, TENDER_CHARGE_CARD, TENDER_DISCOUNT, @@ -504,7 +504,7 @@ int TenderValue[] = { const genericChar* PrinterIDName[] = { "Default", "Kitchen1", "Kitchen2", "Bar1", "Bar2", "Expediter", "Kitchen1 notify2", "Kitchen2 notify1", - "Remote Order", "None", nullptr}; + "Remote Order", "None", NULL}; int PrinterIDValue[] = { PRINTER_DEFAULT, PRINTER_KITCHEN1, PRINTER_KITCHEN2, PRINTER_BAR1, PRINTER_BAR2, PRINTER_EXPEDITER, @@ -512,68 +512,68 @@ int PrinterIDValue[] = { PRINTER_REMOTEORDER, PRINTER_NONE, -1}; const genericChar* CustomerTypeName[] = { - "Restaurant", "Take Out", "Delivery", "Hotel", "Retail", "Fast Food", "Self Order", "For Here", "To Go", "Call In", nullptr}; + "Restaurant", "Take Out", "Delivery", "Hotel", "Retail", "Fast Food", "Self Order", "For Here", "To Go", "Call In", NULL}; int CustomerTypeValue[] = { CHECK_RESTAURANT, CHECK_TAKEOUT, CHECK_DELIVERY, CHECK_HOTEL, CHECK_RETAIL, CHECK_FASTFOOD, CHECK_SELFORDER, CHECK_DINEIN, CHECK_TOGO, CHECK_CALLIN, -1}; const genericChar* PriceTypeName[] = { - "Price/Item", "Price/Hour", "Price/Day", nullptr }; + "Price/Item", "Price/Hour", "Price/Day", NULL }; int PriceTypeValue[] = { PRICE_PERITEM, PRICE_PERHOUR, PRICE_PERDAY, -1}; const genericChar* DrawerZoneTypeName[] = { - "Pull/Balance", "Drawer Selecter", nullptr }; + "Pull/Balance", "Drawer Selecter", NULL }; int DrawerZoneTypeValue[] = { DRAWER_ZONE_BALANCE, DRAWER_ZONE_SELECT, -1 }; const genericChar* CustDispUnitName[] = { - "None", "Epson", "Ba63", nullptr }; + "None", "Epson", "Ba63", NULL }; int CustDispUnitValue[] = { CDU_TYPE_NONE, CDU_TYPE_EPSON, CDU_TYPE_BA63, -1 }; const genericChar* CCTypeName[] = { "VISA", "MasterCard", "American Express", - "Discover", "Diner's Club", "Debit", nullptr }; + "Discover", "Diner's Club", "Debit", NULL }; int CCTypeValue[] = { CREDIT_TYPE_VISA, CREDIT_TYPE_MASTERCARD, CREDIT_TYPE_AMEX, CREDIT_TYPE_DISCOVER, CREDIT_TYPE_DINERSCLUB, CREDIT_TYPE_DEBIT, -1 }; const genericChar* ReportPeriodName[] = { - "Archive", "Day", "Week", "2 Weeks", "Month", "Quarter", "Year to Date", nullptr }; + "Archive", "Day", "Week", "2 Weeks", "Month", "Quarter", "Year to Date", NULL }; int ReportPeriodValue[] = { SP_NONE, SP_DAY, SP_WEEK, SP_2WEEKS, SP_MONTH, SP_QUARTER, SP_YTD, -1 }; -const char* YesNoName[] = {"Yes", "No", nullptr}; +const char* YesNoName[] = {"Yes", "No", NULL}; int YesNoValue[] = {1, 0, -1}; -const char* NoYesName[] = {"No", "Yes", nullptr}; +const char* NoYesName[] = {"No", "Yes", NULL}; int NoYesValue[] = {0, 1, -1}; -const char* NoYesGlobalName[] = {"No", "Yes", "Global", nullptr}; +const char* NoYesGlobalName[] = {"No", "Yes", "Global", NULL}; int NoYesGlobalValue[] = {0, 1, -1, -1}; -const char* SplitCheckName[] = {"Item", "Seat", nullptr}; +const char* SplitCheckName[] = {"Item", "Seat", NULL}; int SplitCheckValue[] = {SPLIT_CHECK_ITEM, SPLIT_CHECK_SEAT, -1}; -const char* ModSeparatorName[] = {"New Line", "Comma", nullptr}; +const char* ModSeparatorName[] = {"New Line", "Comma", NULL}; int ModSeparatorValue[] = {MOD_SEPARATE_NL, MOD_SEPARATE_CM, -1}; -const char* CouponApplyName[] = {"Once", "Each", nullptr}; +const char* CouponApplyName[] = {"Once", "Each", NULL}; int CouponApplyValue[] = {COUPON_APPLY_ONCE, COUPON_APPLY_EACH, -1}; -const char* DateTimeName[] = {"Always Available", "Once", "Daily", "Monthly", nullptr}; +const char* DateTimeName[] = {"Always Available", "Once", "Daily", "Monthly", NULL}; int DateTimeValue[] = {DATETIME_NONE, DATETIME_ONCE, DATETIME_DAILY, DATETIME_MONTHLY, -1}; const char* PrintModeName[] = { - "Normal", "Tall", "Wide", "Wide & Tall", nullptr}; + "Normal", "Tall", "Wide", "Wide & Tall", NULL}; int PrintModeValue[] = { 0, PRINT_TALL, PRINT_WIDE, PRINT_TALL | PRINT_WIDE, -1}; const char* KVPrintMethodName[] = { - "Unmatched", "Matched", nullptr}; + "Unmatched", "Matched", NULL}; int KVPrintMethodValue[] = { KV_PRINT_UNMATCHED, KV_PRINT_MATCHED, -1}; -const char* WOHeadingName[] = {"Standard", "Simple", nullptr}; +const char* WOHeadingName[] = {"Standard", "Simple", NULL}; int WOHeadingValue[] = {0, 1, -1}; diff --git a/main/ui/labels.hh b/main/ui/labels.hh index c94d450d..b0972095 100644 --- a/main/ui/labels.hh +++ b/main/ui/labels.hh @@ -18,8 +18,8 @@ * Various symbols & definitions */ -#ifndef LABELS_HH -#define LABELS_HH +#ifndef _LABELS_HH +#define _LABELS_HH #include "basic.hh" diff --git a/main/ui/report.cc b/main/ui/report.cc index 2949d81e..22c133b3 100644 --- a/main/ui/report.cc +++ b/main/ui/report.cc @@ -128,7 +128,7 @@ int Report::Load(const std::string &textfile, int color) return 1; FILE *fp = fopen(textfile.c_str(), "r"); - if (fp == nullptr) + if (fp == NULL) { snprintf(buffer, STRLENGTH, "Report::Load Error %d opening %s", errno, textfile.c_str()); @@ -235,7 +235,7 @@ int Report::CreateHeader(Terminal *term, Printer *p, const Employee *e) FnTrace("Report::CreateHeader()"); char buffer[STRLENGTH]; - if (e == nullptr) + if (e == NULL) return 1; Settings *s = term->GetSettings(); @@ -245,7 +245,7 @@ int Report::CreateHeader(Terminal *term, Printer *p, const Employee *e) genericChar str[256]; vt_safe_string::safe_format(str, 256, "%s: %s", term->Translate("Author"), e->system_name.Value()); - if (p == nullptr || p->Width() < 80) + if (p == NULL || p->Width() < 80) { TextL(s->store_name.Value()); NewLine(); @@ -417,7 +417,7 @@ int Report::Render(Terminal *term, LayoutZone *lz, Flt header_size, int Report::Print(Printer *printer) { FnTrace("Report::Print()"); - if (printer == nullptr) + if (printer == NULL) return 1; int max_w = printer->MaxWidth(); @@ -492,7 +492,7 @@ int Report::FormalPrint(Printer *printer, int /*columns*/) char buffer[STRLONG] = ""; int lang = LANG_PHRASE; - if (printer == nullptr) + if (printer == NULL) return 1; int max_w = printer->MaxWidth(); diff --git a/main/ui/report.hh b/main/ui/report.hh index 50f32cb3..9733fb5f 100644 --- a/main/ui/report.hh +++ b/main/ui/report.hh @@ -18,8 +18,8 @@ * layout & formating of report information */ -#ifndef REPORT_HH -#define REPORT_HH +#ifndef _REPORT_HH +#define _REPORT_HH #include "utility.hh" #include "terminal.hh" @@ -64,8 +64,16 @@ #define RP_DEST_SCREEN 1 #define RP_DEST_PRINTER 2 -// Print Modes come from printer.hh -#include "printer.hh" +//FIX BAK->GET THIS OUT OF HERE!!! It should only be in printer.hh. +// Print Modes (should match printer.hh) +#define PRINT_RED 1 // use red ink (if available) +#define PRINT_BOLD 2 // bold text +#define PRINT_UNDERLINE 4 // underline text +#define PRINT_NARROW 8 // condensed width text +#define PRINT_WIDE 16 // print double width only +#define PRINT_TALL 32 // print double height only +#define PRINT_LARGE 48 // print double width & height +#define PRINT_BLUE 64 // blue text (if available) // Other #define MAX_REPORT_COLUMNS 16 @@ -94,7 +102,7 @@ public: ReportEntry(const char *t, int c, int a, int m); ReportEntry(const std::string &t, int c, int a, int m); // Destructor - ~ReportEntry() = default; + ~ReportEntry() {} }; diff --git a/main/ui/system_report.cc b/main/ui/system_report.cc index 6492ddae..12b7ad9a 100644 --- a/main/ui/system_report.cc +++ b/main/ui/system_report.cc @@ -523,7 +523,7 @@ int System::ShiftBalanceReport(Terminal *term, TimeInfo &ref, Report *ptrReport) coupinfo = coupinfo->next; } - for (SubCheck *sc = thisCheck->SubList(); sc != nullptr; sc = sc->next) + for (SubCheck *sc = thisCheck->SubList(); sc != NULL; sc = sc->next) { for (int sg = SALESGROUP_FOOD; sg <= SALESGROUP_ROOM; ++sg) group_sales[sn][sg] += sc->GrossSales(thisCheck, currSettings, sg); @@ -538,13 +538,13 @@ int System::ShiftBalanceReport(Terminal *term, TimeInfo &ref, Report *ptrReport) fastfood_sales[sn] += my_sales; item_comp[sn] += sc->item_comps; - for (Payment *thisPayment = sc->PaymentList(); thisPayment != nullptr; thisPayment = thisPayment->next) + for (Payment *thisPayment = sc->PaymentList(); thisPayment != NULL; thisPayment = thisPayment->next) { switch (thisPayment->tender_type) { case TENDER_COMP: { - compinfo = nullptr; + compinfo = NULL; if (a) compinfo = a->FindCompByID(thisPayment->tender_id); else @@ -555,7 +555,7 @@ int System::ShiftBalanceReport(Terminal *term, TimeInfo &ref, Report *ptrReport) break; case TENDER_EMPLOYEE_MEAL: { - mealinfo = nullptr; + mealinfo = NULL; if (a) mealinfo = a->FindMealByID(thisPayment->tender_id); else @@ -566,7 +566,7 @@ int System::ShiftBalanceReport(Terminal *term, TimeInfo &ref, Report *ptrReport) break; case TENDER_DISCOUNT: { - discinfo = nullptr; + discinfo = NULL; if (a) discinfo = a->FindDiscountByID(thisPayment->tender_id); else @@ -577,7 +577,7 @@ int System::ShiftBalanceReport(Terminal *term, TimeInfo &ref, Report *ptrReport) break; case TENDER_COUPON: { - coupinfo = nullptr; + coupinfo = NULL; if (a) coupinfo = a->FindCouponByID(thisPayment->tender_id); else @@ -593,7 +593,7 @@ int System::ShiftBalanceReport(Terminal *term, TimeInfo &ref, Report *ptrReport) } } - if (a == nullptr || a->end_time > end) + if (a == NULL || a->end_time > end) break; a = a->next; @@ -790,7 +790,7 @@ int System::ShiftBalanceReport(Terminal *term, TimeInfo &ref, Report *ptrReport) if (term->expand_goodwill) { MediaList *comps = &complist; - while (comps != nullptr) + while (comps != NULL) { if (comps->name[0] != '\0' && (comps->total != 0 || term->hide_zeros == 0)) { @@ -842,7 +842,7 @@ int System::ShiftBalanceReport(Terminal *term, TimeInfo &ref, Report *ptrReport) if (term->expand_goodwill) { MediaList *meals = &meallist; - while (meals != nullptr) + while (meals != NULL) { if (meals->name[0] != '\0' && (meals->total != 0 || term->hide_zeros == 0)) { @@ -880,7 +880,7 @@ int System::ShiftBalanceReport(Terminal *term, TimeInfo &ref, Report *ptrReport) if (term->expand_goodwill) { MediaList *discounts = &discountlist; - while (discounts != nullptr) + while (discounts != NULL) { if (discounts->name[0] != '\0' && (discounts->total != 0 || term->hide_zeros == 0)) { @@ -918,7 +918,7 @@ int System::ShiftBalanceReport(Terminal *term, TimeInfo &ref, Report *ptrReport) if (term->expand_goodwill) { MediaList *coupons = &couponlist; - while (coupons != nullptr) + while (coupons != NULL) { if (coupons->name[0] != '\0' && (coupons->total != 0 || term->hide_zeros == 0)) { @@ -1381,7 +1381,7 @@ int BalanceReportWorkFn(BRData *brdata) // Early exit if there are no checks to process if (c == nullptr) { thisReport->is_complete = 1; - brdata->term->Update(UPDATE_REPORT, nullptr); + brdata->term->Update(UPDATE_REPORT, NULL); delete brdata; return 1; // end work fn } @@ -1389,30 +1389,30 @@ int BalanceReportWorkFn(BRData *brdata) // Process Media entries if both archive and lastArchive are null, in which // case we just process the media entries in settings, or once for each // archive. - if ((brdata->archive == nullptr && brdata->lastArchive == nullptr) || + if ((brdata->archive == NULL && brdata->lastArchive == NULL) || (brdata->archive && (brdata->archive != brdata->lastArchive))) { // Add the media titles for this archive CompInfo *compinfo = brdata->archive ? brdata->archive->CompList() : currSettings->CompList(); - while (compinfo != nullptr) + while (compinfo != NULL) { brdata->complist.Add(compinfo->name.Value(), 0); compinfo = compinfo->next; } MealInfo *mealinfo = brdata->archive ? brdata->archive->MealList() : currSettings->MealList(); - while (mealinfo != nullptr) + while (mealinfo != NULL) { brdata->meallist.Add(mealinfo->name.Value(), 0); mealinfo = mealinfo->next; } DiscountInfo *discinfo = brdata->archive ? brdata->archive->DiscountList() : currSettings->DiscountList(); - while (discinfo != nullptr) + while (discinfo != NULL) { brdata->discountlist.Add(discinfo->name.Value(), 0); discinfo = discinfo->next; } CouponInfo *coupinfo = brdata->archive ? brdata->archive->CouponList() : currSettings->CouponList(); - while (coupinfo != nullptr) + while (coupinfo != NULL) { brdata->couponlist.Add(coupinfo->name.Value(), 0); coupinfo = coupinfo->next; @@ -1435,7 +1435,7 @@ int BalanceReportWorkFn(BRData *brdata) else brdata->guests += c->Guests(); - for (SubCheck *sc = c->SubList(); sc != nullptr; sc = sc->next) + for (SubCheck *sc = c->SubList(); sc != NULL; sc = sc->next) { for (int sg = SALESGROUP_FOOD; sg <= SALESGROUP_ROOM; ++sg) { @@ -1457,12 +1457,12 @@ int BalanceReportWorkFn(BRData *brdata) MealInfo *mealinfo; brdata->item_comp += sc->item_comps; - for (Payment *p = sc->PaymentList(); p != nullptr; p = p->next) + for (Payment *p = sc->PaymentList(); p != NULL; p = p->next) { switch (p->tender_type) { case TENDER_COMP: - compinfo = nullptr; + compinfo = NULL; if (brdata->archive) compinfo = brdata->archive->FindCompByID(p->tender_id); else @@ -1471,7 +1471,7 @@ int BalanceReportWorkFn(BRData *brdata) brdata->complist.Add(compinfo->name.Value(), p->value); break; case TENDER_EMPLOYEE_MEAL: - mealinfo = nullptr; + mealinfo = NULL; if (brdata->archive) mealinfo = brdata->archive->FindMealByID(p->tender_id); else @@ -1480,7 +1480,7 @@ int BalanceReportWorkFn(BRData *brdata) brdata->meallist.Add(mealinfo->name.Value(), p->value); break; case TENDER_DISCOUNT: - discinfo = nullptr; + discinfo = NULL; if (brdata->archive) discinfo = brdata->archive->FindDiscountByID(p->tender_id); else @@ -1489,7 +1489,7 @@ int BalanceReportWorkFn(BRData *brdata) brdata->discountlist.Add(discinfo->name.Value(), p->value); break; case TENDER_COUPON: - coupinfo = nullptr; + coupinfo = NULL; if (brdata->archive) coupinfo = brdata->archive->FindCouponByID(p->tender_id); else @@ -1609,7 +1609,7 @@ int BalanceReportWorkFn(BRData *brdata) if (term->expand_goodwill) { MediaList *comps = &(brdata->complist); - while (comps != nullptr) + while (comps != NULL) { if (comps->name[0] != '\0' && (comps->total != 0 || term->hide_zeros == 0)) { @@ -1638,7 +1638,7 @@ int BalanceReportWorkFn(BRData *brdata) if (term->expand_goodwill) { MediaList *meals = &(brdata->meallist); - while (meals != nullptr) + while (meals != NULL) { if (meals->name[0] != '\0' && (meals->total != 0 || term->hide_zeros == 0)) { @@ -1660,7 +1660,7 @@ int BalanceReportWorkFn(BRData *brdata) if (term->expand_goodwill) { MediaList *discounts = &(brdata->discountlist); - while (discounts != nullptr) + while (discounts != NULL) { if (discounts->name[0] != '\0' && (discounts->total != 0 || term->hide_zeros == 0)) { @@ -1682,7 +1682,7 @@ int BalanceReportWorkFn(BRData *brdata) if (term->expand_goodwill) { MediaList *coupons = &(brdata->couponlist); - while (coupons != nullptr) + while (coupons != NULL) { if (coupons->name[0] != '\0' && (coupons->total != 0 || term->hide_zeros == 0)) { @@ -1870,7 +1870,7 @@ int BalanceReportWorkFn(BRData *brdata) thisReport->TextPosR(last_pos, str, color); thisReport->is_complete = 1; - brdata->term->Update(UPDATE_REPORT, nullptr); + brdata->term->Update(UPDATE_REPORT, NULL); delete brdata; return 1; // end work fn @@ -1880,7 +1880,7 @@ int BalanceReportWorkFn(BRData *brdata) int System::BalanceReport(Terminal *term, TimeInfo &start_time, TimeInfo &end_time, Report *report) { FnTrace("System::BalanceReport()"); - if (report == nullptr) + if (report == NULL) return 1; // report->SetTitle(BALANCE_TITLE); Let the Button's Name Field provide the Title for this report @@ -1929,11 +1929,11 @@ int System::DepositReport(Terminal *term, TimeInfo &start_time, Report *report) { FnTrace("System::DepositReport()"); - if (report == nullptr) + if (report == NULL) return 1; // Validate input parameters - if (term == nullptr) + if (term == NULL) { ReportError("DepositReport: Invalid terminal parameter"); return 1; @@ -1974,7 +1974,7 @@ int System::DepositReport(Terminal *term, TimeInfo &start_time, start_a = FindByTime(start_time); // Validate archive - if (start_a == nullptr) + if (start_a == NULL) { ReportError("DepositReport: Could not find archive for time range"); report->TextC("Error: Could not find archive for specified time range"); @@ -2034,7 +2034,7 @@ int System::DepositReport(Terminal *term, TimeInfo &start_time, { Check *firstcheck = FirstCheck(a); // Scan checks - for (Check *c = firstcheck; c != nullptr; c = c->next) + for (Check *c = firstcheck; c != NULL; c = c->next) { // Validate check pointer if (c == nullptr) @@ -2046,20 +2046,20 @@ int System::DepositReport(Terminal *term, TimeInfo &start_time, continue; TimeInfo *timevar = c->TimeClosed(); - if (timevar != nullptr && *timevar >= start_time && *timevar < end_time) + if (timevar != NULL && *timevar >= start_time && *timevar < end_time) { // bury the incomplete check here. That way it won't be incomplete just // because we hit the end of the archives, but because we hit the end // of the archives and still had qualifying data. - if (a == nullptr) + if (a == NULL) incomplete = 1; check_count++; // Count closed checks for (SubCheck *subcheck = c->SubList(); - subcheck != nullptr; + subcheck != NULL; subcheck = subcheck->next) { // Validate subcheck pointer - if (subcheck == nullptr) + if (subcheck == NULL) continue; if (subcheck->settle_time.IsSet() && @@ -2092,20 +2092,20 @@ int System::DepositReport(Terminal *term, TimeInfo &start_time, Drawer *drawer = FirstDrawer(a); do { // Validate drawer pointer - if (drawer == nullptr) + if (drawer == NULL) break; // the drawer must exist and it either must be today's drawer while today is // being processed (incomplete != 0) or it must fit into the date range // of the report. - if (drawer != nullptr && + if (drawer != NULL && (incomplete || (drawer->balance_time >= start_time && drawer->balance_time < end_time))) { drawer->Total(firstcheck, 1); CreditCardInfo *credinfo = a ? a->CreditCardList() : s->CreditCardList(); - while (credinfo != nullptr) + while (credinfo != NULL) { int balance = 0; if (drawer) @@ -2175,7 +2175,7 @@ int System::DepositReport(Terminal *term, TimeInfo &start_time, } if (drawer) drawer = drawer->next; - } while (drawer != nullptr); + } while (drawer != NULL); // Scan Tips if (a) @@ -2191,7 +2191,7 @@ int System::DepositReport(Terminal *term, TimeInfo &start_time, tips_held += tip_db.total_held; } - if (a == nullptr || archive) + if (a == NULL || archive) break; if (a->end_time >= end) { @@ -2414,7 +2414,7 @@ int System::DepositReport(Terminal *term, TimeInfo &start_time, report->NewLine(); MediaList *mediacomp = &complist; - while (mediacomp != nullptr) + while (mediacomp != NULL) { if (mediacomp->name[0] != '\0' && (mediacomp->total != 0 || term->hide_zeros == 0)) { @@ -2433,7 +2433,7 @@ int System::DepositReport(Terminal *term, TimeInfo &start_time, } MediaList *mediameal = &meallist; - while (mediameal != nullptr) + while (mediameal != NULL) { if (mediameal->name[0] != '\0' && (mediameal->total != 0 || term->hide_zeros == 0)) { @@ -2445,7 +2445,7 @@ int System::DepositReport(Terminal *term, TimeInfo &start_time, } MediaList *mediadiscount = &discountlist; - while (mediadiscount != nullptr) + while (mediadiscount != NULL) { if (mediadiscount->name[0] != '\0' && (mediadiscount->total != 0 || term->hide_zeros == 0)) { @@ -2457,7 +2457,7 @@ int System::DepositReport(Terminal *term, TimeInfo &start_time, } MediaList *mediacoupon = &couponlist; - while (mediacoupon != nullptr) + while (mediacoupon != NULL) { if (mediacoupon->name[0] != '\0' && (mediacoupon->total != 0 || term->hide_zeros == 0)) { @@ -2601,7 +2601,7 @@ int System::DepositReport(Terminal *term, TimeInfo &start_time, if (settings.authorize_method == CCAUTH_NONE) { MediaList *mediacredit = &creditcardlist; - while (mediacredit != nullptr) + while (mediacredit != NULL) { if (mediacredit->name[0] != '\0' && (mediacredit->total != 0 || term->hide_zeros == 0)) { @@ -2838,15 +2838,15 @@ class CCRData // Constructor CCRData() { - report = nullptr; + report = NULL; none = 1; total_amount = 0; total_guests = 0; total_number = 0; - term = nullptr; - system = nullptr; - archive = nullptr; - check = nullptr; + term = NULL; + system = NULL; + archive = NULL; + check = NULL; user_id = 0; training = 0; } @@ -2862,7 +2862,7 @@ int ClosedCheckReportWorkFn(CCRData *ccrdata) genericChar str[256]; Check *thisCheck = ccrdata->check; - if (thisCheck == nullptr) + if (thisCheck == NULL) thisCheck = sys->FirstCheck(ccrdata->archive); while (thisCheck) @@ -2871,7 +2871,7 @@ int ClosedCheckReportWorkFn(CCRData *ccrdata) thisCheck->WhoGetsSale(s) == ccrdata->user_id) { int amount = 0, flag = 0; - for (SubCheck *sc = thisCheck->SubList(); sc != nullptr; sc = sc->next) + for (SubCheck *sc = thisCheck->SubList(); sc != NULL; sc = sc->next) if (sc->status == CHECK_CLOSED && sc->settle_time < ccrdata->end && sc->settle_time >= ccrdata->start) { @@ -2968,7 +2968,7 @@ int ClosedCheckReportWorkFn(CCRData *ccrdata) thisReport->Divider('-'); thisReport->is_complete = 1; - ccrdata->term->Update(UPDATE_REPORT, nullptr); + ccrdata->term->Update(UPDATE_REPORT, NULL); delete ccrdata; return 1; // end work fn } @@ -2977,7 +2977,7 @@ int System::ClosedCheckReport(Terminal *term, TimeInfo &start_time, TimeInfo &en Employee *thisEmployee, Report *thisReport) { FnTrace("System::ClosedCheckReport()"); - if (thisReport == nullptr) + if (thisReport == NULL) return 1; thisReport->update_flag = UPDATE_ARCHIVE | UPDATE_CHECKS | UPDATE_SERVER; @@ -3039,7 +3039,7 @@ int System::ItemExceptionReport(Terminal *term, TimeInfo &start_time, Employee *thisEmployee, Report *thisReport) { FnTrace("System::ItemExceptionReport()"); - if (thisReport == nullptr) + if (thisReport == NULL) return 1; thisReport->update_flag = UPDATE_ARCHIVE | UPDATE_SERVER; @@ -3109,8 +3109,8 @@ int System::ItemExceptionReport(Terminal *term, TimeInfo &start_time, //short exception_was; short reason_is; //short reason_was; - const char* item_is = nullptr; - const char* item_was = nullptr; + const char* item_is = NULL; + const char* item_was = NULL; ItemException *currException = FirstItemException(thisArchive); while (currException) @@ -3170,7 +3170,7 @@ int System::ItemExceptionReport(Terminal *term, TimeInfo &start_time, currException = currException->next; } - if (thisArchive == nullptr || (thisArchive->end_time > end)) + if (thisArchive == NULL || (thisArchive->end_time > end)) break; thisArchive = thisArchive->next; @@ -3186,7 +3186,7 @@ int System::TableExceptionReport(Terminal *term, TimeInfo &start_time, TimeInfo &end_time, Employee *e, Report *report) { FnTrace("System::TableExceptionReport()"); - if (report == nullptr) + if (report == NULL) return 1; report->update_flag = UPDATE_ARCHIVE | UPDATE_SERVER; @@ -3245,7 +3245,7 @@ int System::TableExceptionReport(Terminal *term, TimeInfo &start_time, } te = te->next; } - if (a == nullptr || a->end_time > end) + if (a == NULL || a->end_time > end) break; a = a->next; } @@ -3258,7 +3258,7 @@ int System::RebuildExceptionReport(Terminal *term, TimeInfo &start_time, TimeInfo &end_time, Employee *e, Report *report) { FnTrace("System::RebuildExceptionReport()"); - if (report == nullptr) + if (report == NULL) return 1; report->update_flag = UPDATE_ARCHIVE | UPDATE_SERVER; @@ -3315,7 +3315,7 @@ int System::RebuildExceptionReport(Terminal *term, TimeInfo &start_time, re = re->next; } - if (a == nullptr || a->end_time > end) + if (a == NULL || a->end_time > end) break; a = a->next; } @@ -3327,7 +3327,7 @@ int System::DrawerSummaryReport(Terminal *term, Drawer *my_drawer_list, Check *my_check_list, Report *report) { FnTrace("System::DrawerSummaryReport()"); - if (my_check_list == nullptr || report == nullptr) + if (my_check_list == NULL || report == NULL) return 1; report->update_flag = UPDATE_ARCHIVE | UPDATE_CHECKS | UPDATE_SERVER; @@ -3337,7 +3337,7 @@ int System::DrawerSummaryReport(Terminal *term, Drawer *my_drawer_list, report->NewLine(2); int open = 0, closed = 0, diff = 0; - for (Drawer *drawer = my_drawer_list; drawer != nullptr; drawer = drawer->next) + for (Drawer *drawer = my_drawer_list; drawer != NULL; drawer = drawer->next) { drawer->Total(my_check_list); int status = drawer->GetStatus(); @@ -3366,7 +3366,7 @@ int System::DrawerSummaryReport(Terminal *term, Drawer *my_drawer_list, int System::CustomerDetailReport(Terminal *term, Employee *e, Report *report) { FnTrace("System::CustomerDetailReport()"); - if (report == nullptr || e == nullptr) + if (report == NULL || e == NULL) return 1; report->Mode(PRINT_UNDERLINE); @@ -3381,7 +3381,7 @@ int System::CustomerDetailReport(Terminal *term, Employee *e, Report *report) genericChar name[256]; int training = e->training; report->update_flag = UPDATE_CHECKS; - for (Check *c = FirstCheck(); c != nullptr; c = c->next) + for (Check *c = FirstCheck(); c != NULL; c = c->next) { if (c->CustomerType() != CHECK_HOTEL || c->IsTraining() != training || @@ -3505,7 +3505,7 @@ class Expenses int Copy(Expenses *exp2); Expenses *ImportExpenseDB(ExpenseDB *expense_db, Terminal *term, Archive *archive, int sortby = 0); - Expenses *Insert(Expense *expense, Terminal *term, int sortby, Archive *archive = nullptr); + Expenses *Insert(Expense *expense, Terminal *term, int sortby, Archive *archive = NULL); int LessThan(Expenses *exp2, int sortby); int GreaterThan(Expenses *exp2, int sortby); void Print(); @@ -3547,7 +3547,7 @@ Expenses::Expenses(Expense *expense, Terminal *term, Archive *archive) date = expense->exp_date; payer_id = expense->employee_id; - if (employee != nullptr) + if (employee != NULL) strncpy(payer_name, employee->system_name.Value(), STRLENGTH); else strncpy(payer_name, "Unknown", STRLENGTH); @@ -3561,14 +3561,14 @@ Expenses::Expenses(Expense *expense, Terminal *term, Archive *archive) strncpy(source_name, "Unknown", STRLENGTH); tax_account_num = expense->tax_account_id; - if (tax_account != nullptr) + if (tax_account != NULL) strncpy(tax_account_name, tax_account->name.Value(), STRLENGTH); else strncpy(tax_account_name, "Unknown", STRLENGTH); tax_amount = expense->tax; dest_account_num = expense->dest_account_id; - if (dest_account != nullptr) + if (dest_account != NULL) strncpy(dest_account_name, dest_account->name.Value(), STRLENGTH); else strncpy(dest_account_name, "Unknown", STRLENGTH); @@ -3611,7 +3611,7 @@ Expenses *Expenses::ImportExpenseDB(ExpenseDB *expense_db, Terminal *term, Expenses *retNode = this; Expense *currExpense = expense_db->ExpenseList(); - while (currExpense != nullptr) + while (currExpense != NULL) { retNode = retNode->Insert(currExpense, term, sortby, archive); currExpense = currExpense->next; @@ -3624,7 +3624,7 @@ Expenses *Expenses::Insert(Expense *expense, Terminal *term, int sortby, Archive { FnTrace("Expenses::Insert()"); Expenses *currNode = this; - Expenses *prevNode = nullptr; + Expenses *prevNode = NULL; Expenses *newNode = new Expenses(expense, term, archive); Expenses *retNode = this; // we'll return this int comparison; @@ -3637,7 +3637,7 @@ Expenses *Expenses::Insert(Expense *expense, Terminal *term, int sortby, Archive done = 1; } - while (currNode != nullptr && done != 1) + while (currNode != NULL && done != 1) { if (sortby & EXPENSE_SORTBY_ASCEND) comparison = newNode->LessThan(currNode, sortby); @@ -3646,7 +3646,7 @@ Expenses *Expenses::Insert(Expense *expense, Terminal *term, int sortby, Archive if (comparison) { - if (prevNode == nullptr) + if (prevNode == NULL) { // at the head retNode = newNode; newNode->next = currNode; @@ -3666,7 +3666,7 @@ Expenses *Expenses::Insert(Expense *expense, Terminal *term, int sortby, Archive } if (done == 0) { - if (prevNode == nullptr) + if (prevNode == NULL) { // at the head retNode = newNode; newNode->next = currNode; @@ -3783,7 +3783,7 @@ void Expenses::Print() FnTrace("Expenses::Print()"); Expenses *currNode = this; - while (currNode != nullptr) + while (currNode != NULL) { printf(" %d\n", currNode->amount); currNode = currNode->next; @@ -3800,7 +3800,7 @@ int System::ExpenseReport(Terminal *term, TimeInfo &start_time, TimeInfo &end_ti Archive *archive, Report *report, ReportZone *rzone) { FnTrace("System::ExpenseReport()"); - if (report == nullptr) + if (report == NULL) return 1; Expenses *expenselist = new Expenses; @@ -3824,10 +3824,10 @@ int System::ExpenseReport(Terminal *term, TimeInfo &start_time, TimeInfo &end_ti int total_expenses = 0; archive = FindByTime(start_time); - if (archive == nullptr) + if (archive == NULL) { // didn't find any archive; process today's expenses ExpenseDB *my_expense_db = &(term->system_data->expense_db); - expenselist = expenselist->ImportExpenseDB(my_expense_db, term, nullptr, sortby); + expenselist = expenselist->ImportExpenseDB(my_expense_db, term, NULL, sortby); incomplete = 1; } else @@ -3835,12 +3835,12 @@ int System::ExpenseReport(Terminal *term, TimeInfo &start_time, TimeInfo &end_ti Expense *expense; Archive *currArchive = archive; - while ((currArchive != nullptr) && (currArchive->end_time <= end_time)) + while ((currArchive != NULL) && (currArchive->end_time <= end_time)) { if (currArchive->loaded == 0) currArchive->LoadPacked(term->GetSettings()); expense = currArchive->expense_db.ExpenseList(); - while (expense != nullptr) + while (expense != NULL) { if (expense->exp_date >= start_time && expense->exp_date < end_time) { @@ -3850,7 +3850,7 @@ int System::ExpenseReport(Terminal *term, TimeInfo &start_time, TimeInfo &end_ti } currArchive = currArchive->next; } - if (currArchive == nullptr) + if (currArchive == NULL) incomplete = 1; } @@ -3865,7 +3865,7 @@ int System::ExpenseReport(Terminal *term, TimeInfo &start_time, TimeInfo &end_ti report->TextL(buffer, color); report->NewLine(2); - if (rzone != nullptr) + if (rzone != NULL) { column_spacing = rzone->ColumnSpacing(term, 5); width = rzone->Width(term); @@ -3894,7 +3894,7 @@ int System::ExpenseReport(Terminal *term, TimeInfo &start_time, TimeInfo &end_ti // now walk through the generated lists of expenses and create the report currExpense = expenselist; - while (currExpense != nullptr) + while (currExpense != NULL) { column = 0; report->TextPosL(column, term->TimeDate(currExpense->date, TD_DATE), color); @@ -3911,7 +3911,7 @@ int System::ExpenseReport(Terminal *term, TimeInfo &start_time, TimeInfo &end_ti report->TextPosL(column, currExpense->document, color); column = (column_spacing * 2) + 10; report->TextPosL(column, currExpense->explanation, color); - if (currExpense->next == nullptr) + if (currExpense->next == NULL) color = COLOR_DK_BLUE; report->UnderlinePosL(0, width - 1, color); report->NewLine(); @@ -3967,10 +3967,10 @@ class RoyaltyData { customers[idx] = 0; sales[idx] = 0; } - system = nullptr; - report = nullptr; - term = nullptr; - archive = nullptr; + system = NULL; + report = NULL; + term = NULL; + archive = NULL; maxdays = 0; incomplete = 0; total_sales = 0; @@ -4008,7 +4008,7 @@ class Vouchers Vouchers::Vouchers() { next = nullptr; - fore = nullptr; + fore = NULL; type = -1; id = -1; } @@ -4016,7 +4016,7 @@ Vouchers::Vouchers() Vouchers::Vouchers(int vtype, int vid) { next = nullptr; - fore = nullptr; + fore = NULL; type = vtype; id = vid; } @@ -4039,9 +4039,9 @@ int RoyaltyReportWorkFn(RoyaltyData *rdata) Archive *archive = rdata->archive; int day; int vouchers; - Check *currCheck = nullptr; - SubCheck *currSubcheck = nullptr; - CouponInfo *currCoupon = nullptr; + Check *currCheck = NULL; + SubCheck *currSubcheck = NULL; + CouponInfo *currCoupon = NULL; DList voucher_list; Vouchers *currVoucher; int guests_counted = 0; @@ -4063,7 +4063,7 @@ int RoyaltyReportWorkFn(RoyaltyData *rdata) currCoupon = rdata->settings->CouponList(); } - while (currCoupon != nullptr) + while (currCoupon != NULL) { if ((currCoupon->flags & TF_ROYALTY) || (strcmp(currCoupon->name.Value(), "Head Office") == 0)) @@ -4075,14 +4075,14 @@ int RoyaltyReportWorkFn(RoyaltyData *rdata) } // Check if there are no checks to process - if (currCheck == nullptr) + if (currCheck == NULL) { // No checks to process, mark as done and continue to archive processing rdata->done = 1; } else { - while (currCheck != nullptr) + while (currCheck != NULL) { if ((currCheck->IsTraining() == 0) && (currCheck->time_open >= rdata->start_time) && @@ -4090,12 +4090,12 @@ int RoyaltyReportWorkFn(RoyaltyData *rdata) { guests_counted = 0; currSubcheck = currCheck->SubList(); - while (currSubcheck != nullptr) + while (currSubcheck != NULL) { if (currSubcheck->settle_time.IsSet() && currSubcheck->settle_time > rdata->start_time && currSubcheck->settle_time < rdata->end_time && - (archive == nullptr || + (archive == NULL || (currSubcheck->settle_time >= archive->start_time && currSubcheck->settle_time <= archive->end_time))) { @@ -4122,7 +4122,7 @@ int RoyaltyReportWorkFn(RoyaltyData *rdata) rdata->total_sales += currSubcheck->total_sales; // now check vouchers currVoucher = voucher_list.Head(); - while (currVoucher != nullptr) + while (currVoucher != NULL) { vouchers = currSubcheck->TotalPayment(currVoucher->type, currVoucher->id); if (vouchers) @@ -4382,7 +4382,7 @@ int RoyaltyReportWorkFn(RoyaltyData *rdata) report->NewLine(); report->is_complete = 1; - term->Update(UPDATE_REPORT, nullptr); + term->Update(UPDATE_REPORT, NULL); delete rdata; return 1; // end of work fn @@ -4392,7 +4392,7 @@ int System::RoyaltyReport(Terminal *term, TimeInfo &start_time, TimeInfo &end_ti Archive *archive, Report *report, ReportZone *rzone) { FnTrace("System::RoyaltyReport()"); - if (report == nullptr) + if (report == NULL) return 1; RoyaltyData *rdata = new RoyaltyData(); @@ -4406,7 +4406,7 @@ int System::RoyaltyReport(Terminal *term, TimeInfo &start_time, TimeInfo &end_ti rdata->archive = FindByTime(start_time); if (report->destination == RP_DEST_PRINTER) rdata->zone_width = report->max_width; - else if (rzone != nullptr) + else if (rzone != NULL) rdata->zone_width = rzone->Width(term); else rdata->zone_width = 80; @@ -4417,7 +4417,7 @@ int System::RoyaltyReport(Terminal *term, TimeInfo &start_time, TimeInfo &end_ti } else { // two columns - if (rzone != nullptr && report->destination != RP_DEST_PRINTER) + if (rzone != NULL && report->destination != RP_DEST_PRINTER) rdata->column_width = rzone->ColumnSpacing(term, 2); else rdata->column_width = rdata->zone_width / 2; @@ -4484,13 +4484,13 @@ AuditingData::AuditingData() FnTrace("AuditingData::AuditingData()"); int idx = 0; - term = nullptr; - system = nullptr; - settings = nullptr; - report = nullptr; + term = NULL; + system = NULL; + settings = NULL; + report = NULL; start_time.Clear(); end_time.Clear(); - archive = nullptr; + archive = NULL; done = 0; total_payments = 0; @@ -4526,17 +4526,17 @@ int GatherAuditChecks(AuditingData *adata) FnTrace("GatherAuditChecks()"); Archive *archive = adata->archive; Settings *settings = adata->settings; - Check *check = nullptr; - SubCheck *subcheck = nullptr; - Order *order = nullptr; - Order *modifier = nullptr; - Payment *payment = nullptr; - DiscountInfo *discount = nullptr; - CouponInfo *coupon = nullptr; - CompInfo *comp = nullptr; - MealInfo *meal = nullptr; - CreditCardInfo *creditcard = nullptr; - const char* temp = nullptr; + Check *check = NULL; + SubCheck *subcheck = NULL; + Order *order = NULL; + Order *modifier = NULL; + Payment *payment = NULL; + DiscountInfo *discount = NULL; + CouponInfo *coupon = NULL; + CompInfo *comp = NULL; + MealInfo *meal = NULL; + CreditCardInfo *creditcard = NULL; + const char* temp = NULL; int guests_counted = 0; int is_dinein = 0; int sales = 0; // payment - taxes - tips - adjustments @@ -4553,7 +4553,7 @@ int GatherAuditChecks(AuditingData *adata) check = adata->system->CheckList(); } - while (check != nullptr) + while (check != NULL) { if (check->IsTraining() == 0) { @@ -4567,12 +4567,12 @@ int GatherAuditChecks(AuditingData *adata) { std::cout << "Check Voided: " << check->time_open.DebugPrint() - << '\n'; + << std::endl; } } subcheck = check->SubList(); - while (subcheck != nullptr) + while (subcheck != NULL) { if (subcheck->settle_time.IsSet() && subcheck->settle_time > adata->start_time && @@ -4619,13 +4619,13 @@ int GatherAuditChecks(AuditingData *adata) if (subcheck->IsTaxExempt() == 0) adata->total_taxes += subcheck->TotalTax(); order = subcheck->OrderList(); - while (order != nullptr) + while (order != NULL) { order->FigureCost(); adata->by_family[order->item_family] += order->cost; adata->total_item_sales += order->cost; modifier = order->modifier_list; - while (modifier != nullptr) + while (modifier != NULL) { adata->by_family[modifier->item_family] += modifier->cost; adata->total_item_sales += modifier->cost; @@ -4635,7 +4635,7 @@ int GatherAuditChecks(AuditingData *adata) } payment = subcheck->PaymentList(); - while (payment != nullptr) + while (payment != NULL) { switch (payment->tender_type) { @@ -4667,14 +4667,14 @@ int GatherAuditChecks(AuditingData *adata) creditcard = archive->FindCreditCardByID(payment->tender_id); else creditcard = settings->FindCreditCardByID(payment->tender_id); - if (creditcard != nullptr) + if (creditcard != NULL) adata->creditcards.Add(creditcard->name.Value(), payment->value); adata->total_payments += payment->amount; sales += payment->value; break; case TENDER_CREDIT_CARD: temp = FindStringByValue(payment->tender_id, CreditCardValue, CreditCardName); - if (temp != nullptr) + if (temp != NULL) { adata->creditcards.Add(temp, payment->value); adata->total_payments += payment->amount; @@ -4683,7 +4683,7 @@ int GatherAuditChecks(AuditingData *adata) break; case TENDER_DEBIT_CARD: temp = FindStringByValue(CARD_TYPE_DEBIT, CardTypeValue, CardTypeName); - if (temp != nullptr) + if (temp != NULL) { adata->creditcards.Add(temp, payment->value); adata->total_payments += payment->amount; @@ -4695,7 +4695,7 @@ int GatherAuditChecks(AuditingData *adata) coupon = archive->FindCouponByID(payment->tender_id); else coupon = settings->FindCouponByID(payment->tender_id); - if (coupon != nullptr) + if (coupon != NULL) adata->coupons.Add(coupon->name.Value(), payment->value); adata->total_adjusts += payment->value; break; @@ -4704,7 +4704,7 @@ int GatherAuditChecks(AuditingData *adata) discount = archive->FindDiscountByID(payment->tender_id); else discount = settings->FindDiscountByID(payment->tender_id); - if (discount != nullptr) + if (discount != NULL) adata->discounts.Add(discount->name.Value(), payment->value); adata->total_adjusts += payment->value; break; @@ -4713,7 +4713,7 @@ int GatherAuditChecks(AuditingData *adata) comp = archive->FindCompByID(payment->tender_id); else comp = settings->FindCompByID(payment->tender_id); - if (comp != nullptr) + if (comp != NULL) adata->comps.Add(comp->name.Value(), payment->value); adata->total_adjusts += payment->value; break; @@ -4722,7 +4722,7 @@ int GatherAuditChecks(AuditingData *adata) meal = archive->FindMealByID(payment->tender_id); else meal = settings->FindMealByID(payment->tender_id); - if (meal != nullptr) + if (meal != NULL) adata->meals.Add(meal->name.Value(), payment->value); adata->total_adjusts += payment->value; break; @@ -4908,7 +4908,7 @@ int AuditingReportWorkFn(AuditingData *adata) report->TextR(term->FormatPrice(adata->total_item_sales), color); report->NewLine(); idx = 0; - while (FamilyName[idx] != nullptr) + while (FamilyName[idx] != NULL) { family_idx = FamilyValue[idx]; if ((term->hide_zeros == 0) || (adata->by_family[family_idx] > 0)) @@ -4946,7 +4946,7 @@ int AuditingReportWorkFn(AuditingData *adata) } if ((term->hide_zeros == 0) || (total_creditcards > 0)) { - while (creditcard != nullptr) + while (creditcard != NULL) { if ((term->hide_zeros == 0) || (creditcard->total > 0)) { @@ -4996,7 +4996,7 @@ int AuditingReportWorkFn(AuditingData *adata) report->NewLine(); report->TextL(term->Translate("Breakdown of Coupons"), color); report->NewLine(); - while (coupon != nullptr) + while (coupon != NULL) { report->TextPosL(indent, term->Translate(coupon->name.c_str()), color); report->TextR(term->FormatPrice(coupon->total), color); @@ -5010,7 +5010,7 @@ int AuditingReportWorkFn(AuditingData *adata) report->NewLine(); report->TextL(term->Translate("Breakdown of Discounts"), color); report->NewLine(); - while (discount != nullptr) + while (discount != NULL) { report->TextPosL(indent, term->Translate(discount->name.c_str()), color); report->TextR(term->FormatPrice(discount->total), color); @@ -5024,7 +5024,7 @@ int AuditingReportWorkFn(AuditingData *adata) report->NewLine(); report->TextL(term->Translate("Breakdown of Comps"), color); report->NewLine(); - while (comp != nullptr) + while (comp != NULL) { report->TextPosL(indent, term->Translate(comp->name.c_str()), color); report->TextR(term->FormatPrice(comp->total), color); @@ -5038,7 +5038,7 @@ int AuditingReportWorkFn(AuditingData *adata) report->NewLine(); report->TextL(term->Translate("Breakdown of Employee Meals"), color); report->NewLine(); - while (meal != nullptr) + while (meal != NULL) { report->TextPosL(indent, term->Translate(meal->name.c_str()), color); report->TextR(term->FormatPrice(meal->total), color); @@ -5048,7 +5048,7 @@ int AuditingReportWorkFn(AuditingData *adata) } report->is_complete = 1; - term->Update(UPDATE_REPORT, nullptr); + term->Update(UPDATE_REPORT, NULL); delete adata; return 1; // end of work fn @@ -5058,7 +5058,7 @@ int System::AuditingReport(Terminal *term, TimeInfo &start_time, TimeInfo &end_t Archive *archive, Report *report, ReportZone *rzone) { FnTrace("System::AuditingReport()"); - if (report == nullptr) + if (report == NULL) return 1; AuditingData *adata = new AuditingData; @@ -5099,14 +5099,14 @@ class CCData CCData::CCData() { - term = nullptr; - system = nullptr; - settings = nullptr; - report = nullptr; + term = NULL; + system = NULL; + settings = NULL; + report = NULL; start_time.Clear(); end_time.Clear(); - archive = nullptr; - report_zone = nullptr; + archive = NULL; + report_zone = NULL; done = 0; } @@ -5115,7 +5115,7 @@ int GetCreditCardPayments(CCData *ccdata, Payment *payment) FnTrace("GetCreditCardPayments()"); int retval = 0; - while (payment != nullptr) + while (payment != NULL) { switch (payment->tender_type) { @@ -5140,8 +5140,8 @@ int CreditCardReportWorkFn(CCData *ccdata) Settings *settings = ccdata->settings; Terminal *term = ccdata->term; Archive *archive = ccdata->archive; - Check *check = nullptr; - SubCheck *subcheck = nullptr; + Check *check = NULL; + SubCheck *subcheck = NULL; ////// // Collect the data @@ -5160,12 +5160,12 @@ int CreditCardReportWorkFn(CCData *ccdata) check = ccdata->system->CheckList(); } - while (check != nullptr) + while (check != NULL) { if (check->IsTraining() == 0) { subcheck = check->SubList(); - while (subcheck != nullptr) + while (subcheck != NULL) { if (subcheck->settle_time.IsSet() && subcheck->settle_time > ccdata->start_time && @@ -5199,7 +5199,7 @@ int CreditCardReportWorkFn(CCData *ccdata) ////// report->is_complete = 1; - term->Update(UPDATE_REPORT, nullptr); + term->Update(UPDATE_REPORT, NULL); delete ccdata; return 1; @@ -5210,12 +5210,12 @@ int System::CreditCardReport(Terminal *term, TimeInfo &start_time, TimeInfo &end { FnTrace("System::CreditCardReport()"); int retval = 1; - CCData *ccdata = nullptr; + CCData *ccdata = NULL; int color = COLOR_DEFAULT; int date_format = TD_SHORT_MONTH | TD_NO_DAY; char str[STRLONG]; - if (report == nullptr) + if (report == NULL) return retval; ////// @@ -5338,9 +5338,9 @@ int System::CreditCardReport(Terminal *term, TimeInfo &start_time, TimeInfo &end } else if (cc_report_type == CC_REPORT_FINISH) { - if (cc_finish != nullptr) + if (cc_finish != NULL) { - if (rzone != nullptr) + if (rzone != NULL) rzone->Page(0); report->NewLine(); report->TextL(cc_finish->Code(), COLOR_DEFAULT); @@ -5357,11 +5357,11 @@ int System::CreditCardReport(Terminal *term, TimeInfo &start_time, TimeInfo &end /********************************************************************* * QuickBooksCSVExport: Generate CSV data for QuickBooks import ********************************************************************/ -int System::QuickBooksCSVExport(Terminal *term, const TimeInfo& start_time, const TimeInfo& end_time, +int System::QuickBooksCSVExport(Terminal *term, TimeInfo start_time, TimeInfo end_time, PrinterQuickBooksCSV *printer) { FnTrace("System::QuickBooksCSVExport()"); - if (printer == nullptr) + if (printer == NULL) return 1; printer->Start(); @@ -5389,7 +5389,7 @@ int System::QuickBooksCSVExport(Terminal *term, const TimeInfo& start_time, cons Archive *archive = FindByTime(start_time); for (;;) { - for (Check *check = FirstCheck(archive); check != nullptr; check = check->next) + for (Check *check = FirstCheck(archive); check != NULL; check = check->next) { if (check->IsTraining()) continue; @@ -5397,7 +5397,7 @@ int System::QuickBooksCSVExport(Terminal *term, const TimeInfo& start_time, cons TimeInfo *close_time = check->TimeClosed(); if (close_time && *close_time >= start_time && *close_time < end_time) { - for (SubCheck *subcheck = check->SubList(); subcheck != nullptr; subcheck = subcheck->next) + for (SubCheck *subcheck = check->SubList(); subcheck != NULL; subcheck = subcheck->next) { if (subcheck->status == CHECK_CLOSED) { @@ -5416,7 +5416,7 @@ int System::QuickBooksCSVExport(Terminal *term, const TimeInfo& start_time, cons } // Process payments - for (Payment *payment = subcheck->PaymentList(); payment != nullptr; payment = payment->next) + for (Payment *payment = subcheck->PaymentList(); payment != NULL; payment = payment->next) { switch (payment->tender_type) { @@ -5484,7 +5484,7 @@ int System::QuickBooksCSVExport(Terminal *term, const TimeInfo& start_time, cons } } - if (archive == nullptr || archive->end_time > end_time) + if (archive == NULL || archive->end_time > end_time) break; archive = archive->next; } diff --git a/main/ui/system_salesmix.cc b/main/ui/system_salesmix.cc index a7b67e87..c80ad0ac 100644 --- a/main/ui/system_salesmix.cc +++ b/main/ui/system_salesmix.cc @@ -89,9 +89,9 @@ class ItemCountTree int Add(ItemCount *ic) { - if (ic == nullptr) + if (ic == NULL) return 1; - else if (head == nullptr) + else if (head == NULL) { head = ic; return 0; @@ -185,7 +185,7 @@ int ItemCount::AddCount(Order *o) int ItemCountTree::AddToBranch(ItemCount *branch, ItemCount *ic) { FnTrace("ItemCountTree::AddToBranch()"); - if (branch == nullptr || ic == nullptr) + if (branch == NULL || ic == NULL) return 1; // NOTE - the nature of the data order should keep the tree sort of balanced @@ -224,7 +224,7 @@ int ItemCountTree::AddToBranch(ItemCount *branch, ItemCount *ic) int ItemCountTree::KillBranch(ItemCount *ic) { FnTrace("ItemCountTree::KillBranch()"); - if (ic == nullptr) + if (ic == NULL) return 1; if (ic->left) KillBranch(ic->left); @@ -238,8 +238,8 @@ ItemCount *ItemCountTree::SearchBranch(ItemCount *ic, const std::string &name, i int family) { FnTrace("ItemCountTree::SearchBranch()"); - if (ic == nullptr) - return nullptr; + if (ic == NULL) + return NULL; int compare = StringCompare(name, ic->name); if (compare < 0) @@ -274,7 +274,7 @@ int ItemCountTree::CountOrder(Order *o) FnTrace("ItemCountTree::CountOrder()"); Order *mod; - if (o == nullptr) + if (o == NULL) return 1; if ((o->qualifier & QUALIFIER_NO) || o->count == 0) return 0; @@ -292,7 +292,7 @@ int ItemCountTree::CountOrder(Order *o) if (ic) { mod = o->modifier_list; - while (mod != nullptr) + while (mod != NULL) { if (mod->total_cost > 0) ic->mods.AddCount(mod); @@ -306,10 +306,10 @@ int ItemCountTree::CountOrder(Order *o) int ItemCountTree::CountOrderNoFamily(Order *o) { FnTrace("ItemCountTree::CountOrderNoFamily()"); - Order *mod = nullptr; - ItemCount *ic = nullptr; + Order *mod = NULL; + ItemCount *ic = NULL; - if (o == nullptr) + if (o == NULL) return 1; if ((o->qualifier & QUALIFIER_NO) || o->count == 0) return 0; @@ -327,7 +327,7 @@ int ItemCountTree::CountOrderNoFamily(Order *o) if (ic) { mod = o->modifier_list; - while (mod != nullptr) + while (mod != NULL) { if (mod->cost > 0) ic->mods.AddCount(mod); @@ -339,8 +339,8 @@ int ItemCountTree::CountOrderNoFamily(Order *o) } -#define COUNT_POS (-11) -#define WEIGHT_POS (-17) +#define COUNT_POS -11 +#define WEIGHT_POS -17 /********************************************************************* * SalesMixReport Function @@ -500,17 +500,17 @@ int System::SalesMixReport(Terminal *t, const TimeInfo &start_time, const TimeIn Archive *a = FindByTime(start_time); for (;;) { - for (Check *c = FirstCheck(a); c != nullptr; c = c->next) + for (Check *c = FirstCheck(a); c != NULL; c = c->next) { if ((c->IsTraining() == 0) && (user_id == 0 || user_id == c->WhoGetsSale(s))) { - for (SubCheck *sc = c->SubList(); sc != nullptr; sc = sc->next) + for (SubCheck *sc = c->SubList(); sc != NULL; sc = sc->next) { if (sc->settle_time.IsSet() && sc->settle_time < end && sc->settle_time > start_time) { - for (Order *o = sc->OrderList(); o != nullptr; o = o->next) + for (Order *o = sc->OrderList(); o != NULL; o = o->next) { if (show_family) tree.CountOrder(o); @@ -522,7 +522,7 @@ int System::SalesMixReport(Terminal *t, const TimeInfo &start_time, const TimeIn } } - if (a == nullptr || a->end_time > end) + if (a == NULL || a->end_time > end) break; // kill loop a = a->next; } diff --git a/print/print_main.cc b/print/print_main.cc index b8e6e709..a1ed9261 100644 --- a/print/print_main.cc +++ b/print/print_main.cc @@ -84,22 +84,22 @@ int main(int argc, const char* argv[]) Parameter param = ParseArguments(argc, argv); if (param.verbose) { - std::cout << "Listening on port " << param.InetPortNumber << '\n'; - std::cout << "Writing to printer at " << param.PrinterDevName << '\n'; + std::cout << "Listening on port " << param.InetPortNumber << std::endl; + std::cout << "Writing to printer at " << param.PrinterDevName << std::endl; } // listen for connections my_socket = Listen(param.InetPortNumber); if (my_socket < 0) { - std::cerr << "Failed to create listening socket on port " << param.InetPortNumber << '\n'; + std::cerr << "Failed to create listening socket on port " << param.InetPortNumber << std::endl; return 1; } while (my_socket > -1 && !g_shutdown_requested) { if (param.verbose) - std::cout << "Waiting to accept connection..." << '\n'; + std::cout << "Waiting to accept connection..." << std::endl; connection = Accept(my_socket); if (connection > -1) { @@ -111,7 +111,7 @@ int main(int argc, const char* argv[]) { PrintFromRemote(connection, printer); if (param.verbose) - std::cout << "Closing Printer" << '\n'; + std::cout << "Closing Printer" << std::endl; close(printer); printer = -1; } @@ -125,7 +125,7 @@ int main(int argc, const char* argv[]) lock = -1; } if (param.verbose) - std::cout << "Closing socket" << '\n'; + std::cout << "Closing socket" << std::endl; close(connection); connection = -1; } @@ -138,7 +138,7 @@ int main(int argc, const char* argv[]) } if (param.verbose && g_shutdown_requested) { - std::cout << "Shutdown requested, exiting gracefully..." << '\n'; + std::cout << "Shutdown requested, exiting gracefully..." << std::endl; } return 0; @@ -173,7 +173,7 @@ int PrintFromRemote(const int my_socket, const int printer) else if (bytes_written != bytes_read) { std::cerr << "Warning: Partial write to printer (" << bytes_written - << " of " << bytes_read << " bytes)" << '\n'; + << " of " << bytes_read << " bytes)" << std::endl; } } else if (bytes_read == 0) @@ -195,16 +195,16 @@ int PrintFromRemote(const int my_socket, const int printer) ****/ void ShowHelp(const std::string &progname) { - std::cout << '\n' - << "Usage: " << progname << " [OPTIONS]" << '\n' - << " -d Printer device (default " << DEVPORT << ")" << '\n' - << " -h Show this help screen" << '\n' - << " -p Set the listening port (default " << default_port_number << ")" << '\n' - << " -v Verbose mode" << '\n' - << '\n' - << "Note: there can be no spaces between an option and the associated" << '\n' - << "argument. AKA, it's \"-p6555\" not \"-p 6555\"." << '\n' - << '\n'; + std::cout << std::endl + << "Usage: " << progname << " [OPTIONS]" << std::endl + << " -d Printer device (default " << DEVPORT << ")" << std::endl + << " -h Show this help screen" << std::endl + << " -p Set the listening port (default " << default_port_number << ")" << std::endl + << " -v Verbose mode" << std::endl + << std::endl + << "Note: there can be no spaces between an option and the associated" << std::endl + << "argument. AKA, it's \"-p6555\" not \"-p 6555\"." << std::endl + << std::endl; exit(1); } @@ -221,7 +221,7 @@ Parameter ParseArguments(const int argc, const char* const argv[]) const std::string arg = argv[idx]; if (arg.length() < 2) { - std::cout << "Invalid argument format: '" << arg << "'" << '\n'; + std::cout << "Invalid argument format: '" << arg << "'" << std::endl; ShowHelp(argv[0]); } @@ -233,7 +233,7 @@ Parameter ParseArguments(const int argc, const char* const argv[]) if (val.empty()) { std::cout << "Error parsing argument '" << arg << "'." - << " No printer specified" << '\n'; + << " No printer specified" << std::endl; ShowHelp(argv[0]); } param.PrinterDevName = val; @@ -247,7 +247,7 @@ Parameter ParseArguments(const int argc, const char* const argv[]) if (val.empty()) { std::cout << "Error parsing argument '" << arg << "'." - << " No port number specified" << '\n'; + << " No port number specified" << std::endl; ShowHelp(argv[0]); } std::istringstream ss(val); @@ -255,7 +255,7 @@ Parameter ParseArguments(const int argc, const char* const argv[]) if (ss.fail() || param.InetPortNumber <= 0 || param.InetPortNumber > 65535) { std::cout << "Invalid port number: " << val - << " (must be between 1 and 65535)" << '\n'; + << " (must be between 1 and 65535)" << std::endl; ShowHelp(argv[0]); } } @@ -265,7 +265,7 @@ Parameter ParseArguments(const int argc, const char* const argv[]) } else { - std::cout << "Unrecognized parameter '" << arg << "'" << '\n'; + std::cout << "Unrecognized parameter '" << arg << "'" << std::endl; ShowHelp(argv[0]); } } diff --git a/scripts/system/reverse-ssh-daemon.service b/scripts/system/reverse-ssh-daemon.service new file mode 100644 index 00000000..5e793bbc --- /dev/null +++ b/scripts/system/reverse-ssh-daemon.service @@ -0,0 +1,33 @@ +[Unit] +Description=ViewTouch Reverse SSH Tunnel Daemon +After=network.target +Wants=network.target + +[Service] +Type=simple +User=viewtouch +Group=viewtouch +ExecStart=/usr/viewtouch/bin/reverse_ssh_daemon +ExecReload=/bin/kill -HUP $MAINPID +Restart=always +RestartSec=10 +StandardOutput=journal +StandardError=journal +SyslogIdentifier=reverse-ssh-daemon + +# Security settings +NoNewPrivileges=yes +PrivateTmp=yes +ProtectHome=yes +ReadWritePaths=/var/log/viewtouch /var/run/viewtouch /usr/viewtouch/ssh +ProtectSystem=strict +ProtectKernelTunables=yes +ProtectKernelModules=yes +ProtectControlGroups=yes + +# Resource limits +LimitNOFILE=1024 +MemoryLimit=50M + +[Install] +WantedBy=multi-user.target diff --git a/scripts/tools/vt_reverse_ssh b/scripts/tools/vt_reverse_ssh new file mode 100755 index 00000000..d8cb1b2a --- /dev/null +++ b/scripts/tools/vt_reverse_ssh @@ -0,0 +1,304 @@ +#!/bin/bash +# +# ViewTouch Reverse SSH Tunnel Management Script +# + +SCRIPT_NAME=$(basename "$0") +PID_FILE="/var/run/viewtouch/reverse_ssh_daemon.pid" +CONFIG_FILE="/etc/viewtouch/reverse_ssh.conf" +DAEMON_BINARY="/usr/viewtouch/bin/reverse_ssh_daemon" +SERVICE_NAME="reverse-ssh-daemon" + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# Logging functions +log_info() { + echo -e "${BLUE}[INFO]${NC} $1" +} + +log_success() { + echo -e "${GREEN}[SUCCESS]${NC} $1" +} + +log_warning() { + echo -e "${YELLOW}[WARNING]${NC} $1" +} + +log_error() { + echo -e "${RED}[ERROR]${NC} $1" +} + +# Check if running as root +check_root() { + if [ "$EUID" -ne 0 ]; then + log_error "This script must be run as root" + exit 1 + fi +} + +# Check if daemon is running +is_running() { + if [ -f "$PID_FILE" ]; then + PID=$(cat "$PID_FILE") + if kill -0 "$PID" 2>/dev/null; then + return 0 + else + log_warning "PID file exists but process is not running. Cleaning up." + rm -f "$PID_FILE" + fi + fi + return 1 +} + +# Get daemon status +get_status() { + if is_running; then + PID=$(cat "$PID_FILE") + log_success "Reverse SSH daemon is running (PID: $PID)" + + # Try to get tunnel information + if command -v ssh >/dev/null 2>&1; then + # Check if we can get tunnel info via SSH + TUNNEL_INFO=$(ssh -o ConnectTimeout=5 -o BatchMode=yes \ + $(grep remote_user "$CONFIG_FILE" | cut -d'=' -f2)@$(grep management_server "$CONFIG_FILE" | cut -d'=' -f2) \ + "netstat -tlnp 2>/dev/null | grep :$(grep remote_port "$CONFIG_FILE" | cut -d'=' -f2) || echo 'No active tunnel found'" 2>/dev/null) + if [ -n "$TUNNEL_INFO" ]; then + log_info "Tunnel status: $TUNNEL_INFO" + fi + fi + else + log_info "Reverse SSH daemon is not running" + fi +} + +# Start the daemon +start_daemon() { + if is_running; then + log_warning "Reverse SSH daemon is already running" + return 1 + fi + + if [ ! -f "$CONFIG_FILE" ]; then + log_error "Configuration file not found: $CONFIG_FILE" + log_info "The configuration file should be installed at $CONFIG_FILE during ViewTouch installation" + log_info "You may need to create it manually: cp /usr/share/viewtouch/config/reverse_ssh_daemon.conf $CONFIG_FILE" + exit 1 + fi + + log_info "Starting reverse SSH daemon..." + if [ -x "$DAEMON_BINARY" ]; then + "$DAEMON_BINARY" -c "$CONFIG_FILE" + sleep 2 + if is_running; then + log_success "Reverse SSH daemon started successfully" + return 0 + else + log_error "Failed to start reverse SSH daemon" + return 1 + fi + else + log_error "Daemon binary not found: $DAEMON_BINARY" + return 1 + fi +} + +# Stop the daemon +stop_daemon() { + if ! is_running; then + log_warning "Reverse SSH daemon is not running" + return 1 + fi + + PID=$(cat "$PID_FILE") + log_info "Stopping reverse SSH daemon (PID: $PID)..." + + # Try graceful shutdown first + kill -TERM "$PID" 2>/dev/null + for i in {1..10}; do + if ! kill -0 "$PID" 2>/dev/null; then + break + fi + sleep 1 + done + + # Force kill if still running + if kill -0 "$PID" 2>/dev/null; then + log_warning "Daemon didn't respond to SIGTERM, sending SIGKILL..." + kill -KILL "$PID" 2>/dev/null + sleep 1 + fi + + if ! kill -0 "$PID" 2>/dev/null; then + rm -f "$PID_FILE" + log_success "Reverse SSH daemon stopped successfully" + return 0 + else + log_error "Failed to stop reverse SSH daemon" + return 1 + fi +} + +# Restart the daemon +restart_daemon() { + log_info "Restarting reverse SSH daemon..." + stop_daemon + sleep 2 + start_daemon +} + +# Generate SSH key +generate_key() { + KEY_PATH=$(grep ssh_key_path "$CONFIG_FILE" 2>/dev/null | cut -d'=' -f2) + if [ -z "$KEY_PATH" ]; then + KEY_PATH="/usr/viewtouch/ssh/reverse_ssh_key" + fi + + KEY_DIR=$(dirname "$KEY_PATH") + mkdir -p "$KEY_DIR" + chmod 700 "$KEY_DIR" + + if [ -f "$KEY_PATH" ]; then + log_warning "SSH key already exists at $KEY_PATH" + read -p "Overwrite existing key? (y/N): " -n 1 -r + echo + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + log_info "Key generation cancelled" + return 1 + fi + fi + + log_info "Generating SSH key at $KEY_PATH..." + ssh-keygen -t ed25519 -f "$KEY_PATH" -N '' -C "viewtouch-reverse-ssh-$(hostname)" 2>/dev/null + + if [ $? -eq 0 ]; then + chmod 600 "$KEY_PATH" + chmod 644 "${KEY_PATH}.pub" + log_success "SSH key generated successfully" + log_info "Public key (${KEY_PATH}.pub):" + cat "${KEY_PATH}.pub" + log_info "" + log_info "Please add the above public key to the authorized_keys file on your management server" + return 0 + else + log_error "Failed to generate SSH key" + return 1 + fi +} + +# Test connection +test_connection() { + if [ ! -f "$CONFIG_FILE" ]; then + log_error "Configuration file not found: $CONFIG_FILE" + exit 1 + fi + + SERVER=$(grep management_server "$CONFIG_FILE" | cut -d'=' -f2) + PORT=$(grep management_port "$CONFIG_FILE" | cut -d'=' -f2) + USER=$(grep remote_user "$CONFIG_FILE" | cut -d'=' -f2) + KEY_PATH=$(grep ssh_key_path "$CONFIG_FILE" | cut -d'=' -f2) + + log_info "Testing SSH connection to $USER@$SERVER:$PORT..." + + if [ -f "$KEY_PATH" ]; then + ssh -o ConnectTimeout=10 -o BatchMode=yes -i "$KEY_PATH" \ + -p "$PORT" "$USER@$SERVER" 'echo "SSH connection successful"' 2>/dev/null + + if [ $? -eq 0 ]; then + log_success "SSH connection test successful" + return 0 + else + log_error "SSH connection test failed" + return 1 + fi + else + log_error "SSH key not found: $KEY_PATH" + log_info "Run '$SCRIPT_NAME generate-key' to create an SSH key" + return 1 + fi +} + +# Show configuration +show_config() { + if [ -f "$CONFIG_FILE" ]; then + log_info "Current configuration ($CONFIG_FILE):" + echo "----------------------------------------" + cat "$CONFIG_FILE" + echo "----------------------------------------" + else + log_error "Configuration file not found: $CONFIG_FILE" + log_info "The configuration file should be installed automatically during ViewTouch installation" + fi +} + +# Show usage +show_usage() { + echo "ViewTouch Reverse SSH Tunnel Management Script" + echo "" + echo "Usage: $SCRIPT_NAME [COMMAND]" + echo "" + echo "Commands:" + echo " start Start the reverse SSH daemon" + echo " stop Stop the reverse SSH daemon" + echo " restart Restart the reverse SSH daemon" + echo " status Show daemon status and tunnel information" + echo " generate-key Generate SSH key pair for authentication" + echo " test Test SSH connection to management server" + echo " config Show current configuration" + echo " help Show this help message" + echo "" + echo "Configuration file: $CONFIG_FILE (installed automatically with ViewTouch)" + echo "PID file: $PID_FILE" + echo "" + echo "Examples:" + echo " $SCRIPT_NAME start" + echo " $SCRIPT_NAME generate-key" + echo " $SCRIPT_NAME test" + echo " $SCRIPT_NAME status" +} + +# Main function +main() { + case "${1:-help}" in + start) + check_root + start_daemon + ;; + stop) + check_root + stop_daemon + ;; + restart) + check_root + restart_daemon + ;; + status) + get_status + ;; + generate-key) + check_root + generate_key + ;; + test) + test_connection + ;; + config) + show_config + ;; + help|--help|-h) + show_usage + ;; + *) + log_error "Unknown command: $1" + echo "" + show_usage + exit 1 + ;; + esac +} + +main "$@" diff --git a/scripts/tools/vt_reverse_ssh_setup b/scripts/tools/vt_reverse_ssh_setup new file mode 100755 index 00000000..f3f13cb2 --- /dev/null +++ b/scripts/tools/vt_reverse_ssh_setup @@ -0,0 +1,389 @@ +#!/bin/bash +# +# ViewTouch Reverse SSH Setup Helper +# Helps users set up reverse tunnels without dedicated servers +# + +SCRIPT_NAME=$(basename "$0") + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# Logging functions +log_info() { + echo -e "${BLUE}[INFO]${NC} $1" +} + +log_success() { + echo -e "${GREEN}[SUCCESS]${NC} $1" +} + +log_warning() { + echo -e "${YELLOW}[WARNING]${NC} $1" +} + +log_error() { + echo -e "${RED}[ERROR]${NC} $1" +} + +# Check if running as root +check_root() { + if [ "$EUID" -ne 0 ]; then + log_error "This script must be run as root for some operations" + log_info "Run with: sudo $0" + exit 1 + fi +} + +# Setup ngrok tunnel +setup_ngrok() { + local location_name="$1" + + if [ -z "$location_name" ]; then + log_info "Setting up Ngrok tunnel..." + log_info "For multiple locations, specify a location name:" + log_info " $SCRIPT_NAME ngrok location_name" + location_name="default" + else + log_info "Setting up Ngrok tunnel for location: $location_name" + fi + + # Check if ngrok is installed + if ! command -v ngrok >/dev/null 2>&1; then + log_info "Ngrok not found. Installing..." + + # Download ngrok + wget -q https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-amd64.tgz -O /tmp/ngrok.tgz + if [ $? -ne 0 ]; then + log_error "Failed to download ngrok" + return 1 + fi + + # Extract ngrok + tar -xzf /tmp/ngrok.tgz -C /usr/local/bin/ + if [ $? -ne 0 ]; then + log_error "Failed to extract ngrok" + return 1 + fi + + log_success "Ngrok installed successfully" + fi + + # Start ngrok tunnel in background + log_info "Starting ngrok tunnel for SSH (port 22)..." + nohup ngrok tcp 22 > "/var/log/ngrok_$location_name.log" 2>&1 & + NGROK_PID=$! + + # Wait a moment for ngrok to start + sleep 3 + + # Get ngrok tunnel info + TUNNEL_INFO=$(curl -s http://localhost:4040/api/tunnels 2>/dev/null | grep -o '"public_url":"tcp://[^"]*"' | cut -d'"' -f4) + + if [ -n "$TUNNEL_INFO" ]; then + # Parse the tunnel URL + TUNNEL_HOST=$(echo $TUNNEL_INFO | cut -d':' -f2 | sed 's|//||') + TUNNEL_PORT=$(echo $TUNNEL_INFO | cut -d':' -f3) + + log_success "Ngrok tunnel established for $location_name!" + log_info "Tunnel: $TUNNEL_INFO" + log_info "Host: $TUNNEL_HOST" + log_info "Port: $TUNNEL_PORT" + + # Configure ViewTouch for this location + configure_viewtouch_for_location "$TUNNEL_HOST" "$TUNNEL_PORT" "$location_name" + + # Save tunnel info + echo "$TUNNEL_INFO" > "/var/run/ngrok_tunnel_$location_name.info" + echo "$NGROK_PID" > "/var/run/ngrok_$location_name.pid" + + log_success "Ngrok setup complete for $location_name!" + log_warning "Keep this terminal open to maintain the tunnel" + log_info "To connect back: ssh -p $TUNNEL_PORT $USER@$TUNNEL_HOST" + + return 0 + else + log_error "Failed to get tunnel information from ngrok" + kill $NGROK_PID 2>/dev/null + return 1 + fi +} + +# Setup serveo tunnel +setup_serveo() { + log_info "Setting up Serveo tunnel..." + + # Check SSH connection to serveo + log_info "Testing connection to serveo.net..." + if ! ssh -o ConnectTimeout=10 -o BatchMode=yes serveo.net "echo 'Serveo connection test'" >/dev/null 2>&1; then + log_error "Cannot connect to serveo.net. Check internet connection." + return 1 + fi + + log_info "Starting Serveo tunnel for SSH (port 22)..." + log_warning "This will run in the foreground. Press Ctrl+C to stop." + + # Start serveo tunnel + ssh -R 80:localhost:22 serveo.net + + # Note: This runs in foreground, so user needs to keep it running + # The actual tunnel URL will be displayed by serveo +} + +# Configure ViewTouch with tunnel information (legacy single location) +configure_viewtouch() { + local tunnel_host="$1" + local tunnel_port="$2" + + configure_viewtouch_for_location "$tunnel_host" "$tunnel_port" "default" +} + +# Configure ViewTouch for specific location +configure_viewtouch_for_location() { + local tunnel_host="$1" + local tunnel_port="$2" + local location_name="$3" + + CONFIG_FILE="/etc/viewtouch/reverse_ssh.conf" + + if [ ! -f "$CONFIG_FILE" ]; then + log_error "ViewTouch config file not found: $CONFIG_FILE" + return 1 + fi + + # Create location-specific config if needed + if [ "$location_name" != "default" ]; then + CONFIG_FILE="/etc/viewtouch/reverse_ssh_$location_name.conf" + log_info "Creating location-specific config: $CONFIG_FILE" + + # Copy base config + cp "/etc/viewtouch/reverse_ssh.conf" "$CONFIG_FILE" + + # Update location-specific settings + echo "# Location: $location_name" >> "$CONFIG_FILE" + fi + + log_info "Configuring ViewTouch for tunnel (location: $location_name)..." + + # Update config file + sed -i "s|^management_server=.*|management_server=$tunnel_host|" "$CONFIG_FILE" + sed -i "s|^management_port=.*|management_port=$tunnel_port|" "$CONFIG_FILE" + sed -i "s|^remote_user=.*|remote_user=$USER|" "$CONFIG_FILE" + + # Add location identifier + if ! grep -q "^location=" "$CONFIG_FILE"; then + echo "location=$location_name" >> "$CONFIG_FILE" + else + sed -i "s|^location=.*|location=$location_name|" "$CONFIG_FILE" + fi + + log_success "ViewTouch configured for tunnel (location: $location_name)" + log_info "Config updated: $CONFIG_FILE" +} + +# Setup personal computer as management server +setup_personal_server() { + log_info "Setting up your computer as management server..." + + # Check if SSH server is running + if ! systemctl is-active --quiet sshd 2>/dev/null && ! systemctl is-active --quiet ssh 2>/dev/null; then + log_info "SSH server not running. Installing and starting..." + + # Try to install SSH server + if command -v apt >/dev/null 2>&1; then + apt update && apt install -y openssh-server + elif command -v dnf >/dev/null 2>&1; then + dnf install -y openssh-server + elif command -v pacman >/dev/null 2>&1; then + pacman -S --noconfirm openssh + else + log_error "Cannot determine package manager. Please install openssh-server manually." + return 1 + fi + + # Start SSH service + systemctl start sshd 2>/dev/null || systemctl start ssh 2>/dev/null + systemctl enable sshd 2>/dev/null || systemctl enable ssh 2>/dev/null + fi + + # Get public IP + PUBLIC_IP=$(curl -s ifconfig.me 2>/dev/null || curl -s icanhazip.com 2>/dev/null) + + if [ -z "$PUBLIC_IP" ]; then + log_warning "Could not determine public IP automatically" + log_info "Please find your public IP manually and use it below" + read -p "Enter your public IP address: " PUBLIC_IP + fi + + log_info "Your public IP appears to be: $PUBLIC_IP" + log_warning "Make sure port 22 is accessible from the internet!" + log_warning "You may need to configure port forwarding in your router." + + # Configure ViewTouch + configure_viewtouch "$PUBLIC_IP" "22" + + log_success "Personal server setup complete!" + log_info "To connect back: ssh -p 2222 localhost (from this computer)" +} + +# Show tunnel status +show_status() { + log_info "Tunnel Status:" + + # Check all ngrok tunnels + NGROK_FOUND=0 + for pid_file in /var/run/ngrok*.pid; do + if [ -f "$pid_file" ]; then + location_name=$(basename "$pid_file" | sed 's/ngrok_\(.*\)\.pid/\1/') + if [ "$location_name" = "ngrok*.pid" ]; then + location_name="default" + fi + + pid=$(cat "$pid_file") + if kill -0 $pid 2>/dev/null; then + NGROK_FOUND=1 + info_file="/var/run/ngrok_tunnel_${location_name}.info" + if [ -f "$info_file" ]; then + TUNNEL=$(cat "$info_file") + log_success "Ngrok tunnel active for $location_name: $TUNNEL" + else + log_success "Ngrok tunnel running for $location_name (PID: $pid)" + fi + fi + fi + done + + if [ $NGROK_FOUND -eq 0 ]; then + log_info "No active ngrok tunnels found" + fi + + # Check ViewTouch reverse SSH + if command -v vt_reverse_ssh >/dev/null 2>&1; then + echo "" + log_info "ViewTouch Reverse SSH Status:" + vt_reverse_ssh status 2>/dev/null || log_warning "ViewTouch reverse SSH not configured" + fi +} + +# Stop tunnels +stop_tunnels() { + local location_name="$1" + + log_info "Stopping tunnels..." + + if [ -n "$location_name" ]; then + # Stop specific location + pid_file="/var/run/ngrok_${location_name}.pid" + info_file="/var/run/ngrok_tunnel_${location_name}.info" + + if [ -f "$pid_file" ]; then + NGROK_PID=$(cat "$pid_file") + if kill -0 $NGROK_PID 2>/dev/null; then + kill $NGROK_PID + log_success "Ngrok tunnel stopped for $location_name" + fi + rm -f "$pid_file" "$info_file" + else + log_warning "No tunnel found for location: $location_name" + fi + else + # Stop all tunnels + TUNNELS_STOPPED=0 + for pid_file in /var/run/ngrok*.pid; do + if [ -f "$pid_file" ]; then + location_name=$(basename "$pid_file" | sed 's/ngrok_\(.*\)\.pid/\1/') + if [ "$location_name" = "ngrok*.pid" ]; then + location_name="default" + fi + + pid=$(cat "$pid_file") + if kill -0 $pid 2>/dev/null; then + kill $pid + TUNNELS_STOPPED=$((TUNNELS_STOPPED + 1)) + log_success "Ngrok tunnel stopped for $location_name" + fi + + # Clean up files + info_file="/var/run/ngrok_tunnel_${location_name}.info" + rm -f "$pid_file" "$info_file" + fi + done + + if [ $TUNNELS_STOPPED -eq 0 ]; then + log_info "No active tunnels to stop" + fi + fi + + log_success "Tunnel cleanup complete" +} + +# Show usage +show_usage() { + echo "ViewTouch Reverse SSH Setup Helper" + echo "" + echo "This tool helps you set up reverse SSH tunnels for ViewTouch" + echo "when you don't have a dedicated management server." + echo "" + echo "Supports multiple locations - each location gets its own tunnel." + echo "" + echo "Usage: $SCRIPT_NAME [COMMAND] [LOCATION_NAME]" + echo "" + echo "Commands:" + echo " ngrok [location] Set up ngrok tunnel (recommended for beginners)" + echo " serveo [location] Set up Serveo tunnel (SSH-based, free)" + echo " personal [location] Set up your computer as management server" + echo " status Show current tunnel status for all locations" + echo " stop [location] Stop tunnels (all or specific location)" + echo " help Show this help message" + echo "" + echo "Examples:" + echo " $SCRIPT_NAME ngrok # Single location setup" + echo " $SCRIPT_NAME ngrok downtown # Setup for 'downtown' location" + echo " $SCRIPT_NAME ngrok mall # Setup for 'mall' location" + echo " $SCRIPT_NAME personal main_street # Personal server for 'main_street'" + echo " $SCRIPT_NAME status # Check all tunnel status" + echo " $SCRIPT_NAME stop downtown # Stop 'downtown' tunnel only" + echo " $SCRIPT_NAME stop # Stop all tunnels" + echo "" + echo "Requirements:" + echo " - Internet connection" + echo " - ViewTouch installed and configured" + echo " - For personal server: Port 22 accessible from internet" +} + +# Main function +main() { + case "${1:-help}" in + ngrok) + setup_ngrok "$2" + ;; + serveo) + setup_serveo "$2" + ;; + personal) + check_root + setup_personal_server "$2" + ;; + status) + show_status + ;; + stop) + stop_tunnels "$2" + ;; + help|--help|-h) + show_usage + ;; + *) + log_error "Unknown command: $1" + echo "" + show_usage + exit 1 + ;; + esac +} + +main "$@" diff --git a/scripts/tools/vt_ssh_security b/scripts/tools/vt_ssh_security new file mode 100755 index 00000000..66992d81 --- /dev/null +++ b/scripts/tools/vt_ssh_security @@ -0,0 +1,464 @@ +#!/bin/bash +# +# ViewTouch SSH Security Management Script +# + +SCRIPT_NAME=$(basename "$0") + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# Logging functions +log_info() { + echo -e "${BLUE}[INFO]${NC} $1" +} + +log_success() { + echo -e "${GREEN}[SUCCESS]${NC} $1" +} + +log_warning() { + echo -e "${YELLOW}[WARNING]${NC} $1" +} + +log_error() { + echo -e "${RED}[ERROR]${NC} $1" +} + +# Check if running as root +check_root() { + if [ "$EUID" -ne 0 ]; then + log_error "This script must be run as root" + exit 1 + fi +} + +# Validate SSH key +validate_key() { + local key_path="$1" + + if [ ! -f "$key_path" ]; then + log_error "SSH key not found: $key_path" + return 1 + fi + + # Check file permissions + local perms=$(stat -c '%a' "$key_path") + if [ "$perms" != "600" ]; then + log_warning "SSH private key has incorrect permissions: $perms (should be 600)" + return 1 + fi + + # Check if it's a valid SSH key + if ! ssh-keygen -l -f "$key_path" >/dev/null 2>&1; then + log_error "Invalid SSH key format: $key_path" + return 1 + fi + + log_success "SSH key validation passed: $key_path" + return 0 +} + +# Rotate SSH key +rotate_key() { + local key_path="$1" + local backup_dir="/usr/viewtouch/ssh/backups" + + if [ ! -f "$key_path" ]; then + log_error "SSH key not found: $key_path" + return 1 + fi + + # Create backup directory + mkdir -p "$backup_dir" + + # Create backup with timestamp + local timestamp=$(date +%Y%m%d_%H%M%S) + local backup_key="$backup_dir/$(basename "$key_path").$timestamp" + local backup_pub="$backup_dir/$(basename "$key_path").$timestamp.pub" + + cp "$key_path" "$backup_key" + cp "${key_path}.pub" "$backup_pub" + + log_info "Backed up existing key to: $backup_key" + + # Generate new key + local key_comment="viewtouch-reverse-ssh-$(hostname)-$timestamp" + ssh-keygen -t ed25519 -f "$key_path" -N '' -C "$key_comment" 2>/dev/null + + if [ $? -eq 0 ]; then + chmod 600 "$key_path" + chmod 644 "${key_path}.pub" + log_success "SSH key rotated successfully" + log_info "New public key (${key_path}.pub):" + cat "${key_path}.pub" + log_info "" + log_warning "IMPORTANT: Update the authorized_keys file on your management server with the new public key" + return 0 + else + log_error "Failed to rotate SSH key" + return 1 + fi +} + +# Check SSH server security +check_ssh_security() { + local sshd_config="/etc/ssh/sshd_config" + + log_info "Checking SSH server security configuration..." + + # Check if file exists + if [ ! -f "$sshd_config" ]; then + log_error "SSH server config not found: $sshd_config" + return 1 + fi + + local issues_found=0 + + # Check password authentication + if grep -q "^PasswordAuthentication yes" "$sshd_config" 2>/dev/null; then + log_warning "Password authentication is enabled - consider disabling for key-only authentication" + issues_found=$((issues_found + 1)) + fi + + # Check root login + if grep -q "^PermitRootLogin yes" "$sshd_config" 2>/dev/null; then + log_warning "Root login is permitted - consider restricting to specific users" + issues_found=$((issues_found + 1)) + fi + + # Check port (avoid default port 22) + local ssh_port=$(grep "^Port " "$sshd_config" 2>/dev/null | awk '{print $2}') + if [ "$ssh_port" = "22" ] || [ -z "$ssh_port" ]; then + log_warning "SSH server is using default port 22 - consider changing to a non-standard port" + issues_found=$((issues_found + 1)) + fi + + # Check MaxAuthTries + local max_auth=$(grep "^MaxAuthTries " "$sshd_config" 2>/dev/null | awk '{print $2}') + if [ -z "$max_auth" ] || [ "$max_auth" -gt 3 ]; then + log_warning "MaxAuthTries is not set or too high - consider setting to 3 or lower" + issues_found=$((issues_found + 1)) + fi + + # Check PermitEmptyPasswords + if grep -q "^PermitEmptyPasswords yes" "$sshd_config" 2>/dev/null; then + log_error "Empty passwords are permitted - this is a security risk" + issues_found=$((issues_found + 1)) + fi + + if [ $issues_found -eq 0 ]; then + log_success "SSH server security check passed" + else + log_warning "Found $issues_found security issues in SSH configuration" + fi + + return $issues_found +} + +# Harden SSH configuration +harden_ssh_config() { + local sshd_config="/etc/ssh/sshd_config" + local backup_config="$sshd_config.backup.$(date +%Y%m%d_%H%M%S)" + + log_info "Hardening SSH server configuration..." + + # Create backup + cp "$sshd_config" "$backup_config" + log_info "Backup created: $backup_config" + + # Apply security settings + cat >> "$sshd_config" << 'EOF' + +# ViewTouch SSH Security Hardening +# Added by vt_ssh_security script + +# Disable password authentication +PasswordAuthentication no + +# Disable root login +PermitRootLogin no + +# Limit authentication attempts +MaxAuthTries 3 + +# Disable empty passwords +PermitEmptyPasswords no + +# Enable public key authentication +PubkeyAuthentication yes + +# Enable tunneling +PermitTunnel yes +GatewayPorts yes + +# Disable X11 forwarding for security +X11Forwarding no + +# Set login grace time +LoginGraceTime 30 + +# Enable reverse DNS lookup (helps with logging) +UseDNS yes + +# Log more information +LogLevel VERBOSE + +EOF + + log_success "SSH configuration hardened" + log_warning "Please review the changes in $sshd_config and restart SSH service:" + log_warning " sudo systemctl restart ssh" +} + +# Generate SSH configuration for management server +generate_mgmt_config() { + local mgmt_config="/etc/ssh/ssh_config.d/viewtouch_management" + + log_info "Generating SSH client configuration for management server..." + + cat > "$mgmt_config" << 'EOF' +# ViewTouch Management Server SSH Configuration +# Generated by vt_ssh_security script + +Host management.viewtouch.com + # Security settings + PasswordAuthentication no + PubkeyAuthentication yes + IdentitiesOnly yes + + # Connection settings + ConnectTimeout 30 + ServerAliveInterval 60 + ServerAliveCountMax 3 + + # Disable potentially dangerous features + ForwardX11 no + ForwardAgent no + + # Strict host key checking for management servers + StrictHostKeyChecking yes + UserKnownHostsFile ~/.ssh/known_hosts + + # Compression for better performance + Compression yes + +EOF + + chmod 644 "$mgmt_config" + log_success "Management server SSH config created: $mgmt_config" +} + +# Check file permissions for SSH directory +check_permissions() { + local ssh_dir="/usr/viewtouch/ssh" + local issues_found=0 + + log_info "Checking SSH file permissions..." + + # Check SSH directory + if [ -d "$ssh_dir" ]; then + local dir_perms=$(stat -c '%a' "$ssh_dir") + if [ "$dir_perms" != "700" ]; then + log_warning "SSH directory has incorrect permissions: $dir_perms (should be 700)" + issues_found=$((issues_found + 1)) + fi + + local dir_owner=$(stat -c '%U:%G' "$ssh_dir") + if [ "$dir_owner" != "root:root" ]; then + log_warning "SSH directory has incorrect ownership: $dir_owner (should be root:root)" + issues_found=$((issues_found + 1)) + fi + else + log_warning "SSH directory does not exist: $ssh_dir" + fi + + # Check SSH keys + for key_file in "$ssh_dir"/*; do + if [ -f "$key_file" ] && [[ "$key_file" == *.key || "$key_file" == *id_* ]]; then + if [[ "$key_file" != *.pub ]]; then + # Private key + local key_perms=$(stat -c '%a' "$key_file") + if [ "$key_perms" != "600" ]; then + log_warning "SSH private key has incorrect permissions: $key_file ($key_perms should be 600)" + issues_found=$((issues_found + 1)) + fi + else + # Public key + local key_perms=$(stat -c '%a' "$key_file") + if [ "$key_perms" != "644" ]; then + log_warning "SSH public key has incorrect permissions: $key_file ($key_perms should be 644)" + issues_found=$((issues_found + 1)) + fi + fi + fi + done + + if [ $issues_found -eq 0 ]; then + log_success "SSH file permissions check passed" + else + log_warning "Found $issues_found permission issues" + fi + + return $issues_found +} + +# Fix file permissions +fix_permissions() { + local ssh_dir="/usr/viewtouch/ssh" + + log_info "Fixing SSH file permissions..." + + # Create SSH directory if it doesn't exist + if [ ! -d "$ssh_dir" ]; then + mkdir -p "$ssh_dir" + log_info "Created SSH directory: $ssh_dir" + fi + + # Set directory permissions + chmod 700 "$ssh_dir" + chown root:root "$ssh_dir" + log_info "Fixed SSH directory permissions" + + # Fix key permissions + for key_file in "$ssh_dir"/*; do + if [ -f "$key_file" ]; then + if [[ "$key_file" != *.pub ]]; then + # Private key + chmod 600 "$key_file" + chown root:root "$key_file" + else + # Public key + chmod 644 "$key_file" + chown root:root "$key_file" + fi + fi + done + + log_success "SSH file permissions fixed" +} + +# Show usage +show_usage() { + echo "ViewTouch SSH Security Management Script" + echo "" + echo "Usage: $SCRIPT_NAME [COMMAND] [OPTIONS]" + echo "" + echo "Commands:" + echo " validate-key [key_path] Validate SSH key file" + echo " rotate-key [key_path] Rotate SSH key pair with backup" + echo " check-ssh Check SSH server security configuration" + echo " harden-ssh Harden SSH server configuration" + echo " gen-mgmt-config Generate SSH client config for management servers" + echo " check-perms Check SSH file permissions" + echo " fix-perms Fix SSH file permissions" + echo " audit Run full security audit" + echo " help Show this help message" + echo "" + echo "Examples:" + echo " $SCRIPT_NAME validate-key /usr/viewtouch/ssh/reverse_ssh_key" + echo " $SCRIPT_NAME rotate-key /usr/viewtouch/ssh/reverse_ssh_key" + echo " $SCRIPT_NAME audit" +} + +# Run full security audit +run_audit() { + log_info "Running full SSH security audit..." + echo "========================================" + + local total_issues=0 + + echo "" + log_info "Checking SSH file permissions..." + if ! check_permissions; then + total_issues=$((total_issues + 1)) + fi + + echo "" + log_info "Checking SSH server security..." + if ! check_ssh_security; then + total_issues=$((total_issues + 1)) + fi + + echo "" + log_info "Checking SSH keys..." + local key_path="/usr/viewtouch/ssh/reverse_ssh_key" + if [ -f "$key_path" ]; then + if ! validate_key "$key_path"; then + total_issues=$((total_issues + 1)) + fi + else + log_warning "SSH key not found: $key_path" + total_issues=$((total_issues + 1)) + fi + + echo "" + echo "========================================" + if [ $total_issues -eq 0 ]; then + log_success "SSH security audit passed - no issues found" + else + log_warning "SSH security audit found $total_issues issue(s)" + echo "" + log_info "Recommendations:" + echo " - Run '$SCRIPT_NAME fix-perms' to fix permission issues" + echo " - Run '$SCRIPT_NAME harden-ssh' to harden SSH configuration" + echo " - Run '$SCRIPT_NAME rotate-key' to rotate SSH keys if compromised" + fi + + return $total_issues +} + +# Main function +main() { + case "${1:-help}" in + validate-key) + check_root + local key_path="${2:-/usr/viewtouch/ssh/reverse_ssh_key}" + validate_key "$key_path" + ;; + rotate-key) + check_root + local key_path="${2:-/usr/viewtouch/ssh/reverse_ssh_key}" + rotate_key "$key_path" + ;; + check-ssh) + check_root + check_ssh_security + ;; + harden-ssh) + check_root + harden_ssh_config + ;; + gen-mgmt-config) + check_root + generate_mgmt_config + ;; + check-perms) + check_root + check_permissions + ;; + fix-perms) + check_root + fix_permissions + ;; + audit) + check_root + run_audit + ;; + help|--help|-h) + show_usage + ;; + *) + log_error "Unknown command: $1" + echo "" + show_usage + exit 1 + ;; + esac +} + +main "$@" diff --git a/src/core/basic.hh b/src/core/basic.hh index e9d42c10..b5a134d2 100644 --- a/src/core/basic.hh +++ b/src/core/basic.hh @@ -18,8 +18,8 @@ * Standard types, macros & definitions used in application */ -#ifndef BASIC_HH -#define BASIC_HH +#ifndef _BASIC_HH +#define _BASIC_HH #include #include diff --git a/src/core/crash_report.cc b/src/core/crash_report.cc index e9d7e414..9266f46f 100644 --- a/src/core/crash_report.cc +++ b/src/core/crash_report.cc @@ -67,7 +67,7 @@ namespace vt_crash { if (S_ISDIR(st.st_mode)) { return true; } else { - std::cerr << "ERROR: Crash report path exists but is not a directory: " << dir << '\n'; + std::cerr << "ERROR: Crash report path exists but is not a directory: " << dir << std::endl; return false; } } @@ -83,15 +83,16 @@ namespace vt_crash { } // Create the directory with permissions 0750 (rely on umask for further restriction) - const int mkdir_result = mkdir(dir.c_str(), 0750); - if (mkdir_result == 0 || errno == EEXIST) { - // Either we created it or another process raced us to create it + if (mkdir(dir.c_str(), 0750) == 0) { return true; + } else if (errno == EEXIST) { + // Directory was created by another process + return true; + } else { + std::cerr << "ERROR: Failed to create crash report directory: " << dir + << " (errno: " << errno << ")" << std::endl; + return false; } - - std::cerr << "ERROR: Failed to create crash report directory: " << dir - << " (errno: " << errno << ")" << '\n'; - return false; } void InitializeCrashReporting(const std::string& crash_report_dir) { @@ -100,10 +101,10 @@ namespace vt_crash { // Create crash report directory if it doesn't exist if (!EnsureCrashReportDirectory(crash_report_dir)) { - std::cerr << "WARNING: Could not create crash report directory: " << crash_report_dir << '\n'; - std::cerr << "Crash reports may not be saved to disk." << '\n'; + std::cerr << "WARNING: Could not create crash report directory: " << crash_report_dir << std::endl; + std::cerr << "Crash reports may not be saved to disk." << std::endl; } else { - std::cerr << "Crash reporting initialized - reports will be saved to: " << crash_report_dir << '\n'; + std::cerr << "Crash reporting initialized - reports will be saved to: " << crash_report_dir << std::endl; } // Note: We don't set up signal handlers here because they are set up @@ -187,6 +188,7 @@ namespace vt_crash { bool found_model = false; int cpu_count = 0; std::string model_name; + std::string cpu_freq; while (fgets(line, sizeof(line), cpuinfo)) { std::string line_str(line); @@ -424,9 +426,7 @@ namespace vt_crash { } // Get symbols - void* raw_symbols = reinterpret_cast(backtrace_symbols(buffer.data(), num_frames)); - std::unique_ptr symbols_guard(raw_symbols, &std::free); - auto symbols = static_cast(raw_symbols); + char** symbols = backtrace_symbols(buffer.data(), num_frames); if (symbols == nullptr) { oss << "Failed to get stack trace symbols\n"; return oss.str(); @@ -487,6 +487,7 @@ namespace vt_crash { oss << "\n"; } + free(symbols); #else oss << "Stack trace not available on this platform\n"; oss << "(execinfo.h is a GNU/Linux extension)\n"; @@ -662,14 +663,14 @@ namespace vt_crash { // Ensure directory exists before trying to write if (!EnsureCrashReportDirectory(report_dir)) { - std::cerr << "ERROR: Cannot create crash report directory: " << report_dir << '\n'; + std::cerr << "ERROR: Cannot create crash report directory: " << report_dir << std::endl; // Try to write to /tmp as fallback std::string fallback_dir = "/tmp"; if (EnsureCrashReportDirectory(fallback_dir)) { report_dir = fallback_dir; - std::cerr << "Using fallback directory: " << report_dir << '\n'; + std::cerr << "Using fallback directory: " << report_dir << std::endl; } else { - std::cerr << "ERROR: Cannot create fallback directory either!" << '\n'; + std::cerr << "ERROR: Cannot create fallback directory either!" << std::endl; } } diff --git a/src/core/data_file.hh b/src/core/data_file.hh index e27362d8..965cce17 100644 --- a/src/core/data_file.hh +++ b/src/core/data_file.hh @@ -19,8 +19,8 @@ * Functions for the reading & writing of data files */ -#ifndef DATA_FILE_HH -#define DATA_FILE_HH +#ifndef _DATA_FILE_HH +#define _DATA_FILE_HH #include "utility.hh" @@ -76,7 +76,7 @@ public: int Read(Str &val); int Read(TimeInfo &val); - // conditional reads (won't read if pointer is nullptr) + // conditional reads (won't read if pointer is NULL) int Read(int *val); int Read(Flt *val); int Read(Str *val); @@ -125,7 +125,7 @@ public: int Write(Flt val, int bk = 0); int Write(TimeInfo &val, int bk = 0); - // conditional writes (won't write if pointer is nullptr) + // conditional writes (won't write if pointer is NULL) int Write(int *val, int bk = 0); int Write(const char* val, int bk = 0); int Write(Flt *val, int bk = 0); diff --git a/src/core/data_persistence_manager.cc b/src/core/data_persistence_manager.cc index 53ed1452..0ace1760 100644 --- a/src/core/data_persistence_manager.cc +++ b/src/core/data_persistence_manager.cc @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -294,7 +293,7 @@ DataPersistenceManager::ValidationResult DataPersistenceManager::ValidateCritica return overall_result; } -void DataPersistenceManager::RegisterValidationCallback(const std::string& name, const ValidationCallback& callback) +void DataPersistenceManager::RegisterValidationCallback(const std::string& name, ValidationCallback callback) { validation_callbacks.push_back(callback); LogInfo("Registered validation callback: " + name); @@ -352,7 +351,7 @@ DataPersistenceManager::SaveResult DataPersistenceManager::SaveCriticalData() return overall_result; } -void DataPersistenceManager::RegisterSaveCallback(const std::string& name, const SaveCallback& callback) +void DataPersistenceManager::RegisterSaveCallback(const std::string& name, SaveCallback callback) { save_callbacks.push_back(callback); LogInfo("Registered save callback: " + name); @@ -366,8 +365,8 @@ void DataPersistenceManager::RegisterCriticalData(const std::string& name, data_item.name = name; data_item.is_dirty = false; data_item.last_modified = std::chrono::steady_clock::now(); - data_item.validator = std::move(validator); - data_item.saver = std::move(saver); + data_item.validator = validator; + data_item.saver = saver; data_item.consecutive_failures = 0; data_item.last_failure = std::chrono::steady_clock::now(); diff --git a/src/core/data_persistence_manager.hh b/src/core/data_persistence_manager.hh index 689d91c5..9fe12cb6 100644 --- a/src/core/data_persistence_manager.hh +++ b/src/core/data_persistence_manager.hh @@ -78,9 +78,9 @@ public: std::string component; int severity; // 0=info, 1=warning, 2=error, 3=critical - ErrorInfo(std::string msg, std::string comp, int sev = 2) - : message(std::move(msg)), timestamp(std::chrono::system_clock::now()), - component(std::move(comp)), severity(sev) {} + ErrorInfo(const std::string& msg, const std::string& comp, int sev = 2) + : message(msg), timestamp(std::chrono::system_clock::now()), + component(comp), severity(sev) {} }; // Data operation result with detailed information @@ -121,14 +121,14 @@ private: // Critical data tracking struct CriticalData { std::string name; - bool is_dirty{false}; + bool is_dirty; std::chrono::steady_clock::time_point last_modified; ValidationCallback validator; SaveCallback saver; - int consecutive_failures{0}; + int consecutive_failures; std::chrono::steady_clock::time_point last_failure; - CriticalData() = default; + CriticalData() : is_dirty(false), consecutive_failures(0) {} }; std::vector critical_data_items; @@ -151,16 +151,18 @@ private: // Performance metrics struct PerformanceMetrics { - int total_validations{0}; - int total_saves{0}; - int failed_validations{0}; - int failed_saves{0}; - std::chrono::milliseconds total_validation_time{0}; - std::chrono::milliseconds total_save_time{0}; + int total_validations; + int total_saves; + int failed_validations; + int failed_saves; + std::chrono::milliseconds total_validation_time; + std::chrono::milliseconds total_save_time; std::chrono::steady_clock::time_point last_reset; - PerformanceMetrics() - : last_reset(std::chrono::steady_clock::now()) {} + PerformanceMetrics() : total_validations(0), total_saves(0), + failed_validations(0), failed_saves(0), + total_validation_time(0), total_save_time(0), + last_reset(std::chrono::steady_clock::now()) {} }; PerformanceMetrics metrics; @@ -211,14 +213,14 @@ public: // Data validation ValidationResult ValidateAllData(); ValidationResult ValidateCriticalData(); - void RegisterValidationCallback(const std::string& name, const ValidationCallback& callback); + void RegisterValidationCallback(const std::string& name, ValidationCallback callback); // Data saving SaveResult SaveAllData(); SaveResult SaveCriticalData(); OperationResult SaveAllDataDetailed(); OperationResult SaveCriticalDataDetailed(); - void RegisterSaveCallback(const std::string& name, const SaveCallback& callback); + void RegisterSaveCallback(const std::string& name, SaveCallback callback); // Critical data management void RegisterCriticalData(const std::string& name, diff --git a/src/core/debug.cc b/src/core/debug.cc index a3ff6e82..b10ad771 100644 --- a/src/core/debug.cc +++ b/src/core/debug.cc @@ -218,28 +218,28 @@ void PrintTermCode( int code ) noexcept constexpr std::array server_codes = { "", - "SrvError", - "SrvTermInfo", - "SrvTouch", - "SrvKey", - "SrvMouse", - "SrvPageData", - "SrvZoneData", - "SrvZoneChanges", - "SrvKillPage", - "SrvKillZone", - "SrvKillZones", - "SrvTranslate", - "SrvListSelect", - "SrvSwipe", - "SrvButtonPress", - "SrvItemSelect", - "SrvTextEntry", - "", - "", - "SrvPrinterDone", - "SrvBadFile", - "SrvDefPage" + "SERVER_ERROR", + "SERVER_TERMINFO", + "SERVER_TOUCH", + "SERVER_KEY", + "SERVER_MOUSE", + "SERVER_PAGEDATA", + "SERVER_ZONEDATA", + "SERVER_ZONECHANGES", + "SERVER_KILLPAGE", + "SERVER_KILLZONE", + "SERVER_KILLZONES", + "SERVER_TRANSLATE", + "SERVER_LISTSELECT", + "SERVER_SWIPE", + "SERVER_BUTTONPRESS", + "SERVER_ITEMSELECT", + "SERVER_TEXTENTRY", + "", + "", + "SERVER_PRINTER_DONE", + "SERVER_BADFILE", + "SERVER_DEFPAGE" }; constexpr int num_server_codes = static_cast(server_codes.size()); void PrintServerCode( int code ) noexcept diff --git a/src/core/debug.hh b/src/core/debug.hh index 014040dd..d4ec10ef 100644 --- a/src/core/debug.hh +++ b/src/core/debug.hh @@ -21,7 +21,7 @@ */ #ifndef _DEBUG_FUNCS_HH -#define DEBUG_FUNCS_HH +#define _DEBUG_FUNCS_HH #include "basic.hh" diff --git a/src/core/error_handler.cc b/src/core/error_handler.cc index 95cb4e69..291a7cae 100644 --- a/src/core/error_handler.cc +++ b/src/core/error_handler.cc @@ -64,7 +64,7 @@ namespace vt_error { log_file_.open(log_file_path_, std::ios::app); if (!log_file_.is_open()) { - std::cerr << "Error: Could not open log file: " << log_file_path_ << '\n'; + std::cerr << "Error: Could not open log file: " << log_file_path_ << std::endl; } } @@ -250,14 +250,14 @@ namespace vt_error { } if (log_file_.is_open()) { - log_file_ << formatLogEntry(error) << '\n'; + log_file_ << formatLogEntry(error) << std::endl; log_file_.flush(); } } void ErrorHandler::logToConsole(const ErrorInfo& error) { std::ostream& stream = (error.severity >= Severity::ERROR) ? std::cerr : std::cout; - stream << formatLogEntry(error) << '\n'; + stream << formatLogEntry(error) << std::endl; } void ErrorHandler::notifyCallbacks(const ErrorInfo& error) { @@ -267,7 +267,7 @@ namespace vt_error { callback(error); } catch (const std::exception& e) { // Log callback error but don't let it propagate - std::cerr << "Error in error handler callback: " << e.what() << '\n'; + std::cerr << "Error in error handler callback: " << e.what() << std::endl; } } } diff --git a/src/core/image_data.hh b/src/core/image_data.hh index 953101bd..a40f8a23 100644 --- a/src/core/image_data.hh +++ b/src/core/image_data.hh @@ -19,7 +19,7 @@ */ #ifndef _IMAGE_DATA_HH -#define IMAGE_DATA_HH +#define _IMAGE_DATA_HH #include diff --git a/src/core/list_utility.hh b/src/core/list_utility.hh index c2650820..27c8646a 100644 --- a/src/core/list_utility.hh +++ b/src/core/list_utility.hh @@ -223,20 +223,27 @@ class DList while (psize > 0 || (qsize > 0 && q)) { /* decide whether next element of merge comes from p or q */ - const bool take_from_q = (psize == 0) - ? true - : ! (qsize == 0 || q == nullptr || cmp(p, q) <= 0); - - if (take_from_q) + if (psize == 0) { - /* take from q */ + /* p is empty; e must come from q. */ e = q; q = q->next; qsize--; } - else + else if (qsize == 0 || q == nullptr) + { + /* q is empty; e must come from p. */ + e = p; p = p->next; psize--; + } + else if (cmp(p,q) <= 0) { - /* take from p */ + /* First element of p is lower (or same); + * e must come from p. */ e = p; p = p->next; psize--; } + else + { + /* First element of q is lower; e must come from q. */ + e = q; q = q->next; qsize--; + } /* add the next element to the merged list */ if (tail) { diff --git a/src/core/time_info.cc b/src/core/time_info.cc index fcaf6e09..ef8d425f 100644 --- a/src/core/time_info.cc +++ b/src/core/time_info.cc @@ -570,7 +570,7 @@ int TimeInfo::WeekDay() const return 6; } else { - std::cout << wd << '\n'; + std::cout << wd << std::endl; throw std::runtime_error("TimeInfo::Weekday(): Unknown Weekday value"); } // function using unsigned operator as defined in C++20 diff --git a/src/core/time_info.hh b/src/core/time_info.hh index 97399e22..7a0de48f 100644 --- a/src/core/time_info.hh +++ b/src/core/time_info.hh @@ -39,7 +39,7 @@ public: TimeInfo(); TimeInfo(const TimeInfo &other); - [[nodiscard]] const date::local_time &get_local_time() const; + const date::local_time &get_local_time() const; // Member Functions int Set(); // Sets time values to current time int Set(int s, int y); @@ -47,7 +47,7 @@ public: int Set(const TimeInfo *other); // Copies time value int Set(const TimeInfo &other); // Copies time value int Clear(); // Erases time value - [[nodiscard]] bool IsSet() const; // boolean - has time been set? + bool IsSet() const; // boolean - has time been set? int AdjustSeconds(int amount); // Adds 'amount' to current second int AdjustMinutes(int amount); // Adds 'amount' to current minute int AdjustDays(int amount); // Adds 'amount' to current day @@ -61,10 +61,10 @@ public: // if sign < 0 jump backward a half mont // d_low and d_high are the days in the month to jump to void half_month_jump(const int sign, const int d_low, const int d_high); - [[nodiscard]] std::string DebugPrint() const; // Just prints the time value for debugging (minutes accuracy) - [[nodiscard]] std::string to_string() const; - [[nodiscard]] std::string Date() const; - [[nodiscard]] std::string Time()const; + std::string DebugPrint() const; // Just prints the time value for debugging (minutes accuracy) + std::string to_string() const; + std::string Date() const; + std::string Time()const; TimeInfo& operator= (const TimeInfo &other); @@ -108,7 +108,7 @@ public: // helper to get the specified property template - [[nodiscard]] int get() const + int get() const { auto t_floor = date::floor(t_); auto dur = std::chrono::duration_cast(t_ - t_floor); @@ -118,18 +118,18 @@ public: return static_cast(dur_cnt); } // getters using get() - [[nodiscard]] int Sec() const; - [[nodiscard]] int Min() const; - [[nodiscard]] int Hour() const; - [[nodiscard]] int Day() const; - [[nodiscard]] int Month() const; - [[nodiscard]] int Year() const; + int Sec() const; + int Min() const; + int Hour() const; + int Day() const; + int Month() const; + int Year() const; // the weekday of the TimeInfo - [[nodiscard]] int WeekDay() const; + int WeekDay() const; // get the seconds since midnight of the current year - [[nodiscard]] int SecondsInYear() const; + int SecondsInYear() const; // get the days in the current month - [[nodiscard]] int DaysInMonth() const; + int DaysInMonth() const; // round down to the precision defined by Duration // for example floor() diff --git a/src/network/remote_link.cc b/src/network/remote_link.cc index 79485734..2a47677d 100644 --- a/src/network/remote_link.cc +++ b/src/network/remote_link.cc @@ -345,7 +345,7 @@ int CharQueue::Read(int device_no) timeout.tv_sec = 5; // 5 second timeout for header timeout.tv_usec = 0; - int select_result = select(device_no + 1, &read_fds, nullptr, nullptr, &timeout); + int select_result = select(device_no + 1, &read_fds, NULL, NULL, &timeout); if (select_result <= 0) { fprintf(stderr, "CharQueue::Read() - Timeout/header read failed\n"); fcntl(device_no, F_SETFL, original_flags); // Restore original flags @@ -389,7 +389,7 @@ int CharQueue::Read(int device_no) timeout.tv_sec = 5; timeout.tv_usec = 0; - int select_result = select(device_no + 1, &read_fds, nullptr, nullptr, &timeout); + int select_result = select(device_no + 1, &read_fds, NULL, NULL, &timeout); if (select_result == -1 && errno == EINTR) continue; if (select_result <= 0) diff --git a/src/network/remote_link.hh b/src/network/remote_link.hh index 581a03b8..30ddb5bb 100644 --- a/src/network/remote_link.hh +++ b/src/network/remote_link.hh @@ -19,7 +19,7 @@ */ #ifndef _REMOTE_LINK_HH -#define REMOTE_LINK_HH +#define _REMOTE_LINK_HH #include "basic.hh" @@ -297,85 +297,117 @@ namespace TerminalProtocol { /**** Server Protocol Constants ****/ // Note: any updates should be applied to debug.cc too -enum class ServerProtocol : int { - SrvError = 1, // - SrvTermInfo = 2, // - SrvTouch = 3, // - SrvKey = 4, // - SrvMouse = 5, // - SrvPageData = 6, // see term_dialog.cc - SrvZoneData = 7, // see term_dialog.cc - SrvZoneChanges = 8, // see term_dialog.cc - SrvKillPage = 9, // no args - SrvKillZone = 10, // no args - SrvKillZones = 11, // no args - SrvTranslate = 12, // - SrvListSelect = 13, // see term_dialog.cc - SrvSwipe = 14, // - card swiped in card reader - SrvButtonPress = 15, // - layer id, button id - SrvItemSelect = 16, // - layer, menu/list, item - SrvTextEntry = 17, // - layer, entry, value - SrvShutdown = 18, // no args +namespace ServerProtocol { + inline constexpr int ERROR = 1; // + inline constexpr int TERMINFO = 2; // + inline constexpr int TOUCH = 3; // + inline constexpr int KEY = 4; // + inline constexpr int MOUSE = 5; // + inline constexpr int PAGEDATA = 6; // see term_dialog.cc + inline constexpr int ZONEDATA = 7; // see term_dialog.cc + inline constexpr int ZONECHANGES = 8; // see term_dialog.cc + inline constexpr int KILLPAGE = 9; // no args + inline constexpr int KILLZONE = 10; // no args + inline constexpr int KILLZONES = 11; // no args + inline constexpr int TRANSLATE = 12; // + inline constexpr int LISTSELECT = 13; // see term_dialog.cc + inline constexpr int SWIPE = 14; // - card swiped in card reader + inline constexpr int BUTTONPRESS = 15; // - layer id, button id + inline constexpr int ITEMSELECT = 16; // - layer, menu/list, item + inline constexpr int TEXTENTRY = 17; // - layer, entry, value + inline constexpr int SHUTDOWN = 18; // no args - SrvPrinterDone = 20, // - printer done printing file - SrvBadFile = 21, // - invalid file given - SrvDefPage = 22, // see term_dialog.cc + inline constexpr int PRINTER_DONE = 20; // - printer done printing file + inline constexpr int BADFILE = 21; // - invalid file given + inline constexpr int DEFPAGE = 22; // see term_dialog.cc - SrvCcProcessed = 30, // see Terminal::ReadCreditCard() - SrvCcSettled = 31, - SrvCcInit = 32, - SrvCcTotals = 33, - SrvCcDetails = 34, - SrvCcSafCleared = 35, - SrvCcSafDetails = 36, - SrvCcSettleFailed = 37, - SrvCcSafClearFailed = 38 -}; - -inline constexpr int ToInt(ServerProtocol code) { - return static_cast(code); + inline constexpr int CC_PROCESSED = 30; // see Terminal::ReadCreditCard() + inline constexpr int CC_SETTLED = 31; + inline constexpr int CC_INIT = 32; + inline constexpr int CC_TOTALS = 33; + inline constexpr int CC_DETAILS = 34; + inline constexpr int CC_SAFCLEARED = 35; + inline constexpr int CC_SAFDETAILS = 36; + inline constexpr int CC_SETTLEFAILED = 37; + inline constexpr int CC_SAFCLEARFAILED = 38; } -/**** Printer Protocol Constants ****/ -enum class PrinterProtocol : int { - File = 1, // - specify file to print - Cancel = 2, // no args - cancel current printing task - OpenDrawer = 3, // - open drawer - Die = 99 // no args - kills printer process -}; +// Maintain backward compatibility with legacy #define names +#define SERVER_ERROR ServerProtocol::ERROR +#define SERVER_TERMINFO ServerProtocol::TERMINFO +#define SERVER_TOUCH ServerProtocol::TOUCH +#define SERVER_KEY ServerProtocol::KEY +#define SERVER_MOUSE ServerProtocol::MOUSE +#define SERVER_PAGEDATA ServerProtocol::PAGEDATA +#define SERVER_ZONEDATA ServerProtocol::ZONEDATA +#define SERVER_ZONECHANGES ServerProtocol::ZONECHANGES +#define SERVER_KILLPAGE ServerProtocol::KILLPAGE +#define SERVER_KILLZONE ServerProtocol::KILLZONE +#define SERVER_KILLZONES ServerProtocol::KILLZONES +#define SERVER_TRANSLATE ServerProtocol::TRANSLATE +#define SERVER_LISTSELECT ServerProtocol::LISTSELECT +#define SERVER_SWIPE ServerProtocol::SWIPE +#define SERVER_BUTTONPRESS ServerProtocol::BUTTONPRESS +#define SERVER_ITEMSELECT ServerProtocol::ITEMSELECT +#define SERVER_TEXTENTRY ServerProtocol::TEXTENTRY +#define SERVER_SHUTDOWN ServerProtocol::SHUTDOWN +#define SERVER_PRINTER_DONE ServerProtocol::PRINTER_DONE +#define SERVER_BADFILE ServerProtocol::BADFILE +#define SERVER_DEFPAGE ServerProtocol::DEFPAGE +#define SERVER_CC_PROCESSED ServerProtocol::CC_PROCESSED +#define SERVER_CC_SETTLED ServerProtocol::CC_SETTLED +#define SERVER_CC_INIT ServerProtocol::CC_INIT +#define SERVER_CC_TOTALS ServerProtocol::CC_TOTALS +#define SERVER_CC_DETAILS ServerProtocol::CC_DETAILS +#define SERVER_CC_SAFCLEARED ServerProtocol::CC_SAFCLEARED +#define SERVER_CC_SAFDETAILS ServerProtocol::CC_SAFDETAILS +#define SERVER_CC_SETTLEFAILED ServerProtocol::CC_SETTLEFAILED +#define SERVER_CC_SAFCLEARFAILED ServerProtocol::CC_SAFCLEARFAILED -inline constexpr int ToInt(PrinterProtocol code) { - return static_cast(code); +/**** Printer Protocol Constants ****/ +namespace PrinterProtocol { + inline constexpr int FILE = 1; // - specify file to print + inline constexpr int CANCEL = 2; // no args - cancel current printing task + inline constexpr int OPENDRAWER = 3; // - open drawer + inline constexpr int DIE = 99; // no args - kills printer process } -/*** Mode Constants ***/ -enum class OperationMode : int { - OpNone = 0, // normal operation mode - OpTraining = 1, // current user is in training - OpTranslate = 2, // edit mode - button translation - OpEdit = 3, // edit mode - application building - OpMacro = 5 // record a macro -}; - -inline constexpr int ToInt(OperationMode mode) { - return static_cast(mode); +// Maintain backward compatibility +#define PRINTER_FILE PrinterProtocol::FILE +#define PRINTER_CANCEL PrinterProtocol::CANCEL +#define PRINTER_OPENDRAWER PrinterProtocol::OPENDRAWER +#define PRINTER_DIE PrinterProtocol::DIE + +/**** Mode Constants ****/ +namespace OperationMode { + inline constexpr int NONE = 0; // normal operation mode + inline constexpr int TRAINING = 1; // current user is in training + inline constexpr int TRANSLATE = 2; // edit mode - button translation + inline constexpr int EDIT = 3; // edit mode - application building + inline constexpr int MACRO = 5; // record a macro } -/*** Window Frame Constants ***/ -enum class WindowFrame : int { - FrameBorder = 1, // regular border for window - FrameTitle = 2, // title bar on window - FrameMove = 4, // window can be moved by titlebar - FrameResize = 8, // resize window handles on border - FrameClose = 16 // close button on window border -}; - -inline constexpr int ToInt(WindowFrame frame) { - return static_cast(frame); +// Maintain backward compatibility +#define MODE_NONE OperationMode::NONE +#define MODE_TRAINING OperationMode::TRAINING +#define MODE_TRANSLATE OperationMode::TRANSLATE +#define MODE_EDIT OperationMode::EDIT +#define MODE_MACRO OperationMode::MACRO + +/**** Window Frame Constants ****/ +namespace WindowFrame { + inline constexpr int BORDER = 1; // regular border for window + inline constexpr int TITLE = 2; // title bar on window + inline constexpr int MOVE = 4; // window can be moved by titlebar + inline constexpr int RESIZE = 8; // resize window handles on border + inline constexpr int CLOSE = 16; // close button on window border } -inline constexpr int operator|(WindowFrame lhs, WindowFrame rhs) { - return ToInt(lhs) | ToInt(rhs); -} +// Maintain backward compatibility +#define WINFRAME_BORDER WindowFrame::BORDER +#define WINFRAME_TITLE WindowFrame::TITLE +#define WINFRAME_MOVE WindowFrame::MOVE +#define WINFRAME_RESIZE WindowFrame::RESIZE +#define WINFRAME_CLOSE WindowFrame::CLOSE #endif diff --git a/src/network/reverse_ssh_daemon.cc b/src/network/reverse_ssh_daemon.cc new file mode 100644 index 00000000..2730fb20 --- /dev/null +++ b/src/network/reverse_ssh_daemon.cc @@ -0,0 +1,323 @@ +/* + * Copyright ViewTouch, Inc., 1995, 1996, 1997, 1998, 2025 + + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * reverse_ssh_daemon.cc - Standalone reverse SSH tunnel daemon + */ + +#include "reverse_ssh_service.hh" +#include "src/utils/vt_logger.hh" +#include "basic.hh" +#include +#include +#include +#include +#include +#include +#include + +namespace fs = std::filesystem; + +// Global variables for signal handling +volatile bool running = true; +std::unique_ptr ssh_service; + +// Signal handler +void signal_handler(int signum) { + vt::Logger::info("[ReverseSSH Daemon] Received signal {}, shutting down...", signum); + running = false; + if (ssh_service) { + ssh_service->Stop(); + } +} + +// Configuration file structure +struct DaemonConfig { + std::string management_server; + int management_port = 22; + std::string remote_user; + int local_port = 22; + int remote_port = 0; + std::string ssh_key_path; + int reconnect_interval = 30; + int health_check_interval = 60; + int max_retries = 10; + std::string log_file = "/var/log/viewtouch/reverse_ssh_daemon.log"; + std::string pid_file = "/var/run/viewtouch/reverse_ssh_daemon.pid"; + bool daemonize = true; +}; + +// Load configuration from file +bool load_config(const std::string& config_file, DaemonConfig& config) { + std::ifstream file(config_file); + if (!file.is_open()) { + std::cerr << "Failed to open config file: " << config_file << std::endl; + return false; + } + + std::string line; + while (std::getline(file, line)) { + // Skip comments and empty lines + if (line.empty() || line[0] == '#') continue; + + size_t pos = line.find('='); + if (pos != std::string::npos) { + std::string key = line.substr(0, pos); + std::string value = line.substr(pos + 1); + + // Trim whitespace + key.erase(key.find_last_not_of(" \t") + 1); + value.erase(0, value.find_first_not_of(" \t")); + value.erase(value.find_last_not_of(" \t") + 1); + + if (key == "management_server") config.management_server = value; + else if (key == "management_port") config.management_port = std::stoi(value); + else if (key == "remote_user") config.remote_user = value; + else if (key == "local_port") config.local_port = std::stoi(value); + else if (key == "remote_port") config.remote_port = std::stoi(value); + else if (key == "ssh_key_path") config.ssh_key_path = value; + else if (key == "reconnect_interval") config.reconnect_interval = std::stoi(value); + else if (key == "health_check_interval") config.health_check_interval = std::stoi(value); + else if (key == "max_retries") config.max_retries = std::stoi(value); + else if (key == "log_file") config.log_file = value; + else if (key == "pid_file") config.pid_file = value; + else if (key == "daemonize") config.daemonize = (value == "true" || value == "1"); + } + } + + return true; +} + +// Validate configuration +bool validate_config(const DaemonConfig& config) { + if (config.management_server.empty()) { + std::cerr << "Error: management_server not specified" << std::endl; + return false; + } + if (config.remote_user.empty()) { + std::cerr << "Error: remote_user not specified" << std::endl; + return false; + } + if (config.local_port <= 0 || config.local_port > 65535) { + std::cerr << "Error: invalid local_port" << std::endl; + return false; + } + return true; +} + +// Daemonize the process +void daemonize() { + pid_t pid = fork(); + if (pid < 0) { + std::cerr << "Failed to fork daemon process" << std::endl; + exit(1); + } + if (pid > 0) { + exit(0); // Parent exits + } + + // Child continues + if (setsid() < 0) { + std::cerr << "Failed to create new session" << std::endl; + exit(1); + } + + // Change working directory + if (chdir("/") < 0) { + std::cerr << "Failed to change working directory" << std::endl; + exit(1); + } + + // Close standard file descriptors + close(STDIN_FILENO); + close(STDOUT_FILENO); + close(STDERR_FILENO); +} + +// Write PID file +bool write_pid_file(const std::string& pid_file) { + std::ofstream file(pid_file); + if (!file.is_open()) { + std::cerr << "Failed to write PID file: " << pid_file << std::endl; + return false; + } + file << getpid() << std::endl; + return true; +} + +// Remove PID file +void remove_pid_file(const std::string& pid_file) { + unlink(pid_file.c_str()); +} + +// Print usage information +void print_usage(const char* program_name) { + std::cout << "Usage: " << program_name << " [OPTIONS]" << std::endl; + std::cout << std::endl; + std::cout << "Options:" << std::endl; + std::cout << " -c, --config FILE Configuration file (default: /etc/viewtouch/reverse_ssh.conf)" << std::endl; + std::cout << " -f, --foreground Run in foreground (don't daemonize)" << std::endl; + std::cout << " -h, --help Show this help message" << std::endl; + std::cout << " -v, --version Show version information" << std::endl; + std::cout << std::endl; + std::cout << "Configuration file format:" << std::endl; + std::cout << " management_server=hostname" << std::endl; + std::cout << " management_port=22" << std::endl; + std::cout << " remote_user=username" << std::endl; + std::cout << " local_port=22" << std::endl; + std::cout << " remote_port=0" << std::endl; + std::cout << " ssh_key_path=/path/to/key" << std::endl; + std::cout << " reconnect_interval=30" << std::endl; + std::cout << " health_check_interval=60" << std::endl; + std::cout << " max_retries=10" << std::endl; + std::cout << " log_file=/var/log/viewtouch/reverse_ssh_daemon.log" << std::endl; + std::cout << " pid_file=/var/run/viewtouch/reverse_ssh_daemon.pid" << std::endl; + std::cout << " daemonize=true" << std::endl; +} + +int main(int argc, char* argv[]) { + std::string config_file = "/etc/viewtouch/reverse_ssh.conf"; + bool foreground = false; + + // Parse command line options + struct option long_options[] = { + {"config", required_argument, 0, 'c'}, + {"foreground", no_argument, 0, 'f'}, + {"help", no_argument, 0, 'h'}, + {"version", no_argument, 0, 'v'}, + {0, 0, 0, 0} + }; + + int option_index = 0; + int c; + while ((c = getopt_long(argc, argv, "c:fhv", long_options, &option_index)) != -1) { + switch (c) { + case 'c': + config_file = optarg; + break; + case 'f': + foreground = true; + break; + case 'h': + print_usage(argv[0]); + return 0; + case 'v': + std::cout << "ViewTouch Reverse SSH Daemon v1.0" << std::endl; + return 0; + default: + print_usage(argv[0]); + return 1; + } + } + + // Load configuration + DaemonConfig config; + if (!load_config(config_file, config)) { + return 1; + } + + // Override daemonize if foreground requested + if (foreground) { + config.daemonize = false; + } + + // Validate configuration + if (!validate_config(config)) { + return 1; + } + + // Initialize logging + try { + if (config.daemonize) { + vt::Logger::Initialize("/var/log/viewtouch", "info", false, false); + } else { + vt::Logger::Initialize("/var/log/viewtouch", "debug", true, true); + } + } catch (const std::exception& e) { + std::cerr << "Failed to initialize logging: " << e.what() << std::endl; + return 1; + } + + vt::Logger::info("[ReverseSSH Daemon] Starting ViewTouch Reverse SSH Daemon v1.0"); + vt::Logger::info("[ReverseSSH Daemon] Configuration file: {}", config_file); + + // Daemonize if requested + if (config.daemonize) { + vt::Logger::info("[ReverseSSH Daemon] Daemonizing..."); + daemonize(); + } + + // Write PID file + if (!write_pid_file(config.pid_file)) { + vt::Logger::error("[ReverseSSH Daemon] Failed to write PID file"); + return 1; + } + + // Setup signal handlers + signal(SIGINT, signal_handler); + signal(SIGTERM, signal_handler); + signal(SIGHUP, signal_handler); + + // Initialize reverse SSH service + try { + vt::ReverseSSHService::Configuration ssh_config; + ssh_config.enabled = true; + ssh_config.management_server = config.management_server; + ssh_config.management_port = config.management_port; + ssh_config.remote_user = config.remote_user; + ssh_config.local_port = config.local_port; + ssh_config.remote_port = config.remote_port; + ssh_config.ssh_key_path = config.ssh_key_path; + ssh_config.reconnect_interval = std::chrono::seconds(config.reconnect_interval); + ssh_config.health_check_interval = std::chrono::seconds(config.health_check_interval); + ssh_config.max_retry_attempts = config.max_retries; + + ssh_service = std::make_unique(); + ssh_service->Initialize(ssh_config); + + vt::Logger::info("[ReverseSSH Daemon] Starting reverse SSH service..."); + if (!ssh_service->Start()) { + vt::Logger::error("[ReverseSSH Daemon] Failed to start reverse SSH service"); + remove_pid_file(config.pid_file); + return 1; + } + + } catch (const std::exception& e) { + vt::Logger::error("[ReverseSSH Daemon] Exception during initialization: {}", e.what()); + remove_pid_file(config.pid_file); + return 1; + } + + vt::Logger::info("[ReverseSSH Daemon] Reverse SSH daemon started successfully"); + vt::Logger::info("[ReverseSSH Daemon] PID: {}", getpid()); + vt::Logger::info("[ReverseSSH Daemon] Tunnel: {}:{} -> localhost:{}", + config.management_server, config.remote_port, config.local_port); + + // Main loop + while (running) { + sleep(1); + } + + // Cleanup + vt::Logger::info("[ReverseSSH Daemon] Shutting down..."); + if (ssh_service) { + ssh_service->Stop(); + } + remove_pid_file(config.pid_file); + vt::Logger::Shutdown(); + + vt::Logger::info("[ReverseSSH Daemon] Shutdown complete"); + return 0; +} diff --git a/src/network/reverse_ssh_service.cc b/src/network/reverse_ssh_service.cc new file mode 100644 index 00000000..491f58a5 --- /dev/null +++ b/src/network/reverse_ssh_service.cc @@ -0,0 +1,560 @@ +/* + * Copyright ViewTouch, Inc., 1995, 1996, 1997, 1998, 2025 + + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * reverse_ssh_service.cc - Implementation of reverse SSH tunnel service + */ + +#include "reverse_ssh_service.hh" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace fs = std::filesystem; + +namespace vt { + +// Global service instance +std::unique_ptr GlobalReverseSSHService; + +ReverseSSHService::ReverseSSHService() + : status_(ServiceStatus::STOPPED) + , running_(false) + , tunnel_active_(false) + , consecutive_failures_(0) + , assigned_remote_port_(0) + , ssh_pid_(0) +{ +} + +ReverseSSHService::~ReverseSSHService() { + Stop(); +} + +bool ReverseSSHService::Initialize(const Configuration& config) { + std::lock_guard lock(config_mutex_); + config_ = config; + + if (!ValidateConfiguration()) { + LogError("Invalid reverse SSH configuration"); + return false; + } + + if (config_.enabled) { + status_ = ServiceStatus::STOPPED; + LogInfo("Reverse SSH service initialized and enabled"); + } else { + status_ = ServiceStatus::DISABLED; + LogInfo("Reverse SSH service initialized but disabled"); + } + + return true; +} + +bool ReverseSSHService::Start() { + if (status_ == ServiceStatus::DISABLED) { + LogWarning("Cannot start reverse SSH service - service is disabled"); + return false; + } + + if (status_ == ServiceStatus::RUNNING) { + LogInfo("Reverse SSH service is already running"); + return true; + } + + LogInfo("Starting reverse SSH service..."); + status_ = ServiceStatus::STARTING; + running_ = true; + + try { + // Setup SSH keys if needed + if (!SetupSSHKeys()) { + LogError("Failed to setup SSH keys"); + status_ = ServiceStatus::FAILED; + return false; + } + + // Start the tunnel thread + tunnel_thread_ = std::make_unique([this]() { + while (running_) { + if (EstablishTunnel()) { + tunnel_active_ = true; + status_ = ServiceStatus::RUNNING; + LogInfo("Reverse SSH tunnel established successfully"); + + // Start monitoring thread + monitor_thread_ = std::make_unique([this]() { + MonitorTunnel(); + }); + monitor_thread_->detach(); + + // Wait for tunnel to be stopped + while (running_ && tunnel_active_) { + std::this_thread::sleep_for(std::chrono::seconds(1)); + } + } else { + tunnel_active_ = false; + status_ = ServiceStatus::FAILED; + HandleTunnelFailure(); + } + + if (running_) { + LogInfo("Retrying tunnel establishment in " + + std::to_string(config_.reconnect_interval.count()) + " seconds"); + std::this_thread::sleep_for(config_.reconnect_interval); + } + } + }); + + tunnel_thread_->detach(); + + // Wait a bit for initial connection attempt + std::this_thread::sleep_for(std::chrono::seconds(2)); + + return status_ == ServiceStatus::RUNNING; + + } catch (const std::exception& e) { + LogError("Exception during service start: " + std::string(e.what())); + status_ = ServiceStatus::FAILED; + running_ = false; + return false; + } +} + +void ReverseSSHService::Stop() { + LogInfo("Stopping reverse SSH service..."); + + running_ = false; + status_ = ServiceStatus::STOPPED; + + // Cleanup tunnel + CleanupTunnel(); + + // Wait for threads to finish + if (tunnel_thread_ && tunnel_thread_->joinable()) { + tunnel_thread_->join(); + } + if (monitor_thread_ && monitor_thread_->joinable()) { + monitor_thread_->join(); + } + + tunnel_thread_.reset(); + monitor_thread_.reset(); + + LogInfo("Reverse SSH service stopped"); +} + +bool ReverseSSHService::Restart() { + LogInfo("Restarting reverse SSH service..."); + Stop(); + std::this_thread::sleep_for(std::chrono::seconds(2)); + return Start(); +} + +ReverseSSHService::ServiceStatus ReverseSSHService::GetStatus() const { + return status_; +} + +std::string ReverseSSHService::GetStatusString(ServiceStatus status) const { + switch (status) { + case ServiceStatus::STOPPED: return "STOPPED"; + case ServiceStatus::STARTING: return "STARTING"; + case ServiceStatus::RUNNING: return "RUNNING"; + case ServiceStatus::RECONNECTING: return "RECONNECTING"; + case ServiceStatus::FAILED: return "FAILED"; + case ServiceStatus::DISABLED: return "DISABLED"; + default: return "UNKNOWN"; + } +} + +bool ReverseSSHService::IsHealthy() const { + return status_ == ServiceStatus::RUNNING && tunnel_active_; +} + +std::string ReverseSSHService::GetLastError() const { + std::lock_guard lock(error_mutex_); + return last_error_; +} + +std::string ReverseSSHService::GetTunnelInfo() const { + if (!tunnel_active_ || assigned_remote_port_ == 0) { + return "No active tunnel"; + } + + std::stringstream ss; + ss << "Tunnel active: " << config_.management_server << ":" + << assigned_remote_port_ << " -> localhost:" << config_.local_port; + return ss.str(); +} + +bool ReverseSSHService::UpdateConfiguration(const Configuration& new_config) { + std::lock_guard lock(config_mutex_); + + if (!ValidateConfiguration()) { + LogError("Invalid configuration update"); + return false; + } + + bool needs_restart = (config_.enabled != new_config.enabled) || + (config_.management_server != new_config.management_server) || + (config_.management_port != new_config.management_port) || + (config_.remote_user != new_config.remote_user) || + (config_.local_port != new_config.local_port); + + config_ = new_config; + + if (needs_restart && status_ == ServiceStatus::RUNNING) { + LogInfo("Configuration change requires service restart"); + Restart(); + } + + return true; +} + +const ReverseSSHService::Configuration& ReverseSSHService::GetConfiguration() const { + return config_; +} + +void ReverseSSHService::PerformHealthCheck() { + if (status_ != ServiceStatus::RUNNING) { + return; + } + + if (!CheckTunnelHealth()) { + LogWarning("Health check failed - tunnel may be down"); + tunnel_active_ = false; + status_ = ServiceStatus::RECONNECTING; + } +} + +std::string ReverseSSHService::GetHealthReport() const { + std::stringstream ss; + ss << "Status: " << GetStatusString(status_) << "\n"; + ss << "Tunnel Active: " << (tunnel_active_ ? "Yes" : "No") << "\n"; + ss << "SSH PID: " << ssh_pid_ << "\n"; + ss << "Remote Port: " << assigned_remote_port_ << "\n"; + ss << "Consecutive Failures: " << consecutive_failures_ << "\n"; + + if (!last_error_.empty()) { + ss << "Last Error: " << last_error_ << "\n"; + } + + return ss.str(); +} + +bool ReverseSSHService::ValidateConfiguration() const { + if (!config_.enabled) { + return true; // Disabled config is valid + } + + if (config_.management_server.empty()) { + SetError("Management server not specified"); + return false; + } + + if (config_.remote_user.empty()) { + SetError("Remote user not specified"); + return false; + } + + if (config_.local_port <= 0 || config_.local_port > 65535) { + SetError("Invalid local port"); + return false; + } + + if (config_.management_port <= 0 || config_.management_port > 65535) { + SetError("Invalid management server port"); + return false; + } + + return true; +} + +bool ReverseSSHService::EstablishTunnel() { + try { + std::string ssh_command; + if (!GenerateSSHCommand(ssh_command)) { + return false; + } + + LogInfo("Establishing SSH tunnel: " + ssh_command); + + // Fork and execute SSH command + ssh_pid_ = fork(); + if (ssh_pid_ == 0) { + // Child process + execl("/bin/sh", "sh", "-c", ssh_command.c_str(), nullptr); + _exit(1); // Should not reach here + } else if (ssh_pid_ < 0) { + SetError("Failed to fork SSH process"); + return false; + } + + // Wait a bit for tunnel to establish + std::this_thread::sleep_for(std::chrono::seconds(3)); + + // Check if process is still running and tunnel is active + if (kill(ssh_pid_, 0) == 0) { + // Try to determine assigned remote port if auto-assigned + if (config_.remote_port == 0) { + // For auto-assigned ports, we might need to parse SSH output + // This is a simplified implementation + assigned_remote_port_ = 2222; // Default fallback + } else { + assigned_remote_port_ = config_.remote_port; + } + return true; + } else { + SetError("SSH process terminated immediately"); + return false; + } + + } catch (const std::exception& e) { + SetError("Exception establishing tunnel: " + std::string(e.what())); + return false; + } +} + +void ReverseSSHService::MonitorTunnel() { + LogInfo("Starting tunnel monitoring"); + + while (running_ && tunnel_active_) { + std::this_thread::sleep_for(config_.health_check_interval); + + if (!running_) break; + + PerformHealthCheck(); + + if (!tunnel_active_) { + LogWarning("Tunnel health check failed"); + break; + } + } + + LogInfo("Tunnel monitoring stopped"); +} + +void ReverseSSHService::CleanupTunnel() { + if (ssh_pid_ > 0) { + LogInfo("Terminating SSH tunnel process (PID: " + std::to_string(ssh_pid_) + ")"); + + // Try graceful termination first + kill(ssh_pid_, SIGTERM); + + // Wait up to 5 seconds for graceful shutdown + int wait_count = 0; + while (wait_count < 50 && kill(ssh_pid_, 0) == 0) { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + wait_count++; + } + + // Force kill if still running + if (kill(ssh_pid_, 0) == 0) { + LogWarning("Force killing SSH process"); + kill(ssh_pid_, SIGKILL); + } + + // Wait for process to be cleaned up + waitpid(ssh_pid_, nullptr, 0); + ssh_pid_ = 0; + } + + tunnel_active_ = false; + assigned_remote_port_ = 0; +} + +bool ReverseSSHService::CheckTunnelHealth() const { + if (ssh_pid_ <= 0) { + return false; + } + + // Check if SSH process is still running + if (kill(ssh_pid_, 0) != 0) { + return false; + } + + // Try to test the tunnel by attempting a connection + // This is a simplified check - in production you might want more sophisticated monitoring + return true; +} + +bool ReverseSSHService::GenerateSSHCommand(std::string& command) const { + std::stringstream ss; + + ss << "ssh"; + + // SSH options for reliability + if (config_.enable_keepalive) { + ss << " -o ServerAliveInterval=" << config_.server_alive_interval.count(); + ss << " -o ServerAliveCountMax=3"; + } + + if (config_.enable_compression) { + ss << " -o Compression=yes"; + } + + // Connection timeout + ss << " -o ConnectTimeout=10"; + + // Strict host key checking (should be disabled for automation but kept for security) + ss << " -o StrictHostKeyChecking=no"; + + // User known hosts file + if (!config_.known_hosts_path.empty()) { + ss << " -o UserKnownHostsFile=" << config_.known_hosts_path; + } + + // SSH key + if (!config_.ssh_key_path.empty()) { + ss << " -i " << config_.ssh_key_path; + } + + // Quiet mode + ss << " -q"; + + // Reverse tunnel specification + ss << " -R "; + if (config_.remote_port > 0) { + ss << config_.remote_port; + } else { + ss << "0"; // Auto-assign + } + ss << ":localhost:" << config_.local_port; + + // Remote user and server + ss << " " << config_.remote_user << "@" << config_.management_server; + + // Remote command to keep tunnel alive + ss << " 'echo \"Tunnel established\"; while true; do sleep 60; done'"; + + command = ss.str(); + return true; +} + +bool ReverseSSHService::SetupSSHKeys() { + if (config_.ssh_key_path.empty()) { + // Generate a default key if none specified + config_.ssh_key_path = "/usr/viewtouch/ssh/reverse_ssh_key"; + + fs::path key_dir = fs::path(config_.ssh_key_path).parent_path(); + if (!fs::exists(key_dir)) { + fs::create_directories(key_dir); + } + + if (!fs::exists(config_.ssh_key_path)) { + LogInfo("Generating SSH key for reverse tunnel: " + config_.ssh_key_path); + std::string keygen_cmd = "ssh-keygen -t ed25519 -f " + config_.ssh_key_path + + " -N '' -C 'viewtouch-reverse-ssh' 2>/dev/null"; + if (system(keygen_cmd.c_str()) != 0) { + SetError("Failed to generate SSH key"); + return false; + } + } + } + + // Set proper permissions + chmod(config_.ssh_key_path.c_str(), S_IRUSR | S_IWUSR); + std::string pub_key_path = config_.ssh_key_path + ".pub"; + if (fs::exists(pub_key_path)) { + chmod(pub_key_path.c_str(), S_IRUSR | S_IROTH | S_IRGRP); + } + + return true; +} + +bool ReverseSSHService::TestSSHConnection() const { + std::string test_cmd = "ssh -o ConnectTimeout=5 -o BatchMode=yes -o StrictHostKeyChecking=no "; + test_cmd += config_.remote_user + "@" + config_.management_server + " 'echo \"SSH connection test successful\"' 2>/dev/null"; + + FILE* pipe = popen(test_cmd.c_str(), "r"); + if (!pipe) return false; + + char buffer[128]; + std::string result; + while (fgets(buffer, sizeof(buffer), pipe) != nullptr) { + result += buffer; + } + + int status = pclose(pipe); + return (status == 0 && result.find("successful") != std::string::npos); +} + +void ReverseSSHService::HandleTunnelFailure() { + consecutive_failures_++; + + LogWarning("Tunnel establishment failed (attempt " + + std::to_string(consecutive_failures_) + "/" + + std::to_string(config_.max_retry_attempts) + ")"); + + if (consecutive_failures_ >= config_.max_retry_attempts) { + LogError("Maximum retry attempts exceeded, disabling service"); + status_ = ServiceStatus::FAILED; + running_ = false; + return; + } + + // Exponential backoff + auto backoff_time = config_.retry_backoff * consecutive_failures_; + LogInfo("Backing off for " + std::to_string(backoff_time.count()) + " seconds"); + std::this_thread::sleep_for(backoff_time); +} + +std::string ReverseSSHService::ExecuteCommand(const std::string& command) const { + char buffer[128]; + std::string result; + + FILE* pipe = popen(command.c_str(), "r"); + if (!pipe) return ""; + + while (fgets(buffer, sizeof(buffer), pipe) != nullptr) { + result += buffer; + } + + pclose(pipe); + return result; +} + +void ReverseSSHService::LogStatusChange(ServiceStatus old_status, ServiceStatus new_status) { + LogInfo("Status changed from " + std::to_string(static_cast(old_status)) + + " to " + std::to_string(static_cast(new_status))); +} + +void ReverseSSHService::SetError(const std::string& error) const { + std::lock_guard lock(error_mutex_); + last_error_ = error; +} + +void ReverseSSHService::LogInfo(const std::string& message) const { + vt::Logger::info("[ReverseSSH] {}", message); +} + +void ReverseSSHService::LogWarning(const std::string& message) const { + vt::Logger::warn("[ReverseSSH] {}", message); +} + +void ReverseSSHService::LogError(const std::string& message) const { + vt::Logger::error("[ReverseSSH] {}", message); + SetError(message); +} + +} // namespace vt diff --git a/src/network/reverse_ssh_service.hh b/src/network/reverse_ssh_service.hh new file mode 100644 index 00000000..c84496f0 --- /dev/null +++ b/src/network/reverse_ssh_service.hh @@ -0,0 +1,154 @@ +/* + * Copyright ViewTouch, Inc., 1995, 1996, 1997, 1998, 2025 + + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * reverse_ssh_service.hh - Reverse SSH tunnel service for remote access + */ + +#ifndef REVERSE_SSH_SERVICE_HH +#define REVERSE_SSH_SERVICE_HH + +#include +#include +#include +#include +#include +#include +#include "src/utils/vt_logger.hh" + +namespace vt { + +/** + * ReverseSSHService - Manages reverse SSH tunnels for remote access + * + * This service creates SSH tunnels that allow remote access to ViewTouch + * systems that are behind NAT/firewalls. The POS system initiates outbound + * connections to a management server, which then allows inbound connections + * back to the POS system. + * + * Features: + * - Automatic tunnel establishment and maintenance + * - Connection health monitoring + * - Secure key-based authentication + * - Configurable retry logic + * - System integration with ViewTouch lifecycle + */ +class ReverseSSHService { +public: + // Service status enumeration + enum class ServiceStatus { + STOPPED, + STARTING, + RUNNING, + RECONNECTING, + FAILED, + DISABLED + }; + + // Configuration structure + struct Configuration { + bool enabled = false; + std::string management_server; + int management_port = 22; + std::string remote_user; + int local_port = 22; // Local SSH port to expose + int remote_port = 0; // Remote port on management server (0 = auto-assign) + std::string ssh_key_path; // Path to SSH private key + std::string known_hosts_path; // Path to known_hosts file + std::chrono::seconds reconnect_interval = std::chrono::seconds(30); + std::chrono::seconds health_check_interval = std::chrono::seconds(60); + int max_retry_attempts = 10; + std::chrono::seconds retry_backoff = std::chrono::seconds(5); + bool enable_compression = true; + bool enable_keepalive = true; + std::chrono::seconds server_alive_interval = std::chrono::seconds(60); + }; + + // Constructor/Destructor + ReverseSSHService(); + ~ReverseSSHService(); + + // Delete copy operations + ReverseSSHService(const ReverseSSHService&) = delete; + ReverseSSHService& operator=(const ReverseSSHService&) = delete; + + // Service lifecycle + bool Initialize(const Configuration& config); + bool Start(); + void Stop(); + bool Restart(); + + // Status and monitoring + ServiceStatus GetStatus() const; + std::string GetStatusString(ServiceStatus status) const; + bool IsHealthy() const; + std::string GetLastError() const; + std::string GetTunnelInfo() const; + + // Configuration + bool UpdateConfiguration(const Configuration& new_config); + const Configuration& GetConfiguration() const; + + // Health monitoring + void PerformHealthCheck(); + std::string GetHealthReport() const; + +private: + // Internal state + std::atomic status_; + Configuration config_; + mutable std::mutex config_mutex_; + std::unique_ptr tunnel_thread_; + std::unique_ptr monitor_thread_; + std::atomic running_; + std::atomic tunnel_active_; + + // Error handling + mutable std::string last_error_; + mutable std::mutex error_mutex_; + int consecutive_failures_; + int assigned_remote_port_; + + // Tunnel management + pid_t ssh_pid_; + + // Internal methods + bool ValidateConfiguration() const; + bool EstablishTunnel(); + void MonitorTunnel(); + void CleanupTunnel(); + bool CheckTunnelHealth() const; + bool GenerateSSHCommand(std::string& command) const; + bool SetupSSHKeys(); + bool TestSSHConnection() const; + void LogStatusChange(ServiceStatus old_status, ServiceStatus new_status); + void HandleTunnelFailure(); + std::string ExecuteCommand(const std::string& command) const; + + // Error handling + void SetError(const std::string& error) const; + + // Logging helpers + void LogInfo(const std::string& message) const; + void LogWarning(const std::string& message) const; + void LogError(const std::string& message) const; +}; + +// Global service instance +extern std::unique_ptr GlobalReverseSSHService; + +} // namespace vt + +#endif // REVERSE_SSH_SERVICE_HH diff --git a/src/network/socket.cc b/src/network/socket.cc index 0b2b5524..503ab115 100644 --- a/src/network/socket.cc +++ b/src/network/socket.cc @@ -50,11 +50,12 @@ int select_timeout = 1; // in milliseconds * Destructor: ****/ Email::~Email() -= default; +{ +} Email::Email(Email&& other) noexcept - : from(other.from), - subject(other.subject), + : from(std::move(other.from)), + subject(std::move(other.subject)), tos(std::move(other.tos)), body(std::move(other.body)), current_to(nullptr), @@ -66,8 +67,8 @@ Email& Email::operator=(Email&& other) noexcept { if (this != &other) { - from = other.from; - subject = other.subject; + from = std::move(other.from); + subject = std::move(other.subject); tos = std::move(other.tos); body = std::move(other.body); current_to = nullptr; @@ -412,7 +413,7 @@ int Connect(const char* host, const char* service) perror("setsockopt SO_SNDTIMEO"); } - memset(&servaddr, 0, sizeof(servaddr)); + bzero(&servaddr, sizeof(servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_port = sp->s_port; memcpy(&servaddr.sin_addr, *pptr, sizeof(struct in_addr)); @@ -441,7 +442,7 @@ int Connect(const char* host, const char* service) FD_ZERO(&write_fds); FD_SET(sockfd, &write_fds); - int select_result = select(sockfd + 1, nullptr, &write_fds, nullptr, &timeout); + int select_result = select(sockfd + 1, NULL, &write_fds, NULL, &timeout); if (select_result > 0) { int error = 0; @@ -519,7 +520,7 @@ int Connect(const char* host, int port) perror("setsockopt SO_SNDTIMEO"); } - memset(&servaddr, 0, sizeof(servaddr)); + bzero(&servaddr, sizeof(servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_port = htons(port); memcpy(&servaddr.sin_addr, *pptr, sizeof(struct in_addr)); @@ -548,7 +549,7 @@ int Connect(const char* host, int port) FD_ZERO(&write_fds); FD_SET(sockfd, &write_fds); - int select_result = select(sockfd + 1, nullptr, &write_fds, nullptr, &timeout); + int select_result = select(sockfd + 1, NULL, &write_fds, NULL, &timeout); if (select_result > 0) { int error = 0; @@ -682,7 +683,7 @@ int SMTP(int fd, Email *email) } // add from address to message body snprintf(outgoing, STRLONG, "From: %s\n", buffer); - vt_safe_string::safe_concat(body, sizeof(body), outgoing); + strncat(body, outgoing, STRLONG); // write each of the to addresses while (email->NextTo(buffer, STRLONG) == 0) @@ -692,7 +693,7 @@ int SMTP(int fd, Email *email) response = GetResponse(fd, responsestr, STRLONG); // add the to address to the message body snprintf(outgoing, STRLONG, "To: %s\n", buffer); - vt_safe_string::safe_concat(body, sizeof(body), outgoing); + strncat(body, outgoing, STRLONG); } // write the message diff --git a/src/network/vt_ccq_pipe.cc b/src/network/vt_ccq_pipe.cc index 5d94594c..bdfb53c4 100644 --- a/src/network/vt_ccq_pipe.cc +++ b/src/network/vt_ccq_pipe.cc @@ -128,7 +128,7 @@ int SocketToSerial(int listen_port, const char* pinpad_device) /* now loop with proper error handling and exit conditions */ int consecutive_failures = 0; const int max_failures = 100; // Maximum consecutive failures before giving up - time_t last_success = time(nullptr); + time_t last_success = time(NULL); const int max_idle_time = 300; // 5 minutes of no activity before checking health while (1) @@ -143,7 +143,7 @@ int SocketToSerial(int listen_port, const char* pinpad_device) if (diagnostics) printf("Opened Device %s, File Descriptor %d\n", pinpad_device, pinpad_fd); consecutive_failures = 0; // Reset failure counter on success - last_success = time(nullptr); + last_success = time(NULL); } else { @@ -164,7 +164,7 @@ int SocketToSerial(int listen_port, const char* pinpad_device) if (diagnostics) printf("Listening on Port: %d\n", listen_port); consecutive_failures = 0; // Reset failure counter on success - last_success = time(nullptr); + last_success = time(NULL); } else { @@ -195,10 +195,10 @@ int SocketToSerial(int listen_port, const char* pinpad_device) FD_SET(listen_fd, &in_fds); timeout.tv_sec = 0; timeout.tv_usec = 10; - reads = select(nfds, &in_fds, nullptr, nullptr, &timeout); + reads = select(nfds, &in_fds, NULL, NULL, &timeout); if (reads > 0) { - last_success = time(nullptr); // Update last success time + last_success = time(NULL); // Update last success time consecutive_failures = 0; // Reset failure counter on activity if (FD_ISSET(pinpad_fd, &in_fds)) @@ -246,7 +246,7 @@ int SocketToSerial(int listen_port, const char* pinpad_device) else { // Timeout - check if we've been idle too long - time_t now = time(nullptr); + time_t now = time(NULL); if (now - last_success > max_idle_time) { if (diagnostics) @@ -315,7 +315,7 @@ int SocketToSocket(int listen_port, const char* host, int port) FD_SET(listen_fd, &in_fds); timeout.tv_sec = 0; timeout.tv_usec = 10; - reads = select(nfds, &in_fds, nullptr, nullptr, &timeout); + reads = select(nfds, &in_fds, NULL, NULL, &timeout); if (reads > 0) { if (FD_ISSET(listen_fd, &in_fds)) @@ -500,10 +500,10 @@ int ProcessConnection(int serverfd, int pinpadfd) { timeout.tv_sec = check_interval; timeout.tv_usec = 0; - readies = select(nfds, &in_fds, nullptr, nullptr, &timeout); + readies = select(nfds, &in_fds, NULL, NULL, &timeout); } else - readies = select(nfds, &in_fds, nullptr, nullptr, nullptr); + readies = select(nfds, &in_fds, NULL, NULL, NULL); if (readies < 0) { perror("ProcessConnection select"); @@ -517,7 +517,7 @@ int ProcessConnection(int serverfd, int pinpadfd) readlen = ReadCmd(serverfd, buffer, STRLONG); if (readlen >= 0) { - lastserver = time(nullptr); + lastserver = time(NULL); // send to pinpad if (diagnostics) PrintRead("from Socket", buffer, readlen); @@ -547,7 +547,7 @@ int ProcessConnection(int serverfd, int pinpadfd) } else if (lastserver && time_limit) { // check for timeouts - now = time(nullptr); + now = time(NULL); if ((now - lastserver) > time_limit) retval = ERR_TIMEOUT; } diff --git a/src/utils/fntrace.hh b/src/utils/fntrace.hh index 7c7e37e8..916c19a2 100644 --- a/src/utils/fntrace.hh +++ b/src/utils/fntrace.hh @@ -34,6 +34,7 @@ class BackTraceFunction public: // Constructor BackTraceFunction(const char* func, const char* file, int line) + : recorded_entry_(false) { // Safety check: validate BT_Track is accessible before using it // This prevents crashes from memory corruption @@ -56,8 +57,8 @@ public: std::printf("Entering %s (%s:%d)\n", func, file, line); } } catch (...) { - // Log error but don't crash - prevents crashes when memory is corrupted - std::fprintf(stderr, "Warning: BackTraceFunction exception in %s (%s:%d)\n", func, file, line); + // Silently ignore errors from corrupted memory/atomic variables + // This prevents crashes when memory is corrupted } } @@ -74,14 +75,14 @@ public: } } } catch (...) { - // Log error but don't crash - prevents crashes when memory is corrupted - std::fprintf(stderr, "Warning: ~BackTraceFunction exception in destructor\n"); + // Silently ignore errors from corrupted memory/atomic variables + // This prevents crashes when memory is corrupted } } private: size_t get_current_memory_usage() noexcept; - bool recorded_entry_{false}; + bool recorded_entry_; }; #define FnTrace(func) BackTraceFunction _fn_start(func, __FILE__, __LINE__) diff --git a/src/utils/font_check.cc b/src/utils/font_check.cc index 0c065e62..c915ef97 100644 --- a/src/utils/font_check.cc +++ b/src/utils/font_check.cc @@ -222,7 +222,7 @@ void FontCheckDrawStringEnhanced(Display *display, XftDraw *xftdraw, XftFont *xf int main() { Display *display = XOpenDisplay(nullptr); if (!display) { - std::cerr << "Cannot open display" << '\n'; + std::cerr << "Cannot open display" << std::endl; return 1; } int screen = DefaultScreen(display); @@ -271,9 +271,9 @@ int main() { } // Print result to terminal if (success) { - std::cout << "\u2713 " << font_label << " (" << font_xft << ") - DISPLAYED" << '\n'; + std::cout << "\u2713 " << font_label << " (" << font_xft << ") - DISPLAYED" << std::endl; } else { - std::cout << "\u2717 " << font_label << " (" << font_xft << ") - FAILED" << '\n'; + std::cout << "\u2717 " << font_label << " (" << font_xft << ") - FAILED" << std::endl; } } if (draw) XftDrawDestroy(draw); diff --git a/src/utils/input_validation.hh b/src/utils/input_validation.hh index 26a0c657..db4b39ce 100644 --- a/src/utils/input_validation.hh +++ b/src/utils/input_validation.hh @@ -271,16 +271,16 @@ public: ValidationContext() = default; void set_severity_level(ValidationSeverity level) { severity_ = level; } - [[nodiscard]] ValidationSeverity get_severity_level() const { return severity_; } + ValidationSeverity get_severity_level() const { return severity_; } void add_error(const std::string& error) { errors_.push_back(error); } void add_warning(const std::string& warning) { warnings_.push_back(warning); } - [[nodiscard]] const std::vector& get_errors() const { return errors_; } - [[nodiscard]] const std::vector& get_warnings() const { return warnings_; } + const std::vector& get_errors() const { return errors_; } + const std::vector& get_warnings() const { return warnings_; } - [[nodiscard]] bool has_errors() const { return !errors_.empty(); } - [[nodiscard]] bool has_warnings() const { return !warnings_.empty(); } + bool has_errors() const { return !errors_.empty(); } + bool has_warnings() const { return !warnings_.empty(); } void clear() { errors_.clear(); @@ -386,7 +386,7 @@ public: #define VT_SANITIZE_OR_RETURN(input, sanitizer_func) \ { \ auto sanitized = sanitizer_func(input); \ - if (sanitized != (input)) { \ + if (sanitized != input) { \ return ValidationResult(true, "", sanitized); \ } \ } diff --git a/src/utils/modern_cpp_example.cc b/src/utils/modern_cpp_example.cc index b371a42d..6f5eeace 100644 --- a/src/utils/modern_cpp_example.cc +++ b/src/utils/modern_cpp_example.cc @@ -43,7 +43,7 @@ enum class ButtonType { }; void DemoLogging() { - std::cout << "\n=== Logging Demo ===" << '\n'; + std::cout << "\n=== Logging Demo ===" << std::endl; // Initialize logger vt::Logger::Initialize( @@ -68,11 +68,11 @@ void DemoLogging() { VT_LOG_INFO("This is a convenience macro"); VT_LOG_DEBUG("Debug value: {}", 100); - std::cout << "Check /tmp/viewtouch_demo/viewtouch.log for output" << '\n'; + std::cout << "Check /tmp/viewtouch_demo/viewtouch.log for output" << std::endl; } void DemoJson() { - std::cout << "\n=== JSON Config Demo ===" << '\n'; + std::cout << "\n=== JSON Config Demo ===" << std::endl; // Create a config file vt::JsonConfig cfg("/tmp/viewtouch_demo_config.json"); @@ -87,7 +87,7 @@ void DemoJson() { // Save to file if (cfg.Save()) { - std::cout << "Config saved to: " << cfg.GetPath() << '\n'; + std::cout << "Config saved to: " << cfg.GetPath() << std::endl; } // Load it back @@ -98,62 +98,62 @@ void DemoJson() { auto timeout = loaded.Get("network.timeout", 10); bool use_seats = loaded.Get("settings.use_seats", false); - std::cout << "Store: " << store << '\n'; - std::cout << "Food tax: " << tax << '\n'; - std::cout << "Timeout: " << timeout << "s" << '\n'; - std::cout << "Use seats: " << (use_seats ? "yes" : "no") << '\n'; + std::cout << "Store: " << store << std::endl; + std::cout << "Food tax: " << tax << std::endl; + std::cout << "Timeout: " << timeout << "s" << std::endl; + std::cout << "Use seats: " << (use_seats ? "yes" : "no") << std::endl; } // Create example config vt::JsonConfig::CreateExample("/tmp/viewtouch_example_config.json"); - std::cout << "Example config created at /tmp/viewtouch_example_config.json" << '\n'; + std::cout << "Example config created at /tmp/viewtouch_example_config.json" << std::endl; } void DemoEnums() { - std::cout << "\n=== Enum Utils Demo ===" << '\n'; + std::cout << "\n=== Enum Utils Demo ===" << std::endl; // Enum to string auto payment_name = vt::EnumToString(PaymentType::CreditCard); - std::cout << "Payment type: " << payment_name << '\n'; + std::cout << "Payment type: " << payment_name << std::endl; // String to enum auto payment = vt::StringToEnum("Cash"); if (payment) { - std::cout << "Parsed payment type: " << vt::EnumToString(*payment) << '\n'; + std::cout << "Parsed payment type: " << vt::EnumToString(*payment) << std::endl; } // Get all values - std::cout << "\nAll payment types:" << '\n'; + std::cout << "\nAll payment types:" << std::endl; for (auto type : vt::GetEnumValues()) { - std::cout << " - " << vt::EnumToString(type) << '\n'; + std::cout << " - " << vt::EnumToString(type) << std::endl; } // Get count - std::cout << "\nTotal payment types: " << vt::GetEnumCount() << '\n'; + std::cout << "\nTotal payment types: " << vt::GetEnumCount() << std::endl; // Display formatting - std::cout << "\nButton types (display format):" << '\n'; + std::cout << "\nButton types (display format):" << std::endl; for (auto btn : vt::GetEnumValues()) { - std::cout << " - " << vt::EnumToDisplayString(btn) << '\n'; + std::cout << " - " << vt::EnumToDisplayString(btn) << std::endl; } // Get pairs for UI dropdowns auto pairs = vt::GetEnumPairs(); - std::cout << "\nButton type pairs (for UI):" << '\n'; + std::cout << "\nButton type pairs (for UI):" << std::endl; for (const auto& [name, value] : pairs) { - std::cout << " " << name << " = " << vt::EnumToInt(value) << '\n'; + std::cout << " " << name << " = " << vt::EnumToInt(value) << std::endl; } // Backwards compatibility - C-style array const char** payment_names = vt::GetEnumNamesArray(); - std::cout << "\nC-style array (backwards compatible):" << '\n'; + std::cout << "\nC-style array (backwards compatible):" << std::endl; for (int i = 0; payment_names[i] != nullptr; ++i) { - std::cout << " [" << i << "] = " << payment_names[i] << '\n'; + std::cout << " [" << i << "] = " << payment_names[i] << std::endl; } } void DemoCombined() { - std::cout << "\n=== Combined Demo ===" << '\n'; + std::cout << "\n=== Combined Demo ===" << std::endl; // Use JSON config with enums and logging vt::JsonConfig cfg("/tmp/viewtouch_combined_demo.json"); @@ -175,14 +175,14 @@ void DemoCombined() { if (payment) { vt::Logger::info("Loaded payment type: {}", vt::EnumToString(*payment)); - std::cout << "Successfully parsed payment type from JSON" << '\n'; + std::cout << "Successfully parsed payment type from JSON" << std::endl; } } } int main() { - std::cout << "=== ViewTouch Modern C++ Libraries Demo ===" << '\n'; - std::cout << "Demonstrating spdlog, nlohmann/json, and magic_enum" << '\n'; + std::cout << "=== ViewTouch Modern C++ Libraries Demo ===" << std::endl; + std::cout << "Demonstrating spdlog, nlohmann/json, and magic_enum" << std::endl; try { DemoLogging(); @@ -190,14 +190,14 @@ int main() { DemoEnums(); DemoCombined(); - std::cout << "\n=== Demo Complete ===" << '\n'; - std::cout << "Check the /tmp directory for generated files" << '\n'; + std::cout << "\n=== Demo Complete ===" << std::endl; + std::cout << "Check the /tmp directory for generated files" << std::endl; // Cleanup vt::Logger::Shutdown(); } catch (const std::exception& e) { - std::cerr << "Error: " << e.what() << '\n'; + std::cerr << "Error: " << e.what() << std::endl; return 1; } diff --git a/src/utils/safe_string_utils.hh b/src/utils/safe_string_utils.hh index 28965602..f5f7657c 100644 --- a/src/utils/safe_string_utils.hh +++ b/src/utils/safe_string_utils.hh @@ -311,7 +311,7 @@ inline std::string safe_substring(const char* str, size_t start, size_t length = } if (length == 0) { - return {str + start}; + return std::string(str + start); } size_t end = start + length; @@ -319,7 +319,7 @@ inline std::string safe_substring(const char* str, size_t start, size_t length = end = str_len; } - return {str + start, end - start}; + return std::string(str + start, end - start); } /** diff --git a/src/utils/utility.cc b/src/utils/utility.cc index c6e27576..29a70193 100644 --- a/src/utils/utility.cc +++ b/src/utils/utility.cc @@ -104,7 +104,7 @@ int vt_setproctitle(const char* title) //int Str::nAllocated = 0; Str::Str() -= default; +{} Str::Str(const std::string &str) { @@ -118,7 +118,7 @@ Str::Str(const Str &s) // Destructor Str::~Str() -= default; +{} // Member Functions int Str::Clear() @@ -284,7 +284,8 @@ RegionInfo::RegionInfo(int rx, int ry, int rw, int rh) //Destructor RegionInfo::~RegionInfo() -= default; +{ +} // Member Functions int RegionInfo::Fit(int rx, int ry, int rw, int rh) @@ -347,22 +348,22 @@ int Price::Write(OutputDataFile &df, int version) const char* Price::Format(int sign) { - return nullptr; + return NULL; } const char* Price::Format(const char* buffer, int sign) { - return nullptr; + return NULL; } const char* Price::SimpleFormat() { - return nullptr; + return NULL; } const char* Price::SimpleFormat(const char* buffer) { - return nullptr; + return NULL; } diff --git a/src/utils/utility.hh b/src/utils/utility.hh index fb7e7e8f..7798cd38 100644 --- a/src/utils/utility.hh +++ b/src/utils/utility.hh @@ -46,13 +46,13 @@ int vt_setproctitle(const char* title); class InputDataFile; class OutputDataFile; -enum RenderResult : std::uint8_t +enum RenderResult { RENDER_OKAY, // render okay RENDER_ERROR // error in rendering }; -enum SignalResult : std::int8_t +enum SignalResult { SIGNAL_ERROR = -1, // error in processing signal SIGNAL_OKAY, // signal received @@ -86,24 +86,18 @@ public: bool Set(const Str &s) { data = s.data; return true; } bool Set(const Str *s) { return Set(s->Value()); } void ChangeAtoB(const char a, const char b); // character replace - [[nodiscard]] int IntValue() const; - [[nodiscard]] Flt FltValue() const; - [[nodiscard]] const char *Value() const noexcept; - [[nodiscard]] const char *c_str() const noexcept; - [[nodiscard]] std::string str() const noexcept; + int IntValue() const; + Flt FltValue() const; + const char *Value() const noexcept; + const char *c_str() const noexcept; + std::string str() const noexcept; const char* ValueSet(const char* set = nullptr); - [[nodiscard]] bool empty() const noexcept; - [[nodiscard]] size_t size() const noexcept; + bool empty() const noexcept; + size_t size() const noexcept; Str & operator = (const char* s) { Set(s); return *this; } - Str & operator = (const Str &s) { - if (this == &s) { - return *this; - } - Set(s); - return *this; - } + Str & operator = (const Str &s) { Set(s); return *this; } Str & operator = (const int s) { Set(s); return *this; } Str & operator = (const Flt s) { Set(s); return *this; } int operator > (const Str &s) const; @@ -231,7 +225,7 @@ std::string AdjustCaseAndSpacing(const std::string &str); int CompareList(const genericChar* val, const genericChar* list[], int unknown = -1); int CompareList(int val, int list[], int unknown = -1); -// compares val with each item in list (nullptr terminated or -1 terminated) +// compares val with each item in list (NULL terminated or -1 terminated) // returns index of match or 'unknown' for no match. int CompareListN(const genericChar* list[], const genericChar* str, int unknown = -1); @@ -239,7 +233,7 @@ int CompareListN(const genericChar* list[], const genericChar* str, int unknown // str="hello" will match list[0]="hello world". const char* FindStringByValue(int val, int val_list[], const genericChar* str_list[], - const genericChar* unknown = nullptr); + const genericChar* unknown = NULL); int FindValueByString(const genericChar* val, int val_list[], const genericChar* str_list[], int unknown = -1); // finds string by finding val index diff --git a/src/utils/vt_enum_utils.hh b/src/utils/vt_enum_utils.hh index 3910be73..1528c5d6 100644 --- a/src/utils/vt_enum_utils.hh +++ b/src/utils/vt_enum_utils.hh @@ -163,13 +163,12 @@ std::string EnumToDisplayString(E value) { for (size_t i = 0; i < name.size(); ++i) { if (name[i] == '_') { name[i] = ' '; - continue; // underscores fully handled + } else if (i == 0 || name[i-1] == ' ') { + // Capitalize first letter of each word + name[i] = static_cast(std::toupper(static_cast(name[i]))); + } else { + name[i] = static_cast(std::tolower(static_cast(name[i]))); } - - const bool word_start = (i == 0 || name[i - 1] == ' '); - name[i] = word_start - ? static_cast(std::toupper(static_cast(name[i]))) - : static_cast(std::tolower(static_cast(name[i]))); } return name; diff --git a/src/utils/vt_json_config.cc b/src/utils/vt_json_config.cc index b4c258e4..83a585b6 100644 --- a/src/utils/vt_json_config.cc +++ b/src/utils/vt_json_config.cc @@ -42,10 +42,10 @@ bool JsonConfig::Load() { loaded_ = true; return true; } catch (const json::parse_error& e) { - std::cerr << "JSON parse error in " << filepath_ << ": " << e.what() << '\n'; + std::cerr << "JSON parse error in " << filepath_ << ": " << e.what() << std::endl; return false; } catch (const std::exception& e) { - std::cerr << "Error loading JSON config " << filepath_ << ": " << e.what() << '\n'; + std::cerr << "Error loading JSON config " << filepath_ << ": " << e.what() << std::endl; return false; } } @@ -55,7 +55,7 @@ bool JsonConfig::Save(bool pretty_print, bool create_backup) { // Create backup if requested and file exists if (create_backup && std::filesystem::exists(filepath_)) { if (!CreateBackup()) { - std::cerr << "Warning: Could not create backup of " << filepath_ << '\n'; + std::cerr << "Warning: Could not create backup of " << filepath_ << std::endl; } } @@ -67,7 +67,7 @@ bool JsonConfig::Save(bool pretty_print, bool create_backup) { std::ofstream file(filepath_); if (!file.is_open()) { - std::cerr << "Error: Could not open " << filepath_ << " for writing" << '\n'; + std::cerr << "Error: Could not open " << filepath_ << " for writing" << std::endl; return false; } @@ -79,7 +79,7 @@ bool JsonConfig::Save(bool pretty_print, bool create_backup) { return true; } catch (const std::exception& e) { - std::cerr << "Error saving JSON config " << filepath_ << ": " << e.what() << '\n'; + std::cerr << "Error saving JSON config " << filepath_ << ": " << e.what() << std::endl; return false; } } @@ -162,7 +162,7 @@ bool JsonConfig::CreateExample(std::string_view filepath) { file << example.dump(4); return true; } catch (const std::exception& e) { - std::cerr << "Error creating example config: " << e.what() << '\n'; + std::cerr << "Error creating example config: " << e.what() << std::endl; return false; } } @@ -195,7 +195,7 @@ bool JsonConfig::CreateBackup() const { ); return true; } catch (const std::exception& e) { - std::cerr << "Backup error: " << e.what() << '\n'; + std::cerr << "Backup error: " << e.what() << std::endl; return false; } } diff --git a/src/utils/vt_json_config.hh b/src/utils/vt_json_config.hh index 38474b76..e1d958cd 100644 --- a/src/utils/vt_json_config.hh +++ b/src/utils/vt_json_config.hh @@ -78,7 +78,7 @@ public: * @return The value or default */ template - [[nodiscard]] [[nodiscard]] T Get(std::string_view key, const T& default_value = T{}) const { + T Get(std::string_view key, const T& default_value = T{}) const { try { auto keys = SplitKey(key); const json* current = &data_; @@ -121,7 +121,7 @@ public: /** * @brief Check if a key exists */ - [[nodiscard]] bool Has(std::string_view key) const; + bool Has(std::string_view key) const; /** * @brief Remove a key from the config @@ -132,17 +132,17 @@ public: * @brief Get direct access to underlying JSON object */ json& Data() { return data_; } - [[nodiscard]] const json& Data() const { return data_; } + const json& Data() const { return data_; } /** * @brief Get the file path */ - [[nodiscard]] const std::string& GetPath() const { return filepath_; } + const std::string& GetPath() const { return filepath_; } /** * @brief Check if config was loaded successfully */ - [[nodiscard]] bool IsLoaded() const { return loaded_; } + bool IsLoaded() const { return loaded_; } /** * @brief Clear all data @@ -169,7 +169,7 @@ private: /** * @brief Create backup of config file */ - [[nodiscard]] bool CreateBackup() const; + bool CreateBackup() const; }; /** diff --git a/src/utils/vt_logger.cc b/src/utils/vt_logger.cc index e7f96152..e66847d7 100644 --- a/src/utils/vt_logger.cc +++ b/src/utils/vt_logger.cc @@ -37,7 +37,6 @@ namespace vt { // Static member initialization std::shared_ptr Logger::logger_ = nullptr; -std::shared_ptr Logger::structured_logger_ = nullptr; bool Logger::initialized_ = false; thread_local std::optional Logger::current_business_context_; @@ -67,33 +66,22 @@ void Logger::Initialize( // Create multiple sinks for different outputs std::vector sinks; - std::string logdir_str(log_dir); - bool test_logs = (logdir_str.find("viewtouch_test_logs") != std::string::npos); - - // 1. File sink - spdlog::sink_ptr file_sink; - if (test_logs) { - // Use basic file sink in tests for simplicity - file_sink = std::make_shared( - logdir_str + "/viewtouch.log", true /* truncate */); - } else { - // Rotating file sink (10MB files, max 5 files) - file_sink = std::make_shared( - logdir_str + "/viewtouch.log", - 1024 * 1024 * 10, // 10MB per file - 5 // Keep 5 files max - ); - } + // 1. Rotating file sink (10MB files, max 5 files) + auto file_sink = std::make_shared( + std::string(log_dir) + "/viewtouch.log", + 1024 * 1024 * 10, // 10MB per file + 5 // Keep 5 files max + ); file_sink->set_level(spdlog::level::trace); // Capture everything in file sinks.push_back(file_sink); // 2. Structured JSON log file for analysis auto json_sink = std::make_shared( - logdir_str + "/viewtouch_structured.log", false /* don't truncate - append instead */ + std::string(log_dir) + "/viewtouch_structured.log" ); json_sink->set_level(spdlog::level::info); - // JSON pattern for structured logging - just output the raw message - json_sink->set_pattern("%v"); + // JSON pattern for structured logging + json_sink->set_pattern(""); sinks.push_back(json_sink); // 3. Console sink (colored output) @@ -119,47 +107,19 @@ void Logger::Initialize( syslog_sink->set_level(spdlog::level::info); sinks.push_back(syslog_sink); } catch (const std::exception& e) { - std::cerr << "Warning: Could not initialize syslog sink: " << e.what() << '\n'; + std::cerr << "Warning: Could not initialize syslog sink: " << e.what() << std::endl; } } - // Create loggers: use synchronous mode for test log directory to avoid async timing issues - bool use_async = (test_logs == false); - - // Main logger (all sinks except JSON) - std::vector main_sinks; - for (auto& sink : sinks) { - if (sink != json_sink) { - main_sinks.push_back(sink); - } - } - - if (use_async) { - spdlog::init_thread_pool(8192, 1); - logger_ = std::make_shared( - "ViewTouch", - main_sinks.begin(), - main_sinks.end(), - spdlog::thread_pool(), - spdlog::async_overflow_policy::block - ); - } else { - logger_ = std::make_shared("ViewTouch", main_sinks.begin(), main_sinks.end()); - } - - // Structured logger (JSON sink only) - always synchronous for tests, async for production - if (use_async) { - structured_logger_ = std::make_shared( - "ViewTouch_Structured", - json_sink, - spdlog::thread_pool(), - spdlog::async_overflow_policy::block - ); - } else { - structured_logger_ = std::make_shared("ViewTouch_Structured", json_sink); - } - structured_logger_->set_level(spdlog::level::info); - structured_logger_->flush_on(spdlog::level::info); // Flush immediately for test readers + // Create async logger with thread pool + spdlog::init_thread_pool(8192, 1); // Queue size, thread count + logger_ = std::make_shared( + "ViewTouch", + sinks.begin(), + sinks.end(), + spdlog::thread_pool(), + spdlog::async_overflow_policy::block + ); // Set log pattern: [2025-01-20 14:30:45.123] [info] [pid:12345] Message logger_->set_pattern("[%Y-%m-%d %H:%M:%S.%e] [%^%l%$] [pid:%P] %v"); @@ -184,9 +144,8 @@ void Logger::Initialize( // Register as default logger spdlog::set_default_logger(logger_); - // Flush on info or higher so structured JSON messages are immediately - // available to external readers (tests read files immediately). - logger_->flush_on(spdlog::level::info); + // Flush on warning or higher + logger_->flush_on(spdlog::level::warn); initialized_ = true; @@ -195,7 +154,7 @@ void Logger::Initialize( logger_->info("Log level: {}", log_level); } catch (const std::exception& e) { - std::cerr << "Failed to initialize logging system: " << e.what() << '\n'; + std::cerr << "Failed to initialize logging system: " << e.what() << std::endl; // Fall back to basic console logger logger_ = spdlog::stdout_color_mt("ViewTouch"); initialized_ = true; @@ -206,13 +165,7 @@ void Logger::Shutdown() { if (logger_) { logger_->info("Shutting down logging system"); logger_->flush(); - if (structured_logger_) { - structured_logger_->flush(); - } - // Drop all loggers to release file handles - spdlog::drop_all(); - logger_.reset(); - structured_logger_.reset(); + spdlog::shutdown(); } initialized_ = false; } @@ -238,15 +191,6 @@ void Logger::SetLevel(std::string_view level) { void Logger::Flush() { if (logger_) { logger_->flush(); - for (auto &s : logger_->sinks()) { - s->flush(); - } - } - if (structured_logger_) { - structured_logger_->flush(); - for (auto &s : structured_logger_->sinks()) { - s->flush(); - } } } @@ -283,14 +227,6 @@ LogEvent& LogEvent::add(std::string_view key, std::string_view value) { return *this; } -LogEvent& LogEvent::add(std::string_view key, const char* value) { - if (value) - metadata[std::string(key)] = std::string(value); - else - metadata[std::string(key)] = std::string(""); - return *this; -} - LogEvent& LogEvent::add(std::string_view key, int value) { metadata[std::string(key)] = value; return *this; @@ -315,10 +251,7 @@ nlohmann::json LogEvent::to_json() const { nlohmann::json j; j["event_type"] = event_type; j["message"] = message; - { - auto sv = spdlog::level::to_string_view(level); - j["level"] = std::string(sv.data(), sv.size()); - } + j["level"] = spdlog::level::to_string_view(level); j["timestamp"] = std::chrono::duration_cast( timestamp.time_since_epoch()).count(); @@ -341,11 +274,8 @@ void Logger::log_event(const LogEvent& event) { auto logger = GetLogger(); if (!logger) return; - // Log structured JSON to dedicated JSON logger - if (structured_logger_) { - structured_logger_->log(event.level, "{}", event.to_json().dump()); - structured_logger_->flush(); - } + // Log structured JSON to dedicated sink + logger->log(event.level, "{}", event.to_json().dump()); // Also log human-readable version to regular logs std::string readable_msg = event.event_type; diff --git a/src/utils/vt_logger.hh b/src/utils/vt_logger.hh index 2905c9c9..dc8a5a55 100644 --- a/src/utils/vt_logger.hh +++ b/src/utils/vt_logger.hh @@ -54,7 +54,7 @@ struct BusinessContext { std::optional start_time; // Convert to JSON for structured logging - [[nodiscard]] nlohmann::json to_json() const; + nlohmann::json to_json() const; }; /** @@ -73,7 +73,6 @@ struct LogEvent { // Add metadata LogEvent& add(std::string_view key, std::string_view value); - LogEvent& add(std::string_view key, const char* value); // ensure const char* selects string, not bool LogEvent& add(std::string_view key, int value); LogEvent& add(std::string_view key, double value); LogEvent& add(std::string_view key, bool value); @@ -224,7 +223,6 @@ public: private: static std::shared_ptr logger_; - static std::shared_ptr structured_logger_; static bool initialized_; static thread_local std::optional current_business_context_; }; diff --git a/term/layer.cc b/term/layer.cc index 3d7bed10..a35e06cd 100644 --- a/term/layer.cc +++ b/term/layer.cc @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -36,8 +36,8 @@ Layer::Layer(Display *d, GC g, Window draw_win, int lw, int lh) gfx = g; win = draw_win; pix = XCreatePixmap(dis, draw_win, lw, lh, DefaultDepth(d, no)); - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; id = 0; offset_x = 0; offset_y = 0; @@ -80,7 +80,7 @@ Layer::Layer(Layer&& other) noexcept , offset_x(other.offset_x) , offset_y(other.offset_y) , window_frame(other.window_frame) - , window_title(other.window_title) + , window_title(std::move(other.window_title)) , pix(other.pix) , dis(other.dis) , win(other.win) @@ -101,7 +101,7 @@ Layer::Layer(Layer&& other) noexcept , max(other.max) , clip(other.clip) , use_clip(other.use_clip) - , page_title(other.page_title) + , page_title(std::move(other.page_title)) , buttons(std::move(other.buttons)) , xftdraw(other.xftdraw) { @@ -132,7 +132,7 @@ Layer& Layer::operator=(Layer&& other) noexcept offset_x = other.offset_x; offset_y = other.offset_y; window_frame = other.window_frame; - window_title = other.window_title; + window_title = std::move(other.window_title); pix = other.pix; dis = other.dis; win = other.win; @@ -153,7 +153,7 @@ Layer& Layer::operator=(Layer&& other) noexcept max = other.max; clip = other.clip; use_clip = other.use_clip; - page_title = other.page_title; + page_title = std::move(other.page_title); buttons = std::move(other.buttons); xftdraw = other.xftdraw; @@ -441,22 +441,22 @@ int Layer::TitleBar() } else { - if (title_mode == ToInt(OperationMode::OpMacro)) + if (title_mode == MODE_MACRO) { Text("** RECORDING MACRO **", 21, page_w / 2, 6, c2, FONT_TIMES_20B, ALIGN_CENTER); } - else if (title_mode == ToInt(OperationMode::OpTraining)) + else if (title_mode == MODE_TRAINING) { Text("** TRAINING MODE **", 19, page_w / 2, 6, c2, FONT_TIMES_20B, ALIGN_CENTER); } - else if (title_mode == ToInt(OperationMode::OpTranslate)) + else if (title_mode == MODE_TRANSLATE) { Text("** TRANSLATION MODE **", 22, page_w / 2, 6, c2, FONT_TIMES_20B, ALIGN_CENTER); } - else if (title_mode == ToInt(OperationMode::OpEdit)) + else if (title_mode == MODE_EDIT) { Text("** EDIT MODE **", 15, page_w / 2, 6, c2, FONT_TIMES_20B, ALIGN_CENTER); @@ -668,7 +668,7 @@ int Layer::ZoneText(const char* str, int tx, int ty, int tw, int th, Text(sub_string[i], sub_length[i], sx, sy, color, font, align, 0, embossed); sy += font_h; } - if (*c && line >= max_lines && title_mode == ToInt(OperationMode::OpEdit)) + if (*c && line >= max_lines && title_mode == MODE_EDIT) Text("!", 1, tx, ty, COLOR_RED, FONT_TIMES_24, ALIGN_LEFT, 0, embossed); return 0; } @@ -879,7 +879,7 @@ int Layer::DrawPixmap(int rx, int ry, int rw, int rh, const char* filename) XPutPixel(scaled_mask_img, x, y, mask_pixel); } } - GC mask_gc = XCreateGC(dis, scaled_mask, 0, nullptr); + GC mask_gc = XCreateGC(dis, scaled_mask, 0, NULL); XPutImage(dis, scaled_mask, mask_gc, scaled_mask_img, 0, 0, 0, 0, draw_w, draw_h); XFreeGC(dis, mask_gc); XDestroyImage(scaled_mask_img); @@ -1870,7 +1870,7 @@ int Layer::MouseAction(LayerList *ll, int mx, int my, int code) return 0; } - WInt8(ToInt(ServerProtocol::SrvMouse)); + WInt8(SERVER_MOUSE); WInt16(id); WInt8(code); WInt16(mx - page_x); @@ -1882,7 +1882,7 @@ int Layer::Touch(LayerList *ll, int tx, int ty) { FnTrace("Layer::Touch()"); - WInt8(ToInt(ServerProtocol::SrvTouch)); + WInt8(SERVER_TOUCH); WInt16(id); WInt16(tx - page_x); WInt16(ty - page_y); @@ -1893,7 +1893,7 @@ int Layer::Keyboard(LayerList *ll, genericChar key, int code, int state) { FnTrace("Layer::Keyboard()"); - WInt8(ToInt(ServerProtocol::SrvKey)); + WInt8(SERVER_KEY); WInt16(id); WInt16(key); WInt32(code); @@ -1908,15 +1908,15 @@ LayerList::LayerList() { FnTrace("LayerList::LayerList()"); - dis = nullptr; - gfx = nullptr; + dis = NULL; + gfx = 0; win = 0; select_on = 0; select_x1 = 0; select_y1 = 0; select_x2 = 0; select_y2 = 0; - drag = nullptr; + drag = NULL; drag_x = 0; drag_y = 0; mouse_x = 0; @@ -1924,8 +1924,8 @@ LayerList::LayerList() screen_blanked = 0; active_frame_color = COLOR_DK_RED; inactive_frame_color = COLOR_DK_BLUE; - last_object = nullptr; - last_layer = nullptr; + last_object = NULL; + last_layer = NULL; } // Member Functions @@ -1945,7 +1945,7 @@ int LayerList::Add(Layer *l, int update) { FnTrace("LayerList::Add()"); - if (l == nullptr) + if (l == NULL) return 1; list.AddToTail(l); @@ -1965,7 +1965,7 @@ int LayerList::Remove(Layer *l, int update) { FnTrace("LayerList::Remove()"); - if (l == nullptr) + if (l == NULL) return 1; // check to see if layer was in active list @@ -1993,7 +1993,7 @@ int LayerList::Remove(Layer *l, int update) UpdateArea(l->x, l->y, l->w, l->h); if (last_layer == l) { - last_object = nullptr; + last_object = NULL; last_layer = FindByPoint(mouse_x, mouse_y); if (last_layer) last_layer->MouseEnter(this); @@ -2018,7 +2018,7 @@ Layer *LayerList::FindByPoint(int x, int y) if (auto result = FindByPointOptional(x, y)) return &result->get(); - return nullptr; + return NULL; } Layer *LayerList::FindByID(int id) @@ -2028,7 +2028,7 @@ Layer *LayerList::FindByID(int id) if (auto result = FindByIDOptional(id)) return &result->get(); - return nullptr; + return NULL; } // Modern versions using std::optional @@ -2036,7 +2036,7 @@ std::optional> LayerList::FindByPointOptional(int { FnTrace("LayerList::FindByPointOptional()"); - for (Layer *l = list.Tail(); l != nullptr; l = l->fore) + for (Layer *l = list.Tail(); l != NULL; l = l->fore) { if (l->IsPointIn(x, y)) return *l; @@ -2049,11 +2049,11 @@ std::optional> LayerList::FindByIDOptional(int id) { FnTrace("LayerList::FindByIDOptional()"); - for (Layer *l = list.Head(); l != nullptr; l = l->next) + for (Layer *l = list.Head(); l != NULL; l = l->next) if (l->id == id) return *l; - for (Layer *l = inactive.Head(); l != nullptr; l = l->next) + for (Layer *l = inactive.Head(); l != NULL; l = l->next) if (l->id == id) return *l; @@ -2066,7 +2066,7 @@ int LayerList::SetScreenBlanker(int set) if (set == screen_blanked) return 1; - drag = nullptr; + drag = NULL; screen_blanked = set; if (set) ShowCursor(CURSOR_BLANK); @@ -2099,7 +2099,7 @@ int LayerList::UpdateAll(int select_all) } Layer *l = list.Head(); - if (l == nullptr) + if (l == NULL) return 0; if (select_all) @@ -2129,7 +2129,7 @@ int LayerList::UpdateAll(int select_all) OptimalUpdateArea(0, p3, WinWidth, WinHeight - p3, next_layer); } - for (l = list.Head(); l != nullptr; l = l->next) + for (l = list.Head(); l != NULL; l = l->next) l->update = 0; return 0; } @@ -2148,7 +2148,7 @@ int LayerList::UpdateArea(int ax, int ay, int aw, int ah) return 0; } - for (l = list.Head(); l != nullptr; l = l->next) + for (l = list.Head(); l != NULL; l = l->next) { if (l->Overlap(ax, ay, aw, ah)) l->update = 1; @@ -2156,7 +2156,7 @@ int LayerList::UpdateArea(int ax, int ay, int aw, int ah) OptimalUpdateArea(ax, ay, aw, ah); - for (l = list.Head(); l != nullptr; l = l->next) + for (l = list.Head(); l != NULL; l = l->next) l->update = 0; return 0; } @@ -2177,7 +2177,7 @@ int LayerList::OptimalUpdateArea(int ax, int ay, int aw, int ah, Layer *end) break; l = l->fore; } - if (l == nullptr) + if (l == NULL) return 0; RegionInfo r; @@ -2189,7 +2189,7 @@ int LayerList::OptimalUpdateArea(int ax, int ay, int aw, int ah, Layer *end) } Layer *next_layer = l->fore; - if (next_layer == nullptr) + if (next_layer == NULL) return 0; int p0 = l->x; @@ -2301,7 +2301,7 @@ int LayerList::MouseAction(int x, int y, int code) if (!(code & (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE)) || (code & MOUSE_RELEASE)) { - drag = nullptr; + drag = NULL; } if (drag) { @@ -2325,11 +2325,11 @@ int LayerList::MouseAction(int x, int y, int code) } Layer *l = FindByPoint(x, y); - if (l == nullptr) + if (l == NULL) { - drag = nullptr; - last_layer = nullptr; - last_object = nullptr; + drag = NULL; + last_layer = NULL; + last_object = NULL; return 0; } @@ -2339,7 +2339,7 @@ int LayerList::MouseAction(int x, int y, int code) { // Object mouse focus has changed last_object->MouseExit(this, last_layer); - last_object = nullptr; + last_object = NULL; } if (last_layer != l) @@ -2354,7 +2354,7 @@ int LayerList::MouseAction(int x, int y, int code) last_layer = l; } - if ((code & MOUSE_PRESS) && (l->window_frame & ToInt(WindowFrame::FrameMove))) + if ((code & MOUSE_PRESS) && l->window_frame & WINFRAME_MOVE) { RegionInfo r(l->x, l->y, l->w, 30); if (r.IsPointIn(x, y)) @@ -2372,7 +2372,7 @@ int LayerList::DragLayer(int x, int y) { FnTrace("LayerList::DragLayer()"); - if (drag == nullptr) + if (drag == NULL) return 1; if (x < 0) @@ -2493,8 +2493,8 @@ LayerObject::LayerObject() { FnTrace("LayerObject::LayerObject()"); - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; hilight = 0; select = 0; id = 0; @@ -2566,10 +2566,10 @@ LayerObject *LayerObjectList::FindByID(int id) { FnTrace("LayerObjectList::FindByID()"); - for (LayerObject *l = list.Tail(); l != nullptr; l = l->fore) + for (LayerObject *l = list.Tail(); l != NULL; l = l->fore) if (l->id == id) return l; - return nullptr; + return NULL; } LayerObject *LayerObjectList::FindByPoint(int x, int y) @@ -2578,7 +2578,7 @@ LayerObject *LayerObjectList::FindByPoint(int x, int y) if (auto result = FindByPointOptional(x, y)) return &result->get(); - return nullptr; + return NULL; } // Modern versions using std::optional @@ -2586,7 +2586,7 @@ std::optional> LayerObjectList::FindByIDOpti { FnTrace("LayerObjectList::FindByIDOptional()"); - for (LayerObject *l = list.Tail(); l != nullptr; l = l->fore) + for (LayerObject *l = list.Tail(); l != NULL; l = l->fore) if (l->id == id) return *l; @@ -2597,7 +2597,7 @@ std::optional> LayerObjectList::FindByPointO { FnTrace("LayerObjectList::FindByPointOptional()"); - for (LayerObject *l = list.Tail(); l != nullptr; l = l->fore) + for (LayerObject *l = list.Tail(); l != NULL; l = l->fore) { if (l->IsPointIn(x, y)) { @@ -2612,7 +2612,7 @@ int LayerObjectList::Render(Layer *l) { FnTrace("LayerObjectList::Render()"); - for (LayerObject *lo = list.Head(); lo != nullptr; lo = lo->next) + for (LayerObject *lo = list.Head(); lo != NULL; lo = lo->next) lo->Render(l); return 0; } @@ -2621,7 +2621,7 @@ int LayerObjectList::Layout(Layer *l) { FnTrace("LayerObjectList::Layout()"); - for (LayerObject *lo = list.Head(); lo != nullptr; lo = lo->next) + for (LayerObject *lo = list.Head(); lo != NULL; lo = lo->next) lo->Layout(l); return 0; } @@ -2700,7 +2700,7 @@ int LO_PushButton::Command(Layer *l) { FnTrace("LO_PushButton::Command()"); - WInt8(ToInt(ServerProtocol::SrvButtonPress)); + WInt8(SERVER_BUTTONPRESS); WInt16(l->id); WInt16(id); return SendNow(); diff --git a/term/layer.hh b/term/layer.hh index a93ac693..8c991b6b 100644 --- a/term/layer.hh +++ b/term/layer.hh @@ -232,7 +232,7 @@ public: // redraws all layers (only layers with update flag if select_all = 0) int UpdateArea(int x, int y, int w, int h); // redraws all layers in region - int OptimalUpdateArea(int x, int y, int w, int h, Layer *end = nullptr); + int OptimalUpdateArea(int x, int y, int w, int h, Layer *end = NULL); // redraws all layers with update flag set in region int RubberBandOff(); int RubberBandUpdate(int x, int y); diff --git a/term/term_credit.cc b/term/term_credit.cc index 4f9925af..a06b7cc1 100644 --- a/term/term_credit.cc +++ b/term/term_credit.cc @@ -27,8 +27,8 @@ ********************************************************************/ -#include -#include +#include +#include #include #include #include diff --git a/term/term_credit_cheq.cc b/term/term_credit_cheq.cc index 1e61cd9d..07fb67de 100644 --- a/term/term_credit_cheq.cc +++ b/term/term_credit_cheq.cc @@ -19,11 +19,11 @@ * keeping them in vt_term ensures that only the local terminal will be locked. */ -#include +#include #include -#include -#include -#include +#include +#include +#include #include #include #include @@ -96,7 +96,7 @@ int my_connect(int sockfd, struct sockaddr *serv_addr, socklen_t addrlen, int ti writeset = readset; timev.tv_sec = timeout; timev.tv_usec = 0; - result = select(sockfd + 1, &readset, &writeset, nullptr, &timev); + result = select(sockfd + 1, &readset, &writeset, NULL, &timev); if (FD_ISSET(sockfd, &readset) || FD_ISSET(sockfd, &writeset)) retval = 0; else @@ -1112,7 +1112,7 @@ int CCard::ReadCheq(const char* buffer_param, int buffsize) FD_SET(ipconn, &readfd); timeout.tv_sec = 0; timeout.tv_usec = 50; - selresult = select(nfds, &readfd, nullptr, nullptr, &timeout); + selresult = select(nfds, &readfd, NULL, NULL, &timeout); if (selresult > 0) { counter = 0; @@ -1306,14 +1306,14 @@ int CCard::BatchSettle() { ParseResponse(buffer); binfo.ParseResults(receipt); - WInt8(ToInt(ServerProtocol::SrvCcSettled)); + WInt8(SERVER_CC_SETTLED); binfo.Write(); retval = 0; } } if (retval) - WInt8(ToInt(ServerProtocol::SrvCcSettleFailed)); + WInt8(SERVER_CC_SETTLEFAILED); SendNow(); return retval; @@ -1334,7 +1334,7 @@ int CCard::CCInit() if (ReadCheq(buffer, STRHUGE) == 0) { ParseResponse(buffer); - WInt8(ToInt(ServerProtocol::SrvCcInit)); + WInt8(SERVER_CC_INIT); WStr(termid); WStr(code); WInt8(intcode); @@ -1363,7 +1363,7 @@ int CCard::Totals() { ParseResponse(buffer); binfo.ParseResults(receipt); - WInt8(ToInt(ServerProtocol::SrvCcTotals)); + WInt8(SERVER_CC_TOTALS); binfo.Write(); SendNow(); } @@ -1387,7 +1387,7 @@ int CCard::Details() if (ReadCheq(buffer, STRHUGE) == 0) { ParseResponse(buffer); - WInt8(ToInt(ServerProtocol::SrvCcDetails)); + WInt8(SERVER_CC_DETAILS); WStr(termid); WStr(code); WInt8(intcode); @@ -1415,7 +1415,7 @@ int CCard::ClearSAF() { if (safclear.ParseSAF(buffer) == 0) { - WInt8(ToInt(ServerProtocol::SrvCcSafCleared)); + WInt8(SERVER_CC_SAFCLEARED); safclear.Write(); retval = 0; } @@ -1423,7 +1423,7 @@ int CCard::ClearSAF() } if (retval) - WInt8(ToInt(ServerProtocol::SrvCcSafClearFailed)); + WInt8(SERVER_CC_SAFCLEARFAILED); SendNow(); @@ -1447,7 +1447,7 @@ int CCard::SAFDetails() { if (safclear.ParseSAF(buffer) == 0) { - WInt8(ToInt(ServerProtocol::SrvCcSafDetails)); + WInt8(SERVER_CC_SAFDETAILS); safclear.Write(); SendNow(); } diff --git a/term/term_credit_mcve.cc b/term/term_credit_mcve.cc index a4142b91..91283af9 100644 --- a/term/term_credit_mcve.cc +++ b/term/term_credit_mcve.cc @@ -442,7 +442,7 @@ int BatchInfo::GetAmt(char* dest, const char* value) ********************************************************************/ CCard::CCard() { - conn = nullptr; + conn = NULL; trans_success = 0; intcode = CC_STATUS_NONE; @@ -570,9 +570,9 @@ int CCard::Connect() if (server[0] != '\0' && port[0] != '\0') { - if (conn == nullptr) + if (conn == NULL) conn = new MCVE_CONN; - MCVE_InitEngine(nullptr); + MCVE_InitEngine(NULL); MCVE_InitConn(conn); if (MCVE_SetIP(conn, server, atoi(port))) { @@ -588,7 +588,7 @@ int CCard::Connect() intcode = CC_STATUS_NOCONNECT; MCVE_DestroyConn(conn); MCVE_DestroyEngine(); - conn = nullptr; + conn = NULL; } } } @@ -601,13 +601,13 @@ int CCard::Close() FnTrace("CCard::Close()"); int retval = 1; - if (conn != nullptr) + if (conn != NULL) { vt_safe_string::safe_copy(code, STRLENGTH, GlobalTranslate("NOCONN")); intcode = CC_STATUS_NOCONNECT; MCVE_DestroyConn(conn); MCVE_DestroyEngine(); - conn = nullptr; + conn = NULL; retval = 0; } @@ -620,7 +620,7 @@ int CCard::SetValue(char* dest, const char* source) int retval = 0; dest[0] = '\0'; - if (source != nullptr) + if (source != NULL) vt_safe_string::safe_copy(dest, STRLENGTH, source); return retval; @@ -772,7 +772,7 @@ int CCard::SetFields(int gut, long identifier) MCVE_DestroyConn(conn); - conn = nullptr; + conn = NULL; } else retval = 1; @@ -1006,7 +1006,7 @@ int CCard::BatchSettle() if (TransSendSimple(identifier) == 0) { binfo.ParseResults(conn, identifier); - WInt8(ToInt(ServerProtocol::SrvCcSettled)); + WInt8(SERVER_CC_SETTLED); binfo.Write(); retval = 0; } @@ -1015,8 +1015,8 @@ int CCard::BatchSettle() if (retval) { - WInt8(ToInt(ServerProtocol::SrvCcSettleFailed)); - if (conn != nullptr) + WInt8(SERVER_CC_SETTLEFAILED); + if (conn != NULL) { SetValue(msgbuff, MCVE_TransactionText(conn, identifier)); if (strlen(msgbuff) < 1) @@ -1075,7 +1075,7 @@ int CCard::Totals() if (MCVE_ParseCommaDelimited(conn, identifier)) { rows = MCVE_NumRows(conn, identifier); - WInt8(ToInt(ServerProtocol::SrvCcTotals)); + WInt8(SERVER_CC_TOTALS); WInt16(rows + 1); columns = MCVE_NumColumns(conn, identifier); buffer[0] = '\0'; @@ -1165,7 +1165,7 @@ int CCard::Details() { rows = MCVE_NumRows(conn, identifier); columns = MCVE_NumColumns(conn, identifier); - WInt8(ToInt(ServerProtocol::SrvCcDetails)); + WInt8(SERVER_CC_DETAILS); WInt16(rows + 1); buffer[0] = '\0'; AppendString(buffer, 8, GlobalTranslate("TTID")); diff --git a/term/term_dialog.cc b/term/term_dialog.cc index 28ebe6d0..7f94cf27 100644 --- a/term/term_dialog.cc +++ b/term/term_dialog.cc @@ -91,7 +91,7 @@ Widget AddLine(Widget parent) } int AddButtons(Widget parent, XtCallbackProc okay_cb, XtCallbackProc delete_cb, - XtCallbackProc cancel_cb, void *client_data = nullptr) + XtCallbackProc cancel_cb, void *client_data = NULL) { Widget f = XtVaCreateWidget("form", xmFormWidgetClass, parent, XmNleftAttachment, XmATTACH_WIDGET, @@ -141,8 +141,8 @@ int AddButtons(Widget parent, XtCallbackProc okay_cb, XtCallbackProc delete_cb, DialogEntry::DialogEntry() { - container = nullptr; - entry = nullptr; + container = 0; + entry = 0; } // Member Functions @@ -253,7 +253,7 @@ DialogMenu::DialogMenu() DialogMenu::~DialogMenu() { - container = nullptr; + container = NULL; } // Member Functions @@ -278,7 +278,7 @@ int DialogMenu::Init(Widget parent, const char* label, const char* *option_name, { const char* name; - if (container == nullptr) + if (container == NULL) { container = XtVaCreateWidget("form", xmFormWidgetClass, parent, @@ -422,7 +422,8 @@ DialogDoubleMenu::DialogDoubleMenu() } DialogDoubleMenu::~DialogDoubleMenu() -= default; +{ +} // Member Functions int DialogDoubleMenu::Init(Widget parent, const char* label, @@ -581,28 +582,28 @@ int DialogDoubleMenu::Value(int &v1, int &v2) // Callback Functions void EP_OkayCB(Widget /*widget*/, XtPointer client_data, XtPointer /*call_data*/) { - auto *d = static_cast(client_data); + PageDialog *d = static_cast(client_data); d->Close(); d->Send(); } void EP_DeleteCB(Widget /*widget*/, XtPointer client_data, XtPointer /*call_data*/) { - auto *d = static_cast(client_data); + PageDialog *d = static_cast(client_data); d->Close(); - WInt8(ToInt(ServerProtocol::SrvKillPage)); + WInt8(SERVER_KILLPAGE); SendNow(); } void EP_CancelCB(Widget /*widget*/, XtPointer client_data, XtPointer /*call_data*/) { - auto *d = static_cast(client_data); + PageDialog *d = static_cast(client_data); d->Close(); } void EP_TypeCB(Widget /*widget*/, XtPointer client_data, XtPointer /*call_data*/) { - auto *d = static_cast(client_data); + PageDialog *d = static_cast(client_data); int new_type = 0; if (d->full_edit) new_type = d->type.Value(); @@ -749,7 +750,7 @@ int PageDialog::Close() int PageDialog::Send() { int tmp, v1, v2; - WInt8(ToInt(ServerProtocol::SrvPageData)); + WInt8(SERVER_PAGEDATA); WInt8(size.Value()); WInt8(page_type); WStr(name.Value()); @@ -785,14 +786,14 @@ int PageDialog::Send() // Callback Functions void DP_OkayCB(Widget /*widget*/, XtPointer client_data, XtPointer /*call_data*/) { - auto *d = static_cast(client_data); + DefaultDialog *d = static_cast(client_data); d->Close(); d->Send(); } void DP_CancelCB(Widget widget, XtPointer client_data, XtPointer call_data) { - auto *d = static_cast(client_data); + DefaultDialog *d = static_cast(client_data); d->Close(); } @@ -837,7 +838,7 @@ DefaultDialog::DefaultDialog(Widget parent) default_shadow.Init(w, "Global Button Shadow Intensity", PageShadowName, PageShadowValue); AddLine(w); - AddButtons(w, DP_OkayCB, nullptr, DP_CancelCB, this); + AddButtons(w, DP_OkayCB, NULL, DP_CancelCB, this); XtManageChild(w); } @@ -890,7 +891,7 @@ int DefaultDialog::Close() int DefaultDialog::Send() { int tmp, v1, v2; - WInt8(ToInt(ServerProtocol::SrvDefPage)); + WInt8(SERVER_DEFPAGE); WInt8(default_font.Value()); WInt16(default_shadow.Value()); default_spacing.Get(tmp); WInt8(tmp); @@ -935,8 +936,8 @@ void ScanImageFiles() struct dirent *ent; struct stat st; - if ((dir = opendir("/usr/viewtouch/imgs")) != nullptr) { - while ((ent = readdir(dir)) != nullptr) { + if ((dir = opendir("/usr/viewtouch/imgs")) != NULL) { + while ((ent = readdir(dir)) != NULL) { std::string filename = ent->d_name; // Skip hidden files and directories @@ -979,28 +980,28 @@ void ScanImageFiles() void EZ_OkayCB(Widget widget, XtPointer client_data, XtPointer call_data) { - auto *d = static_cast(client_data); + ZoneDialog *d = static_cast(client_data); d->Close(); d->Send(); } void EZ_DeleteCB(Widget widget, XtPointer client_data, XtPointer call_data) { - auto *d = static_cast(client_data); + ZoneDialog *d = static_cast(client_data); d->Close(); - WInt8(ToInt(ServerProtocol::SrvKillZone)); + WInt8(SERVER_KILLZONE); SendNow(); } void EZ_CancelCB(Widget widget, XtPointer client_data, XtPointer call_data) { - auto *d = static_cast(client_data); + ZoneDialog *d = static_cast(client_data); d->Close(); } void EZ_TypeCB(Widget widget, XtPointer client_data, XtPointer call_data) { - auto *d = static_cast(client_data); + ZoneDialog *d = static_cast(client_data); int ztype = 0, itype = 0; if (d->full_edit) ztype = d->type.Value(); @@ -1028,7 +1029,7 @@ void EZ_TypeCB(Widget widget, XtPointer client_data, XtPointer call_data) void EZ_JumpCB(Widget widget, XtPointer client_data, XtPointer call_data) { - auto *d = static_cast(client_data); + ZoneDialog *d = static_cast(client_data); int jtype = 0; if (d->full_edit) jtype = d->jump_type.Value(); @@ -1049,7 +1050,7 @@ void EZ_JumpCB(Widget widget, XtPointer client_data, XtPointer call_data) void EZ_CorrectCB(Widget widget, XtPointer client_data, XtPointer call_data) { - auto *d = static_cast(client_data); + ZoneDialog *d = static_cast(client_data); d->Correct(); } @@ -1390,7 +1391,7 @@ int ZoneDialog::Send() int v2; fprintf(stderr, "ZoneDialog::Send() called for zone type %d\n", ztype); - WInt8(ToInt(ServerProtocol::SrvZoneData)); + WInt8(SERVER_ZONEDATA); WInt8(ztype); WStr(name.Value()); page.Get(tmp); WInt32(tmp); @@ -1487,14 +1488,14 @@ int ZoneDialog::Send() void MZ_OkayCB(Widget widget, XtPointer client_data, XtPointer call_data) { - auto *d = static_cast(client_data); + MultiZoneDialog *d = static_cast(client_data); d->Close(); d->Send(); } void MZ_CancelCB(Widget widget, XtPointer client_data, XtPointer call_data) { - auto *d = static_cast(client_data); + MultiZoneDialog *d = static_cast(client_data); d->Close(); } @@ -1536,7 +1537,7 @@ MultiZoneDialog::MultiZoneDialog(Widget parent) shadow.Init(w, "Shadow Intensity of All Buttons", ShadowName, ShadowValue); AddLine(w); - AddButtons(w, MZ_OkayCB, nullptr, MZ_CancelCB, this); + AddButtons(w, MZ_OkayCB, NULL, MZ_CancelCB, this); XtManageChild(w); } @@ -1584,7 +1585,7 @@ int MultiZoneDialog::Close() int MultiZoneDialog::Send() { int v1, v2; - WInt8(ToInt(ServerProtocol::SrvZoneChanges)); + WInt8(SERVER_ZONECHANGES); WInt16(behave.Value()); WInt16(font.Value()); appear1.Value(v1, v2); @@ -1604,14 +1605,14 @@ int MultiZoneDialog::Send() void TD_OkayCB(Widget widget, XtPointer client_data, XtPointer call_data) { - auto *d = static_cast(client_data); + TranslateDialog *d = static_cast(client_data); d->Close(); d->Send(); } void TD_CancelCB(Widget widget, XtPointer client_data, XtPointer call_data) { - auto *d = static_cast(client_data); + TranslateDialog *d = static_cast(client_data); d->Close(); } @@ -1639,7 +1640,7 @@ TranslateDialog::TranslateDialog(Widget parent) translation.Init(w, "Translation"); AddLine(w); - AddButtons(w, TD_OkayCB, nullptr, TD_CancelCB, this); + AddButtons(w, TD_OkayCB, NULL, TD_CancelCB, this); XtManageChild(w); } @@ -1667,7 +1668,7 @@ int TranslateDialog::Close() int TranslateDialog::Send() { - WInt8(ToInt(ServerProtocol::SrvTranslate)); + WInt8(SERVER_TRANSLATE); WInt8(count); for (int i = 0; i < count; ++i) { @@ -1683,8 +1684,8 @@ int TranslateDialog::Send() void ListSelectCB(Widget widget, XtPointer client_data, XtPointer call_data) { - auto *data = static_cast(call_data); - auto *d = static_cast(client_data); + XmListCallbackStruct *data = static_cast(call_data); + ListDialog *d = static_cast(client_data); int new_pos = data->item_position; if (new_pos != d->selected) @@ -1696,7 +1697,7 @@ void ListSelectCB(Widget widget, XtPointer client_data, XtPointer call_data) void ListPrintCB(Widget widget, XtPointer client_data, XtPointer call_data) { - WInt8(ToInt(ServerProtocol::SrvButtonPress)); + WInt8(SERVER_BUTTONPRESS); WInt16(1); // Main Window WInt16(12); // PrintList Button SendNow(); @@ -1704,7 +1705,7 @@ void ListPrintCB(Widget widget, XtPointer client_data, XtPointer call_data) void ListCloseCB(Widget widget, XtPointer client_data, XtPointer call_data) { - auto *d = static_cast(client_data); + ListDialog *d = static_cast(client_data); d->Close(); } @@ -1798,7 +1799,7 @@ int ListDialog::Close() int ListDialog::Send() { - WInt8(ToInt(ServerProtocol::SrvListSelect)); + WInt8(SERVER_LISTSELECT); WInt32(selected); return SendNow(); } diff --git a/term/term_dialog.hh b/term/term_dialog.hh index ca3771e6..85de5742 100644 --- a/term/term_dialog.hh +++ b/term/term_dialog.hh @@ -71,7 +71,7 @@ public: // Member Functions int Clear(); int Init(Widget parent, const genericChar* label, const genericChar* *option_name, int *option_value, - void *option_cb = nullptr, void *client_data = nullptr); + void *option_cb = NULL, void *client_data = NULL); int Show(int flag); int Set(int val); int SetLabel(const char* label); diff --git a/term/term_main.cc b/term/term_main.cc index 7ddcf3ad..53c8d37a 100644 --- a/term/term_main.cc +++ b/term/term_main.cc @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include @@ -148,7 +148,7 @@ int main(int argc, const genericChar* *argv) if (argc >= 7) set_height = atoi(argv[6]); - if (strchr(display.data(), ':') == nullptr) + if (strchr(display.data(), ':') == NULL) vt_safe_string::safe_concat(display.data(), display.size(), ":0"); // if OpenTerm() returns there must be an error diff --git a/term/term_view.cc b/term/term_view.cc index dacf8e61..68ebaec2 100644 --- a/term/term_view.cc +++ b/term/term_view.cc @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include #include @@ -132,20 +132,27 @@ enum ConnectionState { class ConnectionMonitor { private: - ConnectionState state_{CONNECTION_DISCONNECTED}; - time_t last_heartbeat_{0}; - time_t last_reconnect_attempt_{0}; - int reconnect_attempts_{0}; - int max_reconnect_attempts_{10}; - int reconnect_delay_{2}; - bool keep_alive_enabled_{true}; + ConnectionState state_; + time_t last_heartbeat_; + time_t last_reconnect_attempt_; + int reconnect_attempts_; + int max_reconnect_attempts_; + int reconnect_delay_; + bool keep_alive_enabled_; public: - ConnectionMonitor() = default; + ConnectionMonitor() : + state_(CONNECTION_DISCONNECTED), + last_heartbeat_(0), + last_reconnect_attempt_(0), + reconnect_attempts_(0), + max_reconnect_attempts_(10), + reconnect_delay_(2), + keep_alive_enabled_(true) {} void set_connected() { state_ = CONNECTION_CONNECTED; - last_heartbeat_ = time(nullptr); + last_heartbeat_ = time(NULL); reconnect_attempts_ = 0; ReportError("Connection established"); } @@ -159,7 +166,7 @@ class ConnectionMonitor { void set_reconnecting() { state_ = CONNECTION_RECONNECTING; - last_reconnect_attempt_ = time(nullptr); + last_reconnect_attempt_ = time(NULL); reconnect_attempts_++; } @@ -168,37 +175,37 @@ class ConnectionMonitor { ReportError("Connection failed permanently"); } - [[nodiscard]] ConnectionState get_state() const { return state_; } + ConnectionState get_state() const { return state_; } bool should_attempt_reconnect() { if (state_ != CONNECTION_DISCONNECTED) return false; if (reconnect_attempts_ >= max_reconnect_attempts_) return false; - time_t now = time(nullptr); + time_t now = time(NULL); int delay = reconnect_delay_ * (1 << (reconnect_attempts_ - 1)); // Exponential backoff if (delay > 60) delay = 60; // Cap at 60 seconds return (now - last_reconnect_attempt_) >= delay; } - [[nodiscard]] bool is_healthy() const { + bool is_healthy() const { if (state_ != CONNECTION_CONNECTED) return false; if (!keep_alive_enabled_) return true; - time_t now = time(nullptr); + time_t now = time(NULL); return (now - last_heartbeat_) < 30; // 30 second timeout } void send_heartbeat() { - last_heartbeat_ = time(nullptr); + last_heartbeat_ = time(NULL); } void reset_reconnect_attempts() { reconnect_attempts_ = 0; } - [[nodiscard]] int get_reconnect_attempts() const { return reconnect_attempts_; } - [[nodiscard]] int get_max_reconnect_attempts() const { return max_reconnect_attempts_; } + int get_reconnect_attempts() const { return reconnect_attempts_; } + int get_max_reconnect_attempts() const { return max_reconnect_attempts_; } }; @@ -235,8 +242,8 @@ class FileDescriptor { } // Accessors - [[nodiscard]] int get() const noexcept { return fd_; } - [[nodiscard]] bool is_valid() const noexcept { return fd_ > 0; } + int get() const noexcept { return fd_; } + bool is_valid() const noexcept { return fd_ > 0; } // Release ownership int release() noexcept { @@ -275,9 +282,9 @@ struct FontDataType const genericChar* font; }; -static constexpr std::array FontData = +static FontDataType FontData[] = { - {{FONT_TIMES_20, "DejaVu Serif:size=12:style=Book"}, + {FONT_TIMES_20, "DejaVu Serif:size=12:style=Book"}, {FONT_TIMES_24, "DejaVu Serif:size=14:style=Book"}, {FONT_TIMES_34, "DejaVu Serif:size=18:style=Book"}, {FONT_TIMES_48, "DejaVu Serif:size=28:style=Book"}, @@ -292,21 +299,18 @@ static constexpr std::array FontData = {FONT_COURIER_18, "Liberation Serif:size=11:style=Regular"}, {FONT_COURIER_18B, "Liberation Serif:size=11:style=Bold"}, {FONT_COURIER_20, "Liberation Serif:size=12:style=Regular"}, - {FONT_COURIER_20B, "Liberation Serif:size=12:style=Bold"}} + {FONT_COURIER_20B, "Liberation Serif:size=12:style=Bold"} }; struct PenDataType { - int id; - std::array t; - std::array s; - std::array h; + int id, t[3], s[3], h[3]; }; -static constexpr std::array PenData = +static PenDataType PenData[] = { // ColorID Text Color Shadow Color HiLight Color - {{COLOR_BLACK, { 0, 0, 0}, {249, 230, 210}, {148, 113, 78}}, + {COLOR_BLACK, { 0, 0, 0}, {249, 230, 210}, {148, 113, 78}}, {COLOR_WHITE, {255, 255, 255}, { 64, 64, 64}, {117, 97, 78}}, {COLOR_RED, {235, 0, 0}, { 47, 0, 0}, {242, 200, 200}}, {COLOR_GREEN, { 0, 128, 0}, { 0, 42, 0}, {140, 236, 140}}, @@ -326,12 +330,12 @@ static constexpr std::array PenData = {COLOR_DK_BLUE, { 0, 0, 145}, { 0, 0, 45}, {205, 205, 245}}, {COLOR_DK_TEAL, { 0, 92, 130}, { 0, 12, 30}, {176, 216, 255}}, {COLOR_DK_MAGENTA, {160, 32, 110}, { 32, 0, 16}, {232, 188, 210}}, - {COLOR_DK_SEAGREEN, { 0, 98, 72}, { 0, 32, 16}, {127, 228, 200}}} + {COLOR_DK_SEAGREEN, { 0, 98, 72}, { 0, 32, 16}, {127, 228, 200}}, }; -constexpr int FONTS = static_cast(FontData.size()); -constexpr int FONT_COUNT = FONTS; // Alias for compatibility -constexpr int FONT_SPACE = FONTS + 4; +#define FONTS (int)(sizeof(FontData)/sizeof(FontDataType)) +#define FONT_COUNT FONTS // Alias for compatibility +#define FONT_SPACE (FONTS+4) class FontNameClass { @@ -367,18 +371,18 @@ class FontNameClass int Parse(const char* fontname); const char* ToString(); - [[nodiscard]] const char* Foundry() const { return foundry.c_str(); } - [[nodiscard]] const char* Family() const { return family.c_str(); } - [[nodiscard]] const char* Weight() const { return weight.c_str(); } - [[nodiscard]] const char* Slant() const { return slant.c_str(); } - [[nodiscard]] const char* Width() const { return width.c_str(); } - [[nodiscard]] const char* Pixels() const { return pixels.c_str(); } - [[nodiscard]] const char* Points() const { return points.c_str(); } - [[nodiscard]] const char* HorRes() const { return horres.c_str(); } - [[nodiscard]] const char* VertRes() const { return vertres.c_str(); } - [[nodiscard]] const char* Spacing() const { return spacing.c_str(); } - [[nodiscard]] const char* AvgWidth() const { return avgwidth.c_str(); } - [[nodiscard]] const char* CharSet() const { return charset.c_str(); } + const char* Foundry() const { return foundry.c_str(); } + const char* Family() const { return family.c_str(); } + const char* Weight() const { return weight.c_str(); } + const char* Slant() const { return slant.c_str(); } + const char* Width() const { return width.c_str(); } + const char* Pixels() const { return pixels.c_str(); } + const char* Points() const { return points.c_str(); } + const char* HorRes() const { return horres.c_str(); } + const char* VertRes() const { return vertres.c_str(); } + const char* Spacing() const { return spacing.c_str(); } + const char* AvgWidth() const { return avgwidth.c_str(); } + const char* CharSet() const { return charset.c_str(); } void ClearFoundry() { foundry = "*"; } void ClearFamily() { family = "*"; } @@ -559,8 +563,8 @@ const char* FontNameClass::ToString() *------------------------------------------------------------------*/ Xpm::Xpm() { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; width = 0; height = 0; pixmap = 0; @@ -569,8 +573,8 @@ Xpm::Xpm() Xpm::Xpm(Pixmap pm) { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; width = 0; height = 0; pixmap = pm; @@ -579,8 +583,8 @@ Xpm::Xpm(Pixmap pm) Xpm::Xpm(Pixmap pm, int w, int h) { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; width = w; height = h; pixmap = pm; @@ -589,8 +593,8 @@ Xpm::Xpm(Pixmap pm, int w, int h) Xpm::Xpm(Pixmap pm, Pixmap m, int w, int h) { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; width = w; height = h; pixmap = pm; @@ -617,17 +621,17 @@ Xpm *Pixmaps::Get(int idx) { int curridx = 0; Xpm *currXpm = pixmaps.Head(); - Xpm *retval = nullptr; + Xpm *retval = NULL; if (pixmaps.Count() < 1) return retval; - while (currXpm != nullptr && curridx < count) + while (currXpm != NULL && curridx < count) { if (curridx == idx) { retval = currXpm; - currXpm = nullptr; + currXpm = NULL; } else { @@ -641,7 +645,7 @@ Xpm *Pixmaps::Get(int idx) Xpm *Pixmaps::GetRandom() { - Xpm *retval = nullptr; + Xpm *retval = NULL; if (pixmaps.Count() < 2) return retval; @@ -662,17 +666,17 @@ Pixmaps PixmapList; ********************************************************************/ LayerList Layers; -Layer *MainLayer = nullptr; +Layer *MainLayer = NULL; int SocketNo = 0; -Display *Dis = nullptr; -GC Gfx = nullptr; +Display *Dis = NULL; +GC Gfx = 0; Window MainWin; std::array Texture; Pixmap ShadowPix; int ScrDepth = 0; -Visual *ScrVis = nullptr; +Visual *ScrVis = NULL; Colormap ScrCol = 0; int WinWidth = 0; int WinHeight = 0; @@ -718,15 +722,15 @@ void HideReconnectingMessage(); // UI State preservation for disconnections struct SavedUIState { - int current_page{0}; - int cursor_x{0}, cursor_y{0}; - bool input_active{false}; + int current_page; + int cursor_x, cursor_y; + bool input_active; std::string last_message; - SavedUIState() = default; + SavedUIState() : current_page(0), cursor_x(0), cursor_y(0), input_active(false) {} void save() { - if (MainLayer != nullptr) { + if (MainLayer != NULL) { current_page = MainLayer->page_x; // Use page_x instead of page cursor_x = MainLayer->cursor; // Use cursor instead of cursor_x cursor_y = 0; // No cursor_y, set to 0 @@ -736,7 +740,7 @@ struct SavedUIState { } void restore() { - if (MainLayer != nullptr) { + if (MainLayer != NULL) { // Request the server to switch to the saved page // This will be sent when connection is restored fprintf(stderr, "UI State: Requesting page %d restore\n", current_page); @@ -786,9 +790,9 @@ void X11ResourceManager::cleanup() { } } -static Widget MainShell = nullptr; +static Widget MainShell = NULL; static int ScrNo = 0; -static Screen *ScrPtr = nullptr; +static Screen *ScrPtr = NULL; static int ScrHeight = 0; static int ScrWidth = 0; static Window RootWin; @@ -884,10 +888,10 @@ genericChar* RStr(genericChar* s) { FnTrace("RStr()"); - static std::array buffer = {""}; - if (s == nullptr) - s = buffer.data(); - if (BufferIn.GetString(s, buffer.size())) + static genericChar buffer[1024] = ""; + if (s == NULL) + s = buffer; + if (BufferIn.GetString(s, sizeof(buffer))) { s[0] = '\0'; } @@ -899,7 +903,7 @@ int ReportError(const std::string &message) FnTrace("ReportError()"); if (SocketNo) { - WInt8(ToInt(ServerProtocol::SrvError)); + WInt8(SERVER_ERROR); WStr(message.c_str(), 0); return SendNow(); } @@ -966,7 +970,7 @@ int Translations::AddTranslation(const char* key, const char* value) FnTrace("Translations::AddTranslation()"); int retval = 0; - auto *trans = new Translation(key, value); + Translation *trans = new Translation(key, value); trans_list.AddToTail(trans); return retval; @@ -977,13 +981,13 @@ const char* Translations::GetTranslation(const char* key) FnTrace("Translations::GetTranslation()"); Translation *trans = trans_list.Head(); - while (trans != nullptr) + while (trans != NULL) { if (trans->Match(key)) { - static std::array buffer{}; - trans->GetValue(buffer.data(), buffer.size()); - return buffer.data(); + static char buffer[STRLONG]; + trans->GetValue(buffer, STRLONG); + return buffer; } trans = trans->next; } @@ -995,14 +999,14 @@ void Translations::PrintTranslations() FnTrace("Translations::PrintTranslations()"); Translation *trans = trans_list.Head(); - std::array key{}; - std::array value{}; + char key[STRLONG]; + char value[STRLONG]; - while (trans != nullptr) + while (trans != NULL) { - trans->GetKey(key.data(), key.size()); - trans->GetValue(value.data(), value.size()); - printf("%s = %s\n", key.data(), value.data()); + trans->GetKey(key, STRLONG); + trans->GetValue(value, STRLONG); + printf("%s = %s\n", key, value); trans = trans->next; } } @@ -1041,7 +1045,7 @@ class IconifyButton : public LO_PushButton (py < (y + h + EXTRA_ICON_WIDTH)); } - int Command(Layer * /*l*/) override + int Command(Layer * /*l*/) { if (allow_iconify) { @@ -1050,7 +1054,7 @@ class IconifyButton : public LO_PushButton } return 0; } - int Render(Layer *l) override + int Render(Layer *l) { if (allow_iconify) return LO_PushButton::Render(l); @@ -1113,7 +1117,7 @@ void ExposeCB(Widget /*widget*/, XtPointer /*client_data*/, XEvent *event, { FnTrace("ExposeCB()"); - if (event == nullptr) + if (event == NULL) { fprintf(stderr, "ExposeCB: event is NULL, skipping expose processing\n"); return; @@ -1121,7 +1125,7 @@ void ExposeCB(Widget /*widget*/, XtPointer /*client_data*/, XEvent *event, static RegionInfo area; - auto *e = reinterpret_cast(event); + XExposeEvent *e = reinterpret_cast(event); if (CalibrateStage) return; @@ -1173,7 +1177,7 @@ void UpdateCB(XtPointer /*client_data*/, XtIntervalId * /*timer_id*/) // Critical fix: Clear the old timer ID before setting new one to prevent race condition UpdateTimerID = 0; - UpdateTimerID = XtAppAddTimeOut(App, update_time, (XtTimerCallbackProc) UpdateCB, nullptr); + UpdateTimerID = XtAppAddTimeOut(App, update_time, (XtTimerCallbackProc) UpdateCB, NULL); } void TouchScreenCB(XtPointer /*client_data*/, int * /*fid*/, XtInputId * /*id*/) @@ -1287,7 +1291,7 @@ void KeyPressCB(Widget /*widget*/, XtPointer /*client_data*/, { FnTrace("KeyPressCB()"); - if (event == nullptr) + if (event == NULL) { fprintf(stderr, "KeyPressCB: event is NULL, skipping key press processing\n"); return; @@ -1303,11 +1307,11 @@ void KeyPressCB(Widget /*widget*/, XtPointer /*client_data*/, if (UserInput()) return; - auto *e = reinterpret_cast(event); + XKeyEvent *e = reinterpret_cast(event); KeySym key = 0; std::array buffer; - int len = XLookupString(e, buffer.data(), 31, &key, nullptr); + int len = XLookupString(e, buffer.data(), 31, &key, NULL); if (len < 0) len = 0; buffer[len] = '\0'; @@ -1332,7 +1336,7 @@ void KeyPressCB(Widget /*widget*/, XtPointer /*client_data*/, case XK_End: if (e->state & ControlMask && e->state & Mod1Mask) { - WInt8(ToInt(ServerProtocol::SrvShutdown)); + WInt8(SERVER_SHUTDOWN); SendNow(); } break; @@ -1414,7 +1418,7 @@ void KeyPressCB(Widget /*widget*/, XtPointer /*client_data*/, swipe_stage = 0; swipe_char = 0; swipe_track2 = 0; - WInt8(ToInt(ServerProtocol::SrvSwipe)); + WInt8(SERVER_SWIPE); WStr(swipe_buffer.data()); SendNow(); } @@ -1535,7 +1539,7 @@ void KeyPressCB(Widget /*widget*/, XtPointer /*client_data*/, } fake_cc = 0; printf("Sending Fake Credit Card: '%s'\n", swipe_buffer.data()); - WInt8(ToInt(ServerProtocol::SrvSwipe)); + WInt8(SERVER_SWIPE); WStr(swipe_buffer.data()); SendNow(); } @@ -1566,7 +1570,7 @@ void MouseClickCB(Widget /*widget*/, XtPointer /*client_data*/, XEvent *event, { FnTrace("MouseClickCB()"); - if (event == nullptr) + if (event == NULL) { fprintf(stderr, "MouseClickCB: event is NULL, skipping mouse click processing\n"); return; @@ -1579,7 +1583,7 @@ void MouseClickCB(Widget /*widget*/, XtPointer /*client_data*/, XEvent *event, if (silent_mode > 0) return; - auto *btnevent = reinterpret_cast(event); + XButtonEvent *btnevent = reinterpret_cast(event); int code = MOUSE_PRESS; int touch = 0; @@ -1612,7 +1616,7 @@ void MouseReleaseCB(Widget widget, XtPointer client_data, XEvent *event, { FnTrace("MouseReleaseCB()"); - if (event == nullptr) + if (event == NULL) { fprintf(stderr, "MouseReleaseCB: event is NULL, skipping mouse release processing\n"); return; @@ -1623,7 +1627,7 @@ void MouseReleaseCB(Widget widget, XtPointer client_data, XEvent *event, if (silent_mode > 0) return; - auto *b = reinterpret_cast(event); + XButtonEvent *b = reinterpret_cast(event); Layers.RubberBandOff(); int code = MOUSE_RELEASE; @@ -1644,13 +1648,13 @@ void MouseMoveCB(Widget widget, XtPointer client_data, XEvent *event, { FnTrace("MouseMoveCB()"); - if (event == nullptr) + if (event == NULL) { fprintf(stderr, "MouseMoveCB: event is NULL, skipping mouse move processing\n"); return; } - auto *e = reinterpret_cast(event); + XPointerMovedEvent *e = reinterpret_cast(event); if (UserInput()) return; if (silent_mode > 0) @@ -1659,7 +1663,7 @@ void MouseMoveCB(Widget widget, XtPointer client_data, XEvent *event, // try to intelligently determine whether this might be // a touch - gettimeofday(&now, nullptr); + gettimeofday(&now, NULL); if ((now.tv_sec - last_mouse_time.tv_sec) > 1 || (now.tv_usec - last_mouse_time.tv_usec) > 100000) { @@ -1722,7 +1726,7 @@ void SocketInputCB(XtPointer client_data, int *fid, XtInputId *id) saved_ui_state.save(); // Show "Reconnecting..." message on screen instead of just logging - if (MainLayer != nullptr) { + if (MainLayer != NULL) { ShowReconnectingMessage(); } } @@ -1757,7 +1761,7 @@ void SocketInputCB(XtPointer client_data, int *fid, XtInputId *id) consecutive_failures = 0; // Hide reconnecting message and restore normal operation - if (MainLayer != nullptr) { + if (MainLayer != NULL) { HideReconnectingMessage(); } @@ -1786,7 +1790,7 @@ void SocketInputCB(XtPointer client_data, int *fid, XtInputId *id) consecutive_failures = 0; if (connection_monitor.get_state() != CONNECTION_CONNECTED) { connection_monitor.set_connected(); - if (MainLayer != nullptr) { + if (MainLayer != NULL) { HideReconnectingMessage(); // Restore UI state after reconnection saved_ui_state.restore(); @@ -1795,7 +1799,7 @@ void SocketInputCB(XtPointer client_data, int *fid, XtInputId *id) connection_monitor.send_heartbeat(); Layer *l = MainLayer; - if (l == nullptr) + if (l == NULL) { fprintf(stderr, "SocketInputCB: MainLayer is NULL, skipping processing\n"); return; @@ -1810,9 +1814,9 @@ void SocketInputCB(XtPointer client_data, int *fid, XtInputId *id) const genericChar* s1, *s2; int failure = 0; - std::array s{}; - std::array key{}; - std::array value{}; + genericChar s[STRLONG]; + genericChar key[STRLENGTH]; + genericChar value[STRLENGTH]; while (BufferIn.size > 0) { @@ -1875,7 +1879,7 @@ void SocketInputCB(XtPointer client_data, int *fid, XtInputId *id) n4 = RInt8(); n5 = RInt16(); n6 = RInt8(); - s1 = RStr(s.data()); + s1 = RStr(s); s2 = RStr(); if (TScreen) TScreen->Flush(); @@ -1891,61 +1895,61 @@ void SocketInputCB(XtPointer client_data, int *fid, XtInputId *id) SetTitleBar(RStr()); break; case TERM_TEXTL: - RStr(s.data()); + RStr(s); n1 = RInt16(); n2 = RInt16(); n3 = RInt8(); n4 = RInt8(); n5 = RInt16(); - l->Text(s.data(), strlen(s.data()), n1, n2, n3, n4, ALIGN_LEFT, n5, use_embossed_text); + l->Text(s, strlen(s), n1, n2, n3, n4, ALIGN_LEFT, n5, use_embossed_text); break; case TERM_TEXTC: - RStr(s.data()); + RStr(s); n1 = RInt16(); n2 = RInt16(); n3 = RInt8(); n4 = RInt8(); n5 = RInt16(); - l->Text(s.data(), strlen(s.data()), n1, n2, n3, n4, ALIGN_CENTER, n5, use_embossed_text); + l->Text(s, strlen(s), n1, n2, n3, n4, ALIGN_CENTER, n5, use_embossed_text); break; case TERM_TEXTR: - RStr(s.data()); + RStr(s); n1 = RInt16(); n2 = RInt16(); n3 = RInt8(); n4 = RInt8(); n5 = RInt16(); - l->Text(s.data(), strlen(s.data()), n1, n2, n3, n4, ALIGN_RIGHT, n5, use_embossed_text); + l->Text(s, strlen(s), n1, n2, n3, n4, ALIGN_RIGHT, n5, use_embossed_text); break; case TERM_ZONETEXTL: - RStr(s.data()); + RStr(s); n1 = RInt16(); n2 = RInt16(); n3 = RInt16(); n4 = RInt16(); n5 = RInt8(); n6 = RInt8(); - l->ZoneText(s.data(), n1, n2, n3, n4, n5, n6, ALIGN_LEFT, use_embossed_text); + l->ZoneText(s, n1, n2, n3, n4, n5, n6, ALIGN_LEFT, use_embossed_text); break; case TERM_ZONETEXTC: - RStr(s.data()); + RStr(s); n1 = RInt16(); n2 = RInt16(); n3 = RInt16(); n4 = RInt16(); n5 = RInt8(); n6 = RInt8(); - l->ZoneText(s.data(), n1, n2, n3, n4, n5, n6, ALIGN_CENTER, use_embossed_text); + l->ZoneText(s, n1, n2, n3, n4, n5, n6, ALIGN_CENTER, use_embossed_text); break; case TERM_ZONETEXTR: - RStr(s.data()); + RStr(s); n1 = RInt16(); n2 = RInt16(); n3 = RInt16(); n4 = RInt16(); n5 = RInt8(); n6 = RInt8(); - l->ZoneText(s.data(), n1, n2, n3, n4, n5, n6, ALIGN_RIGHT, use_embossed_text); + l->ZoneText(s, n1, n2, n3, n4, n5, n6, ALIGN_RIGHT, use_embossed_text); break; case TERM_ZONE: n1 = RInt16(); @@ -2038,10 +2042,10 @@ void SocketInputCB(XtPointer client_data, int *fid, XtInputId *id) n3 = RInt16(); n4 = RInt16(); n5 = RInt8(); - RStr(s.data()); + RStr(s); n6 = RInt8(); n7 = RInt8(); - l->StatusBar(n1, n2, n3, n4, n5, s.data(), n6, n7); + l->StatusBar(n1, n2, n3, n4, n5, s, n6, n7); break; case TERM_FLUSH_TS: if (TScreen) @@ -2166,8 +2170,8 @@ void SocketInputCB(XtPointer client_data, int *fid, XtInputId *id) n4 = RInt16(); n5 = RInt16(); n6 = RInt8(); - RStr(s.data()); - OpenLayer(n1, n2, n3, n4, n5, n6, s.data()); + RStr(s); + OpenLayer(n1, n2, n3, n4, n5, n6, s); break; case TERM_SHOWWINDOW: ShowLayer(RInt16()); @@ -2184,11 +2188,11 @@ void SocketInputCB(XtPointer client_data, int *fid, XtInputId *id) n3 = RInt16(); n4 = RInt16(); n5 = RInt16(); - RStr(s.data()); + RStr(s); n6 = RInt8(); n7 = RInt8(); n8 = RInt8(); - NewPushButton(n1, n2, n3, n4, n5, s.data(), n6, n7, n8); + NewPushButton(n1, n2, n3, n4, n5, s, n6, n7, n8); break; case TERM_ICONIFY: ResetView(); @@ -2202,9 +2206,9 @@ void SocketInputCB(XtPointer client_data, int *fid, XtInputId *id) n1 = RInt8(); for (n2 = 0; n2 < n1; n2++) { - RStr(key.data()); - RStr(value.data()); - MasterTranslations.AddTranslation(key.data(), value.data()); + RStr(key); + RStr(value); + MasterTranslations.AddTranslation(key, value); } new_page_translations = 1; new_zone_translations = 1; @@ -2216,7 +2220,7 @@ void SocketInputCB(XtPointer client_data, int *fid, XtInputId *id) { creditcard->Read(); creditcard->Sale(); - WInt8(ToInt(ServerProtocol::SrvCcProcessed)); + WInt8(SERVER_CC_PROCESSED); creditcard->Write(); SendNow(); creditcard->Clear(); @@ -2229,7 +2233,7 @@ void SocketInputCB(XtPointer client_data, int *fid, XtInputId *id) { creditcard->Read(); creditcard->PreAuth(); - WInt8(ToInt(ServerProtocol::SrvCcProcessed)); + WInt8(SERVER_CC_PROCESSED); creditcard->Write(); SendNow(); creditcard->Clear(); @@ -2242,7 +2246,7 @@ void SocketInputCB(XtPointer client_data, int *fid, XtInputId *id) { creditcard->Read(); creditcard->FinishAuth(); - WInt8(ToInt(ServerProtocol::SrvCcProcessed)); + WInt8(SERVER_CC_PROCESSED); creditcard->Write(); SendNow(); creditcard->Clear(); @@ -2255,7 +2259,7 @@ void SocketInputCB(XtPointer client_data, int *fid, XtInputId *id) { creditcard->Read(); creditcard->Void(); - WInt8(ToInt(ServerProtocol::SrvCcProcessed)); + WInt8(SERVER_CC_PROCESSED); creditcard->Write(); SendNow(); creditcard->Clear(); @@ -2268,7 +2272,7 @@ void SocketInputCB(XtPointer client_data, int *fid, XtInputId *id) { creditcard->Read(); creditcard->VoidCancel(); - WInt8(ToInt(ServerProtocol::SrvCcProcessed)); + WInt8(SERVER_CC_PROCESSED); creditcard->Write(); SendNow(); creditcard->Clear(); @@ -2281,7 +2285,7 @@ void SocketInputCB(XtPointer client_data, int *fid, XtInputId *id) { creditcard->Read(); creditcard->Refund(); - WInt8(ToInt(ServerProtocol::SrvCcProcessed)); + WInt8(SERVER_CC_PROCESSED); creditcard->Write(); SendNow(); creditcard->Clear(); @@ -2294,7 +2298,7 @@ void SocketInputCB(XtPointer client_data, int *fid, XtInputId *id) { creditcard->Read(); creditcard->RefundCancel(); - WInt8(ToInt(ServerProtocol::SrvCcProcessed)); + WInt8(SERVER_CC_PROCESSED); creditcard->Write(); SendNow(); creditcard->Clear(); @@ -2385,8 +2389,8 @@ void SocketInputCB(XtPointer client_data, int *fid, XtInputId *id) * General Functions ********************************************************************/ -Layer *TargetLayer = nullptr; -LayerObject *TargetObject = nullptr; +Layer *TargetLayer = NULL; +LayerObject *TargetObject = NULL; int OpenLayer(int id, int x, int y, int w, int h, int win_frame, const genericChar* title) { @@ -2399,8 +2403,8 @@ int OpenLayer(int id, int x, int y, int w, int h, int win_frame, const genericCh } KillLayer(id); - auto *l = new Layer(Dis, Gfx, MainWin, w, h); - if (l == nullptr) + Layer *l = new Layer(Dis, Gfx, MainWin, w, h); + if (l == NULL) return 1; if (l->pix == 0) @@ -2429,7 +2433,7 @@ int ShowLayer(int id) FnTrace("ShowLayer()"); Layer *l = Layers.FindByID(id); - if (l == nullptr) + if (l == NULL) return 1; l->buttons.Render(l); @@ -2462,7 +2466,7 @@ int SetTargetLayer(int id) FnTrace("SetTargetLayer()"); Layer *l = Layers.FindByID(id); - if (l == nullptr) + if (l == NULL) return 1; TargetLayer = l; @@ -2475,9 +2479,9 @@ int NewPushButton(int id, int x, int y, int w, int h, const genericChar* text, FnTrace("NewPushButton()"); Layer *l = TargetLayer; - if (l == nullptr) + if (l == NULL) return 1; - auto *b = new LO_PushButton(text, c1, c2); + LO_PushButton *b = new LO_PushButton(text, c1, c2); b->SetRegion(x + l->offset_x, y + l->offset_y, w, h); b->font = font; b->id = id; @@ -2599,10 +2603,10 @@ int SaveToPPM() ReportError(str.data()); // Generate the screenshot - std::array command{}; - snprintf(command.data(), command.size(), "%s -root -display %s >%s", + char command[STRLONG]; + snprintf(command, STRLONG, "%s -root -display %s >%s", Constants::XWD, DisplayString(Dis), filename.data()); - system(command.data()); + system(command); return 0; } @@ -2662,7 +2666,7 @@ Pixmap LoadPixmap(const char**image_data) Pixmap retxpm = 0; int status; - status = XpmCreatePixmapFromData(Dis, MainWin, const_cast(image_data), &retxpm, nullptr, nullptr); + status = XpmCreatePixmapFromData(Dis, MainWin, const_cast(image_data), &retxpm, NULL, NULL); if (status != XpmSuccess) fprintf(stderr, "XpmError: %s\n", XpmGetErrorString(status)); @@ -2679,7 +2683,7 @@ Xpm *LoadPixmapFile(char* file_name) { FnTrace("LoadPixmapFile()"); - Xpm *retxpm = nullptr; + Xpm *retxpm = NULL; Pixmap xpm; XpmAttributes attributes; int status; @@ -2690,7 +2694,7 @@ Xpm *LoadPixmapFile(char* file_name) if (sb.st_size <= MAX_XPM_SIZE) { attributes.valuemask = 0; - status = XpmReadFileToPixmap(Dis, MainWin, file_name, &xpm, nullptr, &attributes); + status = XpmReadFileToPixmap(Dis, MainWin, file_name, &xpm, NULL, &attributes); if (status != XpmSuccess) { fprintf(stderr, "XpmError %s for %s\n", XpmGetErrorString(status), file_name); @@ -2961,20 +2965,20 @@ Xpm *LoadPNGFile(const char* file_name) } // Read PNG header to verify format - std::array header{}; - if (fread(header.data(), 1, header.size(), fp) != header.size()) { + png_byte header[8]; + if (fread(header, 1, 8, fp) != 8) { fprintf(stderr, "LoadPNGFile: Cannot read PNG header from %s\n", file_name); fclose(fp); return nullptr; } - if (png_sig_cmp(header.data(), 0, header.size())) { + if (png_sig_cmp(header, 0, 8)) { fprintf(stderr, "LoadPNGFile: File %s is not a valid PNG\n", file_name); fclose(fp); return nullptr; } - png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); + png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (!png_ptr) { fprintf(stderr, "LoadPNGFile: Cannot create PNG read struct\n"); fclose(fp); @@ -2984,14 +2988,14 @@ Xpm *LoadPNGFile(const char* file_name) png_infop info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) { fprintf(stderr, "LoadPNGFile: Cannot create PNG info struct\n"); - png_destroy_read_struct(&png_ptr, nullptr, nullptr); + png_destroy_read_struct(&png_ptr, NULL, NULL); fclose(fp); return nullptr; } if (setjmp(png_jmpbuf(png_ptr))) { fprintf(stderr, "LoadPNGFile: PNG read error in %s\n", file_name); - png_destroy_read_struct(&png_ptr, &info_ptr, nullptr); + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); fclose(fp); return nullptr; } @@ -3035,10 +3039,10 @@ Xpm *LoadPNGFile(const char* file_name) fprintf(stderr, "LoadPNGFile: Row bytes = %d, channels = %d\n", rowbytes, channels); // Allocate image data - auto* row_pointers = (png_bytep*)malloc(sizeof(png_bytep) * height); + png_bytep* row_pointers = (png_bytep*)malloc(sizeof(png_bytep) * height); if (!row_pointers) { fprintf(stderr, "LoadPNGFile: Cannot allocate row pointers\n"); - png_destroy_read_struct(&png_ptr, &info_ptr, nullptr); + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); fclose(fp); return nullptr; } @@ -3049,7 +3053,7 @@ Xpm *LoadPNGFile(const char* file_name) fprintf(stderr, "LoadPNGFile: Cannot allocate row data\n"); for (int i = 0; i < y; i++) free(row_pointers[i]); free(row_pointers); - png_destroy_read_struct(&png_ptr, &info_ptr, nullptr); + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); fclose(fp); return nullptr; } @@ -3165,7 +3169,7 @@ Xpm *LoadPNGFile(const char* file_name) // Put mask to mask pixmap if (mask && mask_image) { - GC mask_gc = XCreateGC(Dis, mask, 0, nullptr); + GC mask_gc = XCreateGC(Dis, mask, 0, NULL); XPutImage(Dis, mask, mask_gc, mask_image, 0, 0, 0, 0, width, height); XFreeGC(Dis, mask_gc); XDestroyImage(mask_image); @@ -3186,7 +3190,7 @@ Xpm *LoadPNGFile(const char* file_name) free(row_pointers[y]); } free(row_pointers); - png_destroy_read_struct(&png_ptr, &info_ptr, nullptr); + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); fclose(fp); if (pixmap) { @@ -3350,20 +3354,20 @@ Xpm *LoadGIFFile(const char* file_name) int ReadScreenSaverPix() { FnTrace("ReadScreenSaverPix()"); - struct dirent *record = nullptr; + struct dirent *record = NULL; DIR *dp; Xpm *newpm; - std::array fullpath{}; + genericChar fullpath[STRLONG]; int len; if (!fs::is_directory(SCREENSAVER_DIR)) { std::cerr << "Screen saver directory does not exist: '" - << SCREENSAVER_DIR << "' creating it" << '\n'; + << SCREENSAVER_DIR << "' creating it" << std::endl; fs::create_directory(SCREENSAVER_DIR); fs::permissions(SCREENSAVER_DIR, fs::perms::all); // be sure read/write/execute flags are set } dp = opendir(SCREENSAVER_DIR); - if (dp == nullptr) + if (dp == NULL) { ReportError("Can't find screen saver directory"); return 1; @@ -3379,9 +3383,9 @@ int ReadScreenSaverPix() if ((strcmp(&name[len-4], ".xpm") == 0) || (strcmp(&name[len-4], ".XPM") == 0)) { - snprintf(fullpath.data(), fullpath.size(), "%s/%s", SCREENSAVER_DIR, name); - newpm = LoadPixmapFile(fullpath.data()); - if (newpm != nullptr) + snprintf(fullpath, STRLONG, "%s/%s", SCREENSAVER_DIR, name); + newpm = LoadPixmapFile(fullpath); + if (newpm != NULL) PixmapList.Add(newpm); } } @@ -3552,7 +3556,7 @@ int Calibrate(int status) { FnTrace("Calibrate()"); - if (TScreen == nullptr) + if (TScreen == NULL) return 1; ResetView(); @@ -3569,7 +3573,7 @@ int Calibrate(int status) TScreen->Calibrate(); TouchInputID = XtAppAddInput(App, TScreen->device_no, (XtPointer)XtInputReadMask, - (XtInputCallbackProc)CalibrateCB, nullptr); + (XtInputCallbackProc)CalibrateCB, NULL); break; case 1: // 2nd stage - get lower left touch XSetTile(Dis, Gfx, GetTexture(IMAGE_LIT_SAND)); @@ -3621,7 +3625,7 @@ int StartTimers() if (UpdateTimerID == 0) { UpdateTimerID = XtAppAddTimeOut(App, Constants::UPDATE_TIME, - (XtTimerCallbackProc) UpdateCB, nullptr); + (XtTimerCallbackProc) UpdateCB, NULL); } if (TouchInputID == 0 && TScreen && TScreen->device_no > 0) @@ -3633,7 +3637,7 @@ int StartTimers() TScreen->device_no, (XtPointer) XtInputReadMask, (XtInputCallbackProc) TouchScreenCB, - nullptr); + NULL); } return 0; @@ -3709,9 +3713,9 @@ static bool IsRaspberryPi() // Check /proc/cpuinfo for Raspberry Pi FILE* cpuinfo = fopen("/proc/cpuinfo", "r"); if (cpuinfo) { - std::array line{}; - while (fgets(line.data(), line.size(), cpuinfo)) { - if (strstr(line.data(), "Raspberry Pi") || strstr(line.data(), "BCM") || strstr(line.data(), "Model")) { + char line[256]; + while (fgets(line, sizeof(line), cpuinfo)) { + if (strstr(line, "Raspberry Pi") || strstr(line, "BCM") || strstr(line, "Model")) { is_pi = true; break; } @@ -3737,7 +3741,7 @@ int OpenTerm(const char* display, TouchScreen *ts, int is_term_local, int term_h int i; - srand(time(nullptr)); + srand(time(NULL)); // Init Xt & Create Application Context App = XtCreateApplicationContext(); @@ -3747,11 +3751,11 @@ int OpenTerm(const char* display, TouchScreen *ts, int is_term_local, int term_h FontInfo.fill(nullptr); // Start Display - std::array str{}; + genericChar str[STRLENGTH]; int argc = 1; - std::array argv{{"vt_term"}}; + const genericChar* argv[] = {"vt_term"}; IsTermLocal = is_term_local; - Dis = XtOpenDisplay(App, display, nullptr, nullptr, nullptr, 0, &argc, const_cast(argv.data())); + Dis = XtOpenDisplay(App, display, NULL, NULL, NULL, 0, &argc, const_cast(argv)); if (Dis == nullptr) { std::string error_msg = "Can't open display '" + std::string(display) + "'"; @@ -3782,7 +3786,7 @@ int OpenTerm(const char* display, TouchScreen *ts, int is_term_local, int term_h // Load Fonts // Use fixed DPI (96) for consistent font rendering across all displays // This ensures fonts render at the same size regardless of display DPI - static std::array font_spec_with_dpi{}; + static char font_spec_with_dpi[256]; for (const auto& fontData : FontData) { int f = fontData.id; @@ -3791,8 +3795,8 @@ int OpenTerm(const char* display, TouchScreen *ts, int is_term_local, int term_h // Append :dpi=96 to font specification if not already present const char* xft_font_name = fontData.font; if (strstr(xft_font_name, ":dpi=") == nullptr) { - snprintf(font_spec_with_dpi.data(), font_spec_with_dpi.size(), "%s:dpi=96", xft_font_name); - xft_font_name = font_spec_with_dpi.data(); + snprintf(font_spec_with_dpi, sizeof(font_spec_with_dpi), "%s:dpi=96", xft_font_name); + xft_font_name = font_spec_with_dpi; } XftFontsArr[f] = XftFontOpenName(Dis, ScrNo, xft_font_name); @@ -3825,7 +3829,7 @@ int OpenTerm(const char* display, TouchScreen *ts, int is_term_local, int term_h // Create Window int n = 0; std::array args; - XtSetArg(args[n], (String)"visual", ScrVis); ++n; + XtSetArg(args[n], "visual", ScrVis); ++n; XtSetArg(args[n], XtNdepth, ScrDepth); ++n; //XtSetArg(args[n], "mappedWhenManaged", False); ++n; XtSetArg(args[n], XtNx, 0); ++n; @@ -3833,11 +3837,11 @@ int OpenTerm(const char* display, TouchScreen *ts, int is_term_local, int term_h XtSetArg(args[n], XtNwidth, WinWidth); ++n; XtSetArg(args[n], XtNheight, WinHeight); ++n; XtSetArg(args[n], XtNborderWidth, 0); ++n; - XtSetArg(args[n], (String)"minWidth", WinWidth); ++n; - XtSetArg(args[n], (String)"minHeight", WinHeight); ++n; - XtSetArg(args[n], (String)"maxWidth", WinWidth); ++n; - XtSetArg(args[n], (String)"maxHeight" , WinHeight); ++n; - XtSetArg(args[n], (String)"mwmDecorations", 0); ++n; + XtSetArg(args[n], "minWidth", WinWidth); ++n; + XtSetArg(args[n], "minHeight", WinHeight); ++n; + XtSetArg(args[n], "maxWidth", WinWidth); ++n; + XtSetArg(args[n], "maxHeight" , WinHeight); ++n; + XtSetArg(args[n], "mwmDecorations", 0); ++n; MainShell = XtAppCreateShell("POS", "viewtouch", applicationShellWidgetClass, Dis, args.data(), n); @@ -3902,7 +3906,7 @@ int OpenTerm(const char* display, TouchScreen *ts, int is_term_local, int term_h fprintf(stderr, "Raspberry Pi detected: Disabling expensive rendering features for better performance\n"); } - Gfx = XCreateGC(Dis, MainWin, 0, nullptr); + Gfx = XCreateGC(Dis, MainWin, 0, NULL); ShadowPix = XmuCreateStippledPixmap(ScrPtr, 0, 1, 1); XSetStipple(Dis, Gfx, ShadowPix); @@ -3911,7 +3915,7 @@ int OpenTerm(const char* display, TouchScreen *ts, int is_term_local, int term_h CursorWait = XCreateFontCursor(Dis, XC_watch); // Setup Blank Cursor Pixmap p = XCreatePixmap(Dis, MainWin, 16, 16, 1); - GC pgc = XCreateGC(Dis, p, 0, nullptr); + GC pgc = XCreateGC(Dis, p, 0, NULL); XSetForeground(Dis, pgc, BlackPixel(Dis, ScrNo)); XSetFillStyle(Dis, pgc, FillSolid); XFillRectangle(Dis, p, pgc, 0, 0, 16, 16); @@ -3926,7 +3930,7 @@ int OpenTerm(const char* display, TouchScreen *ts, int is_term_local, int term_h // Setup layers Layers.XWindowInit(Dis, Gfx, MainWin); - auto *l = new Layer(Dis, Gfx, MainWin, WinWidth, WinHeight); + Layer *l = new Layer(Dis, Gfx, MainWin, WinWidth, WinHeight); if (l) { l->id = 1; @@ -3955,7 +3959,7 @@ int OpenTerm(const char* display, TouchScreen *ts, int is_term_local, int term_h // Add Iconify Button if (l && IsTermLocal) { - auto *b = new IconifyButton("I", COLOR_GRAY, COLOR_LT_BLUE); + IconifyButton *b = new IconifyButton("I", COLOR_GRAY, COLOR_LT_BLUE); // b->SetRegion(WinWidth - l->title_height + 4, 4, // l->title_height - 8, l->title_height - 8); b->SetRegion(WinWidth - l->title_height + 8, 8, @@ -3980,7 +3984,7 @@ int OpenTerm(const char* display, TouchScreen *ts, int is_term_local, int term_h LastInput = SystemTime; SocketInputID = XtAppAddInput(App, SocketNo, (XtPointer) XtInputReadMask, - (XtInputCallbackProc) SocketInputCB, nullptr); + (XtInputCallbackProc) SocketInputCB, NULL); // Send server term size int screen_size = PAGE_SIZE_640x480; @@ -4018,7 +4022,7 @@ int OpenTerm(const char* display, TouchScreen *ts, int is_term_local, int term_h else if (WinWidth >= 768 && WinHeight >= 1024) screen_size = PAGE_SIZE_768x1024; - WInt8(ToInt(ServerProtocol::SrvTermInfo)); + WInt8(SERVER_TERMINFO); WInt8(screen_size); WInt16(WinWidth); WInt16(WinHeight); @@ -4027,11 +4031,11 @@ int OpenTerm(const char* display, TouchScreen *ts, int is_term_local, int term_h if (TScreen) TScreen->Flush(); - XtAddEventHandler(MainShell, KeyPressMask, FALSE, KeyPressCB, nullptr); - XtAddEventHandler(MainShell, ExposureMask, FALSE, ExposeCB, nullptr); - XtAddEventHandler(MainShell, ButtonPressMask, FALSE, MouseClickCB, nullptr); - XtAddEventHandler(MainShell, ButtonReleaseMask, FALSE, MouseReleaseCB, nullptr); - XtAddEventHandler(MainShell, PointerMotionMask, FALSE, MouseMoveCB, nullptr); + XtAddEventHandler(MainShell, KeyPressMask, FALSE, KeyPressCB, NULL); + XtAddEventHandler(MainShell, ExposureMask, FALSE, ExposeCB, NULL); + XtAddEventHandler(MainShell, ButtonPressMask, FALSE, MouseClickCB, NULL); + XtAddEventHandler(MainShell, ButtonReleaseMask, FALSE, MouseReleaseCB, NULL); + XtAddEventHandler(MainShell, PointerMotionMask, FALSE, MouseMoveCB, NULL); //Boolean okay; XEvent event; @@ -4104,7 +4108,7 @@ void ShowReconnectingMessage() { FnTrace("ShowReconnectingMessage()"); - if (reconnect_message_visible || Dis == nullptr) { + if (reconnect_message_visible || Dis == NULL) { return; } @@ -4163,7 +4167,7 @@ void HideReconnectingMessage() { FnTrace("HideReconnectingMessage()"); - if (!reconnect_message_visible || Dis == nullptr) { + if (!reconnect_message_visible || Dis == NULL) { return; } @@ -4173,7 +4177,7 @@ void HideReconnectingMessage() } // Force a redraw of the main window to restore normal display - if (MainLayer != nullptr) { + if (MainLayer != NULL) { MainLayer->DrawAll(); XFlush(Dis); } @@ -4248,7 +4252,7 @@ int ReconnectToServer() // Re-add the input handler SocketInputID = XtAppAddInput(App, SocketNo, (XtPointer) XtInputReadMask, - (XtInputCallbackProc) SocketInputCB, nullptr); + (XtInputCallbackProc) SocketInputCB, NULL); fprintf(stderr, "ReconnectToServer: Successfully reconnected\n"); return 0; @@ -4339,7 +4343,7 @@ int KillTerm() if (Gfx) { XFreeGC(Dis, Gfx); - Gfx = nullptr; + Gfx = NULL; } for (auto& font : FontInfo) @@ -4365,12 +4369,12 @@ int KillTerm() if (Dis) { XtCloseDisplay(Dis); - Dis = nullptr; + Dis = NULL; } if (App) { XtDestroyApplicationContext(App); - App = nullptr; + App = NULL; } return 0; } @@ -4451,14 +4455,14 @@ void TerminalReloadFonts() } } // Reload fonts with fixed DPI (96) for consistency - static std::array font_spec_with_dpi{}; + static char font_spec_with_dpi[256]; for (const auto& fontData : FontData) { int f = fontData.id; const char* xft_font_name = fontData.font; // Append :dpi=96 to font specification if not already present if (strstr(xft_font_name, ":dpi=") == nullptr) { - snprintf(font_spec_with_dpi.data(), font_spec_with_dpi.size(), "%s:dpi=96", xft_font_name); - xft_font_name = font_spec_with_dpi.data(); + snprintf(font_spec_with_dpi, sizeof(font_spec_with_dpi), "%s:dpi=96", xft_font_name); + xft_font_name = font_spec_with_dpi; } XftFontsArr[f] = XftFontOpenName(Dis, ScrNo, xft_font_name); if (XftFontsArr[f]) { @@ -4477,7 +4481,7 @@ void TerminalReloadFonts() LayerObject *obj = layer->buttons.Head(); while (obj != nullptr) { // Try to cast to LO_PushButton to check if it's a button - auto *button = dynamic_cast(obj); + LO_PushButton *button = dynamic_cast(obj); if (button != nullptr) { // Update button font to use the current font family // The font family will change while keeping the same size diff --git a/term/term_view.hh b/term/term_view.hh index 7f1d5425..41db7697 100644 --- a/term/term_view.hh +++ b/term/term_view.hh @@ -6,8 +6,8 @@ * Terminal Display module */ -#ifndef TERM_VIEW_HH -#define TERM_VIEW_HH +#ifndef _TERM_VIEW_HH +#define _TERM_VIEW_HH #include "list_utility.hh" #include "utility.hh" @@ -67,9 +67,9 @@ extern int silent_mode; // to disable clone input // Avoids expensive XQueryColor calls for every text render struct ColorCache { std::array cached_colors; - bool initialized{false}; + bool initialized; - ColorCache() { + ColorCache() : initialized(false) { for (auto& c : cached_colors) { c.red = c.green = c.blue = c.alpha = 0; } @@ -180,7 +180,7 @@ extern Translations MasterTranslations; #define MAX_SCREEN_HEIGHT 1200 // Page Sizes (resolutions) -enum page_sizes : std::uint8_t { +enum page_sizes { PAGE_SIZE_640x480 = 1, PAGE_SIZE_768x1024, PAGE_SIZE_800x480, @@ -313,10 +313,10 @@ public: Xpm(Pixmap pm); Xpm(Pixmap pm, int w, int h); Xpm(Pixmap pm, Pixmap m, int w, int h); // Constructor with mask - [[nodiscard]] constexpr int Width() const noexcept { return width; } - [[nodiscard]] constexpr int Height() const noexcept { return height; } - [[nodiscard]] constexpr int PixmapID() const noexcept { return pixmap; } - [[nodiscard]] constexpr Pixmap MaskID() const noexcept { return mask; } + constexpr int Width() const noexcept { return width; } + constexpr int Height() const noexcept { return height; } + constexpr int PixmapID() const noexcept { return pixmap; } + constexpr Pixmap MaskID() const noexcept { return mask; } }; class Pixmaps { @@ -327,7 +327,7 @@ public: int Add(Xpm *pixmap); Xpm *Get(int idx); Xpm *GetRandom(); - [[nodiscard]] constexpr int Count() const noexcept { return count; } + constexpr int Count() const noexcept { return count; } }; extern Pixmaps PixmapList; @@ -379,7 +379,7 @@ extern long long RLLong() noexcept; extern int WFlt(Flt val) noexcept; extern Flt RFlt() noexcept; extern int WStr(const char* s, int len = 0); -extern genericChar* RStr(genericChar* s = nullptr); +extern genericChar* RStr(genericChar* s = NULL); extern int SendNow() noexcept; extern int ReloadTermFonts(); // Reload fonts when global defaults change void TerminalReloadFonts(); diff --git a/term/touch_screen.cc b/term/touch_screen.cc index d8882b91..722ee481 100644 --- a/term/touch_screen.cc +++ b/term/touch_screen.cc @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include #include @@ -124,7 +124,7 @@ TouchScreen::TouchScreen(const char* h, int p) // Move constructor TouchScreen::TouchScreen(TouchScreen&& other) noexcept - : buffer(other.buffer) + : buffer(std::move(other.buffer)) , size(other.size) , INIT(std::move(other.INIT)) , PING(std::move(other.PING)) @@ -142,10 +142,10 @@ TouchScreen::TouchScreen(TouchScreen&& other) noexcept , y_res(other.y_res) , last_x(other.last_x) , last_y(other.last_y) - , host(other.host) + , host(std::move(other.host)) , port(other.port) - , last_reset(other.last_reset) - , error(other.error) + , last_reset(std::move(other.last_reset)) + , error(std::move(other.error)) { other.device_no = 0; other.failed = 0; @@ -159,7 +159,7 @@ TouchScreen& TouchScreen::operator=(TouchScreen&& other) noexcept if (device_no > 0) close(device_no); - buffer = other.buffer; + buffer = std::move(other.buffer); size = other.size; INIT = std::move(other.INIT); PING = std::move(other.PING); @@ -177,10 +177,10 @@ TouchScreen& TouchScreen::operator=(TouchScreen&& other) noexcept y_res = other.y_res; last_x = other.last_x; last_y = other.last_y; - host = other.host; + host = std::move(other.host); port = other.port; - last_reset = other.last_reset; - error = other.error; + last_reset = std::move(other.last_reset); + error = std::move(other.error); other.device_no = 0; other.failed = 0; @@ -226,12 +226,12 @@ int TouchScreen::Connect(int boot) if (inaddr.sin_addr.s_addr == INADDR_NONE) { struct hostent *hp = gethostbyname(host.Value()); - if (hp == nullptr || hp->h_addrtype != AF_INET) + if (hp == NULL || hp->h_addrtype != AF_INET) { std::string str = std::string("Can't resolve name '") + host.Value() + "'"; error.Set(str.c_str()); - std::cerr << str << '\n'; + std::cerr << str << std::endl; return 1; } bcopy(hp->h_addr, &inaddr.sin_addr.s_addr, hp->h_length); @@ -242,7 +242,7 @@ int TouchScreen::Connect(int boot) { std::string str = "Can't open socket"; error.Set(str.c_str()); - std::cerr << str << '\n'; + std::cerr << str << std::endl; device_no = 0; return 1; } @@ -251,7 +251,7 @@ int TouchScreen::Connect(int boot) { std::string str = std::string("Connection refused with '") + host.Value() + "'"; - std::cerr << str << '\n'; + std::cerr << str << std::endl; error.Set(str.c_str()); close(device_no); device_no = 0; @@ -660,7 +660,7 @@ int TouchScreen::SaveCalibration(const char* filename) const file << calibration.offset_x << " " << calibration.offset_y << " " << calibration.scale_x << " " << calibration.scale_y << " " - << calibration.rotation << " " << calibration.calibrated << '\n'; + << calibration.rotation << " " << calibration.calibrated << std::endl; file.close(); return 0; diff --git a/tests/unit/test_check.cc b/tests/unit/test_check.cc index f6f2b701..5f43e6f5 100644 --- a/tests/unit/test_check.cc +++ b/tests/unit/test_check.cc @@ -1,6 +1,4 @@ #include -#include - #include "../mocks/mock_terminal.hh" #include "../mocks/mock_settings.hh" @@ -47,10 +45,10 @@ TEST_CASE("Basic arithmetic operations", "[arithmetic]") SECTION("Basic calculations for POS operations") { // Test basic arithmetic that would be used in POS calculations - const int subtotal = 1000; // $10.00 - const double tax_rate = 0.0825; // 8.25% - const int tax_amount = static_cast(std::lround(subtotal * tax_rate)); // Round to nearest cent - const int total = subtotal + tax_amount; + int subtotal = 1000; // $10.00 + float tax_rate = 0.0825f; // 8.25% + int tax_amount = static_cast(subtotal * tax_rate + 0.5f); // Round to nearest cent + int total = subtotal + tax_amount; REQUIRE(subtotal == 1000); REQUIRE(tax_amount == 83); // 1000 * 0.0825 + 0.5 = 82.5 + 0.5 = 83 diff --git a/tests/unit/test_enhanced_logging.cc b/tests/unit/test_enhanced_logging.cc index 40051c3c..75870a3b 100644 --- a/tests/unit/test_enhanced_logging.cc +++ b/tests/unit/test_enhanced_logging.cc @@ -2,7 +2,6 @@ #include "src/utils/vt_logger.hh" #include #include -#include #include #include #include @@ -279,12 +278,9 @@ TEST_CASE("Performance Monitoring", "[enhanced_logging][performance]") TEST_CASE("Log File Output", "[enhanced_logging][files]") { - // Use a unique test directory to avoid interference from other tests - const std::string test_log_dir = "/tmp/viewtouch_test_logs_file_output"; - // Clean up - fs::remove_all(test_log_dir); - vt::Logger::Initialize(test_log_dir); + fs::remove_all("/tmp/viewtouch_test_logs"); + vt::Logger::Initialize("/tmp/viewtouch_test_logs"); SECTION("Structured JSON logging") { @@ -297,9 +293,9 @@ TEST_CASE("Log File Output", "[enhanced_logging][files]") std::this_thread::sleep_for(std::chrono::milliseconds(100)); // Check structured log file - REQUIRE(fs::exists(test_log_dir + "/viewtouch_structured.log")); + REQUIRE(fs::exists("/tmp/viewtouch_test_logs/viewtouch_structured.log")); - std::ifstream structured_log(test_log_dir + "/viewtouch_structured.log"); + std::ifstream structured_log("/tmp/viewtouch_test_logs/viewtouch_structured.log"); std::string line; bool found_json = false; while (std::getline(structured_log, line)) { @@ -310,8 +306,6 @@ TEST_CASE("Log File Output", "[enhanced_logging][files]") } } REQUIRE(found_json); - - vt::Logger::Shutdown(); // Shutdown at end of this section } SECTION("Human-readable logging") @@ -322,9 +316,9 @@ TEST_CASE("Log File Output", "[enhanced_logging][files]") std::this_thread::sleep_for(std::chrono::milliseconds(100)); // Check regular log file - REQUIRE(fs::exists(test_log_dir + "/viewtouch.log")); + REQUIRE(fs::exists("/tmp/viewtouch_test_logs/viewtouch.log")); - std::ifstream regular_log(test_log_dir + "/viewtouch.log"); + std::ifstream regular_log("/tmp/viewtouch_test_logs/viewtouch.log"); std::string line; bool found_message = false; while (std::getline(regular_log, line)) { @@ -334,9 +328,9 @@ TEST_CASE("Log File Output", "[enhanced_logging][files]") } } REQUIRE(found_message); - - vt::Logger::Shutdown(); // Shutdown at end of this section } + + vt::Logger::Shutdown(); } TEST_CASE("Thread Safety", "[enhanced_logging][threading]") diff --git a/tests/unit/test_memory_modernization.cc b/tests/unit/test_memory_modernization.cc index 15b60f61..59900856 100644 --- a/tests/unit/test_memory_modernization.cc +++ b/tests/unit/test_memory_modernization.cc @@ -98,20 +98,27 @@ TEST_CASE("Memory Safety Improvements", "[safety]") // Smart pointers provide exception safety bool cleanup_happened = false; - auto safe_ptr = std::make_unique("Safe"); + try { + auto safe_ptr = std::make_unique("Safe"); - // Create a resource that needs cleanup - auto resource = new int(123); - auto wrapper = vt::make_raii(resource, [&](int* ptr) { - cleanup_happened = true; - delete ptr; - }); + // Create a resource that needs cleanup + auto resource = new int(123); + auto wrapper = vt::make_raii(resource, [&](int* ptr) { + cleanup_happened = true; + delete ptr; + }); + + REQUIRE(*safe_ptr == "Safe"); + REQUIRE(*wrapper == 123); + REQUIRE(!cleanup_happened); - REQUIRE(*safe_ptr == "Safe"); - REQUIRE(*wrapper == 123); - REQUIRE(!cleanup_happened); + // If an exception occurs here, both smart pointers still clean up + // throw std::runtime_error("Test exception"); - // Cleanup happens at end of scope via RAII + // If no exception, cleanup happens at end of scope + } catch (...) { + // Even if we catch exceptions, memory is cleaned up + } REQUIRE(cleanup_happened); // RAII wrapper was cleaned up } @@ -142,8 +149,6 @@ TEST_CASE("Memory Management Patterns", "[patterns]") { auto another_owner = shared_resource; - REQUIRE(another_owner != nullptr); - REQUIRE(*another_owner == "Shared"); REQUIRE(shared_resource.use_count() == 2); } diff --git a/version/main_print_version.cc b/version/main_print_version.cc index 6d1c74e5..3f88dcd8 100644 --- a/version/main_print_version.cc +++ b/version/main_print_version.cc @@ -7,12 +7,12 @@ int main(int, const char **) { std::cout << viewtouch::get_project_name() << " " << viewtouch::get_version_short() - << '\n'; + << std::endl; std::cout << viewtouch::get_project_name() << " " << viewtouch::get_version_long() - << '\n'; + << std::endl; std::cout << viewtouch::get_project_name() << " " << viewtouch::get_version_info() - << '\n'; + << std::endl; return 0; } diff --git a/zone/account_zone.cc b/zone/account_zone.cc index 776765e8..d983352c 100644 --- a/zone/account_zone.cc +++ b/zone/account_zone.cc @@ -37,7 +37,7 @@ AccountZone::AccountZone() { list_header = 2; //list_footer = 1; - account = nullptr; + account = NULL; show_list = 1; edit_default = 0; AddTextField(GlobalTranslate("Account Name"), 15); @@ -133,7 +133,7 @@ int AccountZone::LoadRecord(Terminal *term, int my_record_no) FormField *field = FieldList(); account = term->system_data->account_db.FindByRecord(my_record_no); - if (account != nullptr) + if (account != NULL) { // AddTextField("Account Name", 15, 0); field->Set(account->name.Value()); @@ -153,8 +153,7 @@ int AccountZone::SaveRecord(Terminal *term, int my_record_no, int write_file) int acct_no = 0; FnTrace("AccountZone::SaveRecord()"); - (void)my_record_no; - if (account != nullptr) + if (account != NULL) { FormField *field = FieldList(); field->Get(account->name); field = field->next; @@ -176,7 +175,7 @@ int AccountZone::NewRecord(Terminal *term) FnTrace("AccountZone::NewRecord()"); int acct_num = 0; - if (account != nullptr) + if (account != NULL) acct_num = account->number; account = term->system_data->account_db.NewAccount(acct_num); records = RecordCount(term); @@ -227,15 +226,15 @@ int AccountZone::ListReport(Terminal *term, Report *report) int indent = 0; int my_color = COLOR_DEFAULT; - if (report == nullptr) + if (report == NULL) return 1; AccountDB *account_db = &(term->system_data->account_db); report->Clear(); Account *acct = account_db->Next(); - if (acct == nullptr) + if (acct == NULL) report->TextC(GlobalTranslate("No Accounts Defined")); - while (acct != nullptr) + while (acct != NULL) { indent = 0; snprintf(buff, STRLENGTH, "%d", acct->number); @@ -271,7 +270,7 @@ int AccountZone::CheckAccountNumber(Terminal *term, int sendmsg) genericChar msggood[] = "clearstatus"; const genericChar* msgsend = msggood; - if (account != nullptr) + if (account != NULL) { acctnumfld->Get(number); if (! IsValidAccountNumber(term, number)) diff --git a/zone/account_zone.hh b/zone/account_zone.hh index 2d39e059..346fa72a 100644 --- a/zone/account_zone.hh +++ b/zone/account_zone.hh @@ -19,7 +19,7 @@ */ #ifndef _ACCOUNT_ZONE_HH -#define ACCOUNT_ZONE_HH +#define _ACCOUNT_ZONE_HH #include "form_zone.hh" @@ -38,21 +38,21 @@ public: AccountZone(); // Member Functions - int Type() override { return ZONE_ACCOUNT; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Keyboard(Terminal *term, int key, int state) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - SignalResult Mouse(Terminal *term, int action, int mx, int my) override; - - int LoadRecord(Terminal *term, int record_no) override; - int SaveRecord(Terminal *term, int record_no, int write_file) override; - int NewRecord(Terminal *term) override; - int KillRecord(Terminal *term, int record) override; - int PrintRecord(Terminal *term, int record) override; - int Search(Terminal *term, int record, const char* word) override; - int ListReport(Terminal *term, Report *report) override; - int RecordCount(Terminal *term) override; + int Type() { return ZONE_ACCOUNT; } + virtual RenderResult Render(Terminal *term, int update_flag); + virtual SignalResult Signal(Terminal *term, const genericChar* message); + virtual SignalResult Keyboard(Terminal *term, int key, int state); + virtual SignalResult Touch(Terminal *term, int tx, int ty); + virtual SignalResult Mouse(Terminal *term, int action, int mx, int my); + + int LoadRecord(Terminal *term, int record_no); + int SaveRecord(Terminal *term, int record_no, int write_file); + int NewRecord(Terminal *term); + int KillRecord(Terminal *term, int record); + int PrintRecord(Terminal *term, int record); + int Search(Terminal *term, int record, const char* word); + int ListReport(Terminal *term, Report *report); + int RecordCount(Terminal *term); int CheckAccountNumber(Terminal *term, int sendmsg = 1); }; diff --git a/zone/button_zone.cc b/zone/button_zone.cc index 6f5c8ead..82ec13ca 100644 --- a/zone/button_zone.cc +++ b/zone/button_zone.cc @@ -265,7 +265,7 @@ SignalResult MessageButtonZone::SendandJump(Terminal *term) SignalResult sig = SIGNAL_OKAY; char signal[STRLONG] = ""; char command[STRLONG] = VIEWTOUCH_PATH; - const char* validcommand = nullptr; + const char* validcommand = NULL; int len = 0; int idx = 0; @@ -283,7 +283,7 @@ SignalResult MessageButtonZone::SendandJump(Terminal *term) while (signal[idx] == ' ' && idx < len) idx++; validcommand = ValidateCommand(&signal[idx]); - if (validcommand != nullptr) + if (validcommand != NULL) { snprintf(command, STRLONG, "%s >%s 2>&1", validcommand, COMMAND_OUTPUT_FILE); system(command); @@ -359,7 +359,7 @@ SignalResult MessageButtonZone::Signal(Terminal *term, const char* signal_msg) SignalResult sig = SIGNAL_OKAY; const char* command_list[] = { "sendandjump", - "starttakeout", "pickup", "quicktogo", "quickdinein", "quickselforder", nullptr}; + "starttakeout", "pickup", "quicktogo", "quickdinein", "quickselforder", NULL}; Settings *settings = term->GetSettings(); int idx = CompareListN(command_list, signal_msg); @@ -370,24 +370,30 @@ SignalResult MessageButtonZone::Signal(Terminal *term, const char* signal_msg) sig = SendandJump(term); break; case 1: // starttakeout + if (term->QuickMode(CHECK_TAKEOUT)) + return SIGNAL_IGNORED; + term->Jump(JUMP_STEALTH, -8); + break; case 2: // pickup/delivery - { - int mode = (idx == 1) ? CHECK_TAKEOUT : CHECK_CALLIN; - if (term->QuickMode(mode)) - return SIGNAL_IGNORED; - term->Jump(JUMP_STEALTH, -8); + if (term->QuickMode(CHECK_CALLIN)) + return SIGNAL_IGNORED; + term->Jump(JUMP_STEALTH, -8); break; - } case 3: // quick to-go + if (term->QuickMode(CHECK_SELFTAKEOUT)) + return SIGNAL_IGNORED; + term->JumpToIndex(IndexValue[settings->MealPeriod(SystemTime)]); + break; case 4: // quick dine-in + if (term->QuickMode(CHECK_SELFDINEIN)) + return SIGNAL_IGNORED; + term->JumpToIndex(IndexValue[settings->MealPeriod(SystemTime)]); + break; case 5: // quick self-order - { - int mode = (idx == 3) ? CHECK_SELFTAKEOUT : (idx == 4 ? CHECK_SELFDINEIN : CHECK_SELFORDER); - if (term->QuickMode(mode)) - return SIGNAL_IGNORED; - term->JumpToIndex(IndexValue[settings->MealPeriod(SystemTime)]); + if (term->QuickMode(CHECK_SELFORDER)) + return SIGNAL_IGNORED; + term->JumpToIndex(IndexValue[settings->MealPeriod(SystemTime)]); break; - } default: sig = SIGNAL_IGNORED; break; @@ -407,7 +413,7 @@ SignalResult MessageButtonZone::Signal(Terminal *term, const char* signal_msg) char* MessageButtonZone::ValidateCommand(char* source) { FnTrace("MessageButtonZone::ValidCommand()"); - char* retval = nullptr; + char* retval = NULL; int len = static_cast(strlen(source)); int sidx = 0; char dest[STRLONG] = ""; @@ -416,7 +422,7 @@ char* MessageButtonZone::ValidateCommand(char* source) // do not allow the command to start with a dot. if (source[sidx] == '.') - return nullptr; + return NULL; while (sidx < len) { @@ -448,7 +454,7 @@ char* MessageButtonZone::ValidateCommand(char* source) } if (badchar) - retval = nullptr; + retval = NULL; else { dest[didx] = '\0'; @@ -466,7 +472,7 @@ static const genericChar* KeyWords[] = { "local", "supervisor", "manager", "editusers", "merchandise", "movetable", "tablepages", "passwords", "superuser", "payexpenses", "fastfood", "selforder", "lastendday", - "checkbalanced", "haspayments", "training", "selectedorder", nullptr}; + "checkbalanced", "haspayments", "training", "selectedorder", NULL}; enum comms { CHECK, GUESTS, SUBCHECKS, SETTLE, ORDER, DRAWER, DRAWERCOUNT, ORDERBYSEAT, DEVELOPER, FLOW, ASSIGNED, @@ -476,7 +482,7 @@ enum comms { CHECKBALANCED, HASPAYMENTS, TRAINING, SELECTORDER}; static const genericChar* OperatorWords[] = { - "=", ">", "<", "!=", ">=", nullptr}; + "=", ">", "<", "!=", ">=", NULL}; enum operators { EQUAL, GREATER, LESSER, NOTEQUAL, GREATEREQUAL }; @@ -539,19 +545,16 @@ SignalResult ConditionalZone::Touch(Terminal *term, int /*tx*/, int /*ty*/) FnTrace("ConditionalZone::Touch()"); SignalResult sig = SIGNAL_OKAY; - const char* to_send = nullptr; if (message.size() > 0) { // broadcast button's message - to_send = message.Value(); + sig = term->Signal(message.Value(), group_id); } else if (name.size() > 0) { // broadcast button's name - to_send = name.Value(); + sig = term->Signal(name.Value(), group_id); } - if (to_send) - sig = term->Signal(to_send, group_id); if (sig != SIGNAL_ERROR) term->Jump(jump_type, jump_id); @@ -659,8 +662,10 @@ int ConditionalZone::EvalExp(Terminal *term) n = e->CanPayExpenses(s); break; case FASTFOOD: // fastfood + n = (term->type == TERMINAL_FASTFOOD); + break; case SELFORDER: // selforder - n = (term->type == ((keyword == FASTFOOD) ? TERMINAL_FASTFOOD : TERMINAL_SELFORDER)); + n = (term->type == TERMINAL_SELFORDER); break; case LASTENDDAY: // lastendday if (term && term->system_data && term->system_data->CheckEndDay(term) > 0) @@ -819,18 +824,16 @@ RenderResult KillSystemZone::Render(Terminal *term, int update_flag) { FnTrace("KillSystemZone::Render()"); int users = term->OtherTermsInUse(1); - const char* label = nullptr; - genericChar str[32]; if (users <= 0) - label = name.Value(); + RenderZone(term, name.Value(), update_flag); else if (users == 1) - label = "1 Terminal Busy"; + RenderZone(term, "1 Terminal Busy", update_flag); else { + genericChar str[32]; vt_safe_string::safe_format(str, 32, "%d Terminals Busy", users); - label = str; + RenderZone(term, str, update_flag); } - RenderZone(term, label, update_flag); return RENDER_OKAY; } @@ -839,7 +842,7 @@ SignalResult KillSystemZone::Touch(Terminal *term, int /*tx*/, int /*ty*/) FnTrace("KillSystemZone::Touch()"); Employee *e = term->user; int users = term->OtherTermsInUse(); - if (users > 0 && (e == nullptr || !e->CanEdit())) + if (users > 0 && (e == NULL || !e->CanEdit())) return SIGNAL_IGNORED; SimpleDialog *d = @@ -858,7 +861,7 @@ int KillSystemZone::Update(Terminal *term, int update_message, const genericChar { Employee *e = term->user; int users = term->OtherTermsInUse(); - if (users > 0 && (e == nullptr || !e->CanEdit())) + if (users > 0 && (e == NULL || !e->CanEdit())) term->KillDialog(); return Draw(term, 1); } @@ -915,7 +918,7 @@ SignalResult ClearSystemZone::Signal(Terminal *term, const genericChar* message) { FnTrace("ClearSystemZone::Signal()"); - const genericChar* commands[] = {"clearsystemall", "clearsystemsome", "clearsystemcancel", nullptr}; + const genericChar* commands[] = {"clearsystemall", "clearsystemsome", "clearsystemcancel", NULL}; int idx = CompareList(message, commands); switch (idx) @@ -952,7 +955,7 @@ RenderResult StatusZone::Render(Terminal *term, int update_flag) SignalResult StatusZone::Signal(Terminal *term, const genericChar* message) { const genericChar* command_list[] = { - "status", "clearstatus", nullptr }; + "status", "clearstatus", NULL }; int idx = CompareListN(command_list, message); switch (idx) @@ -1110,7 +1113,7 @@ std::unique_ptr IndexTabZone::Copy() int IndexTabZone::CanSelect(Terminal *t) { FnTrace("IndexTabZone::CanSelect()"); - if (page == nullptr) + if (page == NULL) return 1; // Index Tab buttons can only exist on Index pages or be inherited by Menu Item pages @@ -1135,11 +1138,11 @@ int IndexTabZone::CanSelect(Terminal *t) int IndexTabZone::CanEdit(Terminal *t) { FnTrace("IndexTabZone::CanEdit()"); - if (page == nullptr) + if (page == NULL) return 1; Employee *e = t->user; - if (e == nullptr) + if (e == NULL) return 0; // Index Tab buttons can only be edited when on an Index page diff --git a/zone/button_zone.hh b/zone/button_zone.hh index 57b21626..cf879aab 100644 --- a/zone/button_zone.hh +++ b/zone/button_zone.hh @@ -19,7 +19,7 @@ */ #ifndef _BUTTON_ZONE_HH -#define BUTTON_ZONE_HH +#define _BUTTON_ZONE_HH #include "pos_zone.hh" #include "layout_zone.hh" @@ -35,15 +35,15 @@ public: ButtonZone(); // Member Functions - int Type() override { return ZONE_SIMPLE; } - int AcceptSignals() override { return 0; } - std::unique_ptr Copy() override; - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - int GainFocus(Terminal *term, Zone *oldfocus) override { return 0; } - - int *JumpType() override { return &jump_type; } - int *JumpID() override { return &jump_id; } + virtual int Type() { return ZONE_SIMPLE; } + virtual int AcceptSignals() { return 0; } + virtual std::unique_ptr Copy(); + virtual RenderResult Render(Terminal *term, int update_flag); + virtual SignalResult Touch(Terminal *term, int tx, int ty); + virtual int GainFocus(Terminal *term, Zone *oldfocus) { return 0; } + + int *JumpType() { return &jump_type; } + int *JumpID() { return &jump_id; } Str *ImagePath() { return PosZone::ImagePath(); } }; @@ -58,16 +58,16 @@ public: // Member Functions MessageButtonZone(); - int Type() override { return ZONE_STANDARD; } - int AcceptSignals() override { return 1; } - std::unique_ptr Copy() override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - SignalResult Signal(Terminal *term, const char* signal_msg) override; - char* ValidateCommand(char* command); - - Str *Message() override { return &message; } - int *Confirm() override { return &confirm; } - Str *ConfirmMsg() override { return &confirm_msg; } + virtual int Type() { return ZONE_STANDARD; } + virtual int AcceptSignals() { return 1; } + virtual std::unique_ptr Copy(); + virtual SignalResult Touch(Terminal *term, int tx, int ty); + virtual SignalResult Signal(Terminal *term, const char* signal_msg); + virtual char* ValidateCommand(char* command); + + Str *Message() { return &message; } + int *Confirm() { return &confirm; } + Str *ConfirmMsg() { return &confirm_msg; } }; class ConditionalZone : public MessageButtonZone @@ -80,14 +80,14 @@ public: ConditionalZone(); // Member Functions - int Type() override { return ZONE_CONDITIONAL; } - std::unique_ptr Copy() override; - int RenderInit(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - int Update(Terminal *term, int update_message, const genericChar* value) override; + int Type() { return ZONE_CONDITIONAL; } + std::unique_ptr Copy(); + int RenderInit(Terminal *term, int update_flag); + SignalResult Touch(Terminal *term, int tx, int ty); + int Update(Terminal *term, int update_message, const genericChar* value); - Str *Expression() override { return &expression; } - int ZoneStates() override { return 3; } + Str *Expression() { return &expression; } + int ZoneStates() { return 3; } int EvalExp(Terminal *term); }; @@ -103,36 +103,36 @@ public: ToggleZone(); // Member Functions - int Type() override { return ZONE_TOGGLE; } - int AcceptSignals() override { return 0; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - const genericChar* TranslateString(Terminal *term) override; - int GainFocus(Terminal *term, Zone *oldfocus) override { return 0; } - - Str *Message() override { return &message; } + int Type() { return ZONE_TOGGLE; } + virtual int AcceptSignals() { return 0; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Touch(Terminal *term, int tx, int ty); + const genericChar* TranslateString(Terminal *term); + virtual int GainFocus(Terminal *term, Zone *oldfocus) { return 0; } + + Str *Message() { return &message; } }; class CommentZone : public PosZone { public: // Member Functions - int Type() override { return ZONE_COMMENT; } - int AcceptSignals() override { return 0; } - int RenderInit(Terminal *term, int update_flag) override; - int ZoneStates() override { return 1; } - int GainFocus(Terminal *term, Zone *oldfocus) override { return 0; } + int Type() { return ZONE_COMMENT; } + virtual int AcceptSignals() { return 0; } + int RenderInit(Terminal *term, int update_flag); + int ZoneStates() { return 1; } + virtual int GainFocus(Terminal *term, Zone *oldfocus) { return 0; } }; class KillSystemZone : public PosZone { public: // Member Functions - int Type() override { return ZONE_KILL_SYSTEM; } - int AcceptSignals() override { return 0; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - int Update(Terminal *term, int update_message, const genericChar* value) override; + int Type() { return ZONE_KILL_SYSTEM; } + virtual int AcceptSignals() { return 0; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Touch(Terminal *term, int tx, int ty); + int Update(Terminal *term, int update_message, const genericChar* value); }; class ClearSystemZone : public PosZone @@ -144,12 +144,12 @@ public: ClearSystemZone(); // Member Functions - int Type() override { return ZONE_CLEAR_SYSTEM; } - int AcceptSignals() override { return 1; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - int GainFocus(Terminal *term, Zone *oldfocus) override { return 0; } + int Type() { return ZONE_CLEAR_SYSTEM; } + virtual int AcceptSignals() { return 1; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Touch(Terminal *term, int tx, int ty); + SignalResult Signal(Terminal *term, const genericChar* message); + virtual int GainFocus(Terminal *term, Zone *oldfocus) { return 0; } }; class StatusZone : public LayoutZone @@ -157,11 +157,11 @@ class StatusZone : public LayoutZone Str status; public: StatusZone(); - int Type() override { return ZONE_STATUS_BUTTON; } - int AcceptSignals() override { return 1; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - int GainFocus(Terminal *term, Zone *oldfocus) override { return 0; } + int Type() { return ZONE_STATUS_BUTTON; } + virtual int AcceptSignals() { return 1; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Signal(Terminal *term, const genericChar* message); + virtual int GainFocus(Terminal *term, Zone *oldfocus) { return 0; } }; class ImageButtonZone : public ButtonZone @@ -174,15 +174,15 @@ public: ImageButtonZone(); // Member Functions - int Type() override { return ZONE_IMAGE_BUTTON; } - int AcceptSignals() override { return 0; } - int CanSelect(Terminal *t) override; - int State(Terminal *t) override; // Override to always use normal state for consistent image colors - int ZoneStates() override; // Override to return 1 (no selection states) to skip selection logic - std::unique_ptr Copy() override; - int RenderInit(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - int GainFocus(Terminal *term, Zone *oldfocus) override { return 0; } + int Type() { return ZONE_IMAGE_BUTTON; } + virtual int AcceptSignals() { return 0; } + int CanSelect(Terminal *t); + int State(Terminal *t); // Override to always use normal state for consistent image colors + int ZoneStates(); // Override to return 1 (no selection states) to skip selection logic + std::unique_ptr Copy(); + int RenderInit(Terminal *term, int update_flag); + SignalResult Touch(Terminal *term, int tx, int ty); + virtual int GainFocus(Terminal *term, Zone *oldfocus) { return 0; } }; class IndexTabZone : public ButtonZone @@ -192,12 +192,12 @@ public: IndexTabZone(); // Member Functions - int Type() override { return ZONE_INDEX_TAB; } + int Type() { return ZONE_INDEX_TAB; } // Inherit AcceptSignals from ButtonZone (same as Simple buttons) - int CanSelect(Terminal *t) override; - int CanEdit(Terminal *t) override; - std::unique_ptr Copy() override; - int GainFocus(Terminal *term, Zone *oldfocus) override { return 0; } + int CanSelect(Terminal *t); + int CanEdit(Terminal *t); + std::unique_ptr Copy(); + virtual int GainFocus(Terminal *term, Zone *oldfocus) { return 0; } }; class LanguageButtonZone : public ButtonZone @@ -207,11 +207,11 @@ public: LanguageButtonZone(); // Member Functions - int Type() override { return ZONE_LANGUAGE_BUTTON; } - std::unique_ptr Copy() override; - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - int GainFocus(Terminal *term, Zone *oldfocus) override { return 0; } + int Type() { return ZONE_LANGUAGE_BUTTON; } + std::unique_ptr Copy(); + RenderResult Render(Terminal *term, int update_flag); + SignalResult Touch(Terminal *term, int tx, int ty); + virtual int GainFocus(Terminal *term, Zone *oldfocus) { return 0; } }; #endif diff --git a/zone/cdu_zone.cc b/zone/cdu_zone.cc index b8dad5eb..cbd76d15 100644 --- a/zone/cdu_zone.cc +++ b/zone/cdu_zone.cc @@ -41,17 +41,17 @@ CDUZone::CDUZone() AddSubmit("Submit", 10); record_no = -1; - report = nullptr; + report = NULL; page = 0; no_line = 1; lines_shown = 0; show_item = 0; - cdustring = nullptr; + cdustring = NULL; } CDUZone::~CDUZone() { - if (report != nullptr) + if (report != NULL) delete report; } @@ -78,9 +78,9 @@ RenderResult CDUZone::Render(Terminal *term, int update_flag) TextL(term, header_line, term->Translate("First Line"), col); TextPosL(term, num_spaces, header_line, term->Translate("Second Line"), col); - if (update || update_flag || (report == nullptr)) + if (update || update_flag || (report == NULL)) { - if (report != nullptr) + if (report != NULL) delete report; report = new Report; ListReport(term, report); @@ -108,7 +108,7 @@ SignalResult CDUZone::Signal(Terminal *term, const genericChar* message) FnTrace("CDUZone::Signal()"); SignalResult signal = SIGNAL_IGNORED; static const genericChar* commands[] = {"next", "prior", "change view", - "restore", "new", nullptr}; + "restore", "new", NULL}; int idx = CompareListN(commands, message); int draw = 0; @@ -183,7 +183,7 @@ SignalResult CDUZone::Touch(Terminal *term, int tx, int ty) FnTrace("CDUZone::Touch()"); SignalResult retval = SIGNAL_IGNORED; - if (report != nullptr) + if (report != NULL) { FormZone::Touch(term, tx, ty); int yy = report->TouchLine(list_spacing, selected_y); @@ -243,14 +243,14 @@ int CDUZone::UpdateForm(Terminal *term, int record) genericChar cduline[STRLENGTH]; FormField *field = FieldList(); - if (cdustring == nullptr || show_item == 0) + if (cdustring == NULL || show_item == 0) return 1; while (idx < MAX_CDU_LINES && changed == 0) { field->Get(formline); cdustring->GetLine(cduline, idx); - if (strcmp(formline.Value(), cduline) != 0) + if (strcmp(formline.Value(), cduline)) { changed = 1; cdustring->SetLine(formline, idx); @@ -260,10 +260,10 @@ int CDUZone::UpdateForm(Terminal *term, int record) } if (changed) { - if (report != nullptr) + if (report != NULL) { delete report; - report = nullptr; + report = NULL; } update = 1; } @@ -275,7 +275,7 @@ int CDUZone::HideFields() FnTrace("CDUZone::HideFields()"); FormField *field = FieldList(); - while (field != nullptr) + while (field != NULL) { field->active = 0; field = field->next; @@ -288,7 +288,7 @@ int CDUZone::ShowFields() FnTrace("CDUZone::ShowFields()"); FormField *field = FieldList(); - while (field != nullptr) + while (field != NULL) { field->active = 1; field = field->next; @@ -305,13 +305,13 @@ int CDUZone::LoadRecord(Terminal *term, int record) if (show_item) cdustring = term->system_data->cdustrings.FindByRecord(record); else - cdustring = nullptr; + cdustring = NULL; - if (cdustring != nullptr) + if (cdustring != NULL) { record_no = record; // save off the cdustring for Undo - if (saved_cdustring == nullptr) + if (saved_cdustring == NULL) saved_cdustring = new CDUString; saved_cdustring->Copy(cdustring); @@ -340,7 +340,7 @@ int CDUZone::SaveRecord(Terminal *term, int record, int write_file) FormField *field = FieldList(); Str buffer; - if (cdustring != nullptr) + if (cdustring != NULL) { field->Get(buffer); cdustring->SetLine(buffer, 0); @@ -353,10 +353,10 @@ int CDUZone::SaveRecord(Terminal *term, int record, int write_file) records = RecordCount(term); if (record_no >= records) record_no = records - 1; - if (report != nullptr) + if (report != NULL) delete report; - report = nullptr; - cdustring = nullptr; + report = NULL; + cdustring = NULL; show_item = 0; update = 1; return 0; @@ -366,7 +366,7 @@ int CDUZone::RestoreRecord(Terminal *term) { FnTrace("CDUZone::RestoreRecord()"); - if (cdustring != nullptr && saved_cdustring != nullptr) + if (cdustring != NULL && saved_cdustring != NULL) { cdustring->Copy(saved_cdustring); LoadRecord(term, record_no); @@ -396,7 +396,7 @@ int CDUZone::KillRecord(Terminal *term, int record) { term->system_data->cdustrings.Remove(delstr); delete delstr; - cdustring = nullptr; + cdustring = NULL; records = RecordCount(term); if (record_no > records) record_no = records - 1; @@ -437,7 +437,7 @@ int CDUZone::Search(Terminal *term, int record, const genericChar* word) record_no = -1; show_item = 0; delete report; - report = nullptr; + report = NULL; } return 1; } @@ -455,7 +455,7 @@ int CDUZone::ListReport(Terminal *term, Report *my_report) if (records < 1) my_report->TextC("No Messages Entered", col); - while (currString != nullptr) + while (currString != NULL) { for (idx = 0; idx < 2; idx++) { diff --git a/zone/cdu_zone.hh b/zone/cdu_zone.hh index e746d92d..e7d5beb4 100644 --- a/zone/cdu_zone.hh +++ b/zone/cdu_zone.hh @@ -20,7 +20,7 @@ */ #ifndef _CDU_ZONE_HH -#define CDU_ZONE_HH +#define _CDU_ZONE_HH #include "cdu.hh" #include "form_zone.hh" @@ -41,30 +41,30 @@ class CDUZone : public FormZone CDUString *saved_cdustring; public: CDUZone(); - ~CDUZone() override; + ~CDUZone(); - int Type() override { return ZONE_CDU; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - int Update(Terminal *term, int update_message, const genericChar* value) override + int Type() { return ZONE_CDU; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Signal(Terminal *term, const genericChar* message); + SignalResult Touch(Terminal *term, int tx, int ty); + int Update(Terminal *term, int update_message, const genericChar* value) { return FormZone::Update( term, update_message, value); } - int UpdateForm(Terminal *term, int record) override; + int UpdateForm(Terminal *term, int record); int HideFields(); int ShowFields(); - Flt *Spacing() override { return &list_spacing; } + Flt *Spacing() { return &list_spacing; } int ColumnSpacing(Terminal *term, int num_columns); - int LoadRecord(Terminal *term, int record) override; - int SaveRecord(Terminal *term, int record, int write_file) override; + int LoadRecord(Terminal *term, int record); + int SaveRecord(Terminal *term, int record, int write_file); int RestoreRecord(Terminal *term); - int NewRecord(Terminal *term) override; - int KillRecord(Terminal *term, int record) override; - int PrintRecord(Terminal *term, int record) override; - int Search(Terminal *term, int record, const genericChar* word) override; + int NewRecord(Terminal *term); + int KillRecord(Terminal *term, int record); + int PrintRecord(Terminal *term, int record); + int Search(Terminal *term, int record, const genericChar* word); int ListReport(Terminal *term, Report *report); - int RecordCount(Terminal *term) override; + int RecordCount(Terminal *term); }; #endif diff --git a/zone/chart_zone.cc b/zone/chart_zone.cc index 85c41027..15f9e03d 100644 --- a/zone/chart_zone.cc +++ b/zone/chart_zone.cc @@ -31,7 +31,7 @@ // Constructor ChartZone::ChartZone() { - chart = nullptr; + chart = NULL; } // Destructor diff --git a/zone/chart_zone.hh b/zone/chart_zone.hh index 0038a497..4dff57cc 100644 --- a/zone/chart_zone.hh +++ b/zone/chart_zone.hh @@ -19,7 +19,7 @@ */ #ifndef _CHART_ZONE_HH -#define CHART_ZONE_HH +#define _CHART_ZONE_HH #include "pos_zone.hh" #include "list_utility.hh" @@ -36,17 +36,16 @@ public: // Constructor ChartZone(); // Destructor - ~ChartZone() override; + ~ChartZone(); // Member Functions - int Type() override { return ZONE_CHART; } - std::unique_ptr Copy() override; - - int RenderInit(Terminal *t, int update_flag) override; - RenderResult Render(Terminal *t, int update_flag) override; - SignalResult Signal(Terminal *t, const genericChar* message) override; - SignalResult Touch(Terminal *t, int tx, int ty) override; - using PosZone::Update; // bring base overloads into scope + int Type() { return ZONE_CHART; } + std::unique_ptr Copy(); + + int RenderInit(Terminal *t, int update_flag); + RenderResult Render(Terminal *t, int update_flag); + SignalResult Signal(Terminal *t, const genericChar* message); + SignalResult Touch(Terminal *t, int tx, int ty); int Update(Terminal *t, int update_message); }; diff --git a/zone/check_list_zone.cc b/zone/check_list_zone.cc index 0d443944..f46439fd 100644 --- a/zone/check_list_zone.cc +++ b/zone/check_list_zone.cc @@ -50,7 +50,7 @@ enum checkList_types { }; const char* CLName[] = { - "All", "Open", "Take Out", "Closed", "Fast Food", nullptr}; + "All", "Open", "Take Out", "Closed", "Fast Food", NULL}; int CLValue[] = { CL_ALL, CL_OPEN, CL_TAKEOUT, CL_CLOSED, CL_FASTFOOD, -1}; @@ -75,7 +75,7 @@ RenderResult CheckListZone::Render(Terminal *term, int update_flag) LayoutZone::Render(term, update_flag); Employee *e = term->user; - if (e == nullptr) + if (e == NULL) return RENDER_OKAY; // Set up display check list @@ -124,7 +124,7 @@ RenderResult CheckListZone::Render(Terminal *term, int update_flag) status = CL_OPEN; if (term->GetSettings()->drawer_mode == DRAWER_SERVER) - term->server = nullptr; + term->server = NULL; } MakeList(term); } @@ -149,9 +149,9 @@ RenderResult CheckListZone::Render(Terminal *term, int update_flag) vt_safe_string::safe_format(str, 128, "%s Checks", str2); TextC(term, 1, str, col); - if (term->archive == nullptr) + if (term->archive == NULL) { - if ((term->server == nullptr && e->training) || + if ((term->server == NULL && e->training) || (term->server && term->server->training)) vt_safe_string::safe_copy(str, 128, term->Translate("Current Training Checks")); else @@ -183,9 +183,7 @@ RenderResult CheckListZone::Render(Terminal *term, int update_flag) if (max_pages > 1) TextL(term, size_y - 1, term->PageNo(page_no + 1, max_pages), col); - Flt line = HEADER_SIZE; - - const bool is_open_like = (status == CL_OPEN || status == CL_TAKEOUT || status == CL_FASTFOOD); + Flt line = HEADER_SIZE; if (array_size <= 0) { if (status == CL_ALL) @@ -249,9 +247,9 @@ RenderResult CheckListZone::Render(Terminal *term, int update_flag) vt_safe_string::safe_format(str, 128, "%d", c->Guests()); TextPosL(term, x1, line, str, tc); - if (is_open_like) - term->TimeDate(str, c->time_open, TD_TIME); - else + if (status == CL_OPEN || status == CL_TAKEOUT || status == CL_FASTFOOD) + term->TimeDate(str, c->time_open, TD_TIME); + else { TimeInfo time_close; time_close.Set(c->TimeClosed()); @@ -274,10 +272,10 @@ SignalResult CheckListZone::Signal(Terminal *term, const genericChar* message) { FnTrace("CheckListZone::Signal()"); static const genericChar* commands[] = { - "status", "resend", nullptr}; + "status", "resend", NULL}; Employee *e = term->user; - if (e == nullptr) + if (e == NULL) return SIGNAL_IGNORED; Check *c = term->check; @@ -293,27 +291,18 @@ SignalResult CheckListZone::Signal(Terminal *term, const genericChar* message) c->FinalizeOrders(term, 1); break; default: - { - int off = -1; - Employee *start = nullptr; if (strncmp(message, "search ", 7) == 0) { - off = 7; + if (Search(term, &message[7], NULL) <= 0) + return SIGNAL_IGNORED; } else if (strncmp(message, "nextsearch ", 11) == 0) { - off = 11; - start = term->server; + if (Search(term, &message[11], term->server) <= 0) + return SIGNAL_IGNORED; } else - { return SIGNAL_IGNORED; - } - - if (Search(term, &message[off], start) <= 0) - return SIGNAL_IGNORED; - break; - } } Draw(term, 1); @@ -379,7 +368,7 @@ int CheckListZone::MakeList(Terminal *term) array_size = 0; Employee *e = term->user; - if (e == nullptr) + if (e == NULL) return 1; Employee *server = term->server; @@ -389,7 +378,7 @@ int CheckListZone::MakeList(Terminal *term) while (c) { int okay = 0; - if ((server == nullptr && (e->training == c->IsTraining() || a)) || + if ((server == NULL && (e->training == c->IsTraining() || a)) || (server && server->training == c->IsTraining() && server->id == c->user_owner)) { @@ -444,7 +433,7 @@ int CheckListZone::Search(Terminal *term, const genericChar* emp_name, Employee * CheckEditZone class ********************************************************************/ -const genericChar* CHECK_TypesChar[] = { "Take Out", "Delivery", "Catering", nullptr }; +const genericChar* CHECK_TypesChar[] = { "Take Out", "Delivery", "Catering", NULL }; int CHECK_TypesInt[] = { CHECK_TAKEOUT, CHECK_DELIVERY, CHECK_CATERING, -1 }; CheckEditZone::CheckEditZone() { @@ -460,9 +449,9 @@ CheckEditZone::CheckEditZone() lines_shown = 5; page = 1; - check = nullptr; + check = NULL; my_update = 1; - report = nullptr; + report = NULL; view = -1; // -1 represents Show All AddTimeDateField("TakeOut/Delivery Date"); @@ -471,7 +460,8 @@ CheckEditZone::CheckEditZone() } CheckEditZone::~CheckEditZone() -= default; +{ +} RenderResult CheckEditZone::Render(Terminal *term, int update_flag) { @@ -484,16 +474,16 @@ RenderResult CheckEditZone::Render(Terminal *term, int update_flag) { check = term->check; LoadRecord(term, 0); - if (report != nullptr) + if (report != NULL) free(report); - report = nullptr; + report = NULL; my_update = 0; } - if (check == nullptr) + if (check == NULL) fields_active = 0; FormField *field = FieldList(); - while (field != nullptr) + while (field != NULL) { field->active = fields_active; field = field->next; @@ -515,7 +505,7 @@ SignalResult CheckEditZone::Keyboard(Terminal *term, int my_key, int state) FnTrace("CheckEditZone::Keyboard()"); SignalResult retval = SIGNAL_OKAY; - if ((check != nullptr) && (check->GetStatus() == CHECK_OPEN)) + if ((check != NULL) && (check->GetStatus() == CHECK_OPEN)) retval = FormZone::Keyboard(term, my_key, state); else retval = SIGNAL_IGNORED; @@ -528,7 +518,7 @@ SignalResult CheckEditZone::Touch(Terminal *term, int tx, int ty) FnTrace("CheckEditZone::Touch()"); SignalResult retval = SIGNAL_OKAY; - if ((check != nullptr) && (check->GetStatus() == CHECK_OPEN)) + if ((check != NULL) && (check->GetStatus() == CHECK_OPEN)) retval = FormZone::Touch(term, tx, ty); else retval = SIGNAL_IGNORED; @@ -541,7 +531,7 @@ SignalResult CheckEditZone::Mouse(Terminal *term, int action, int mx, int my) FnTrace("CheckEditZone::Mouse()"); SignalResult retval = SIGNAL_OKAY; - if ((check != nullptr) && (check->GetStatus() == CHECK_OPEN)) + if ((check != NULL) && (check->GetStatus() == CHECK_OPEN)) retval = FormZone::Mouse(term, action, mx, my); else retval = SIGNAL_IGNORED; @@ -555,14 +545,14 @@ SignalResult CheckEditZone::Mouse(Terminal *term, int action, int mx, int my) Check *GetNextCheck(Check *current) { FnTrace("GetNextCheck()"); - Check *retval = nullptr; + Check *retval = NULL; - if (current != nullptr) + if (current != NULL) current = current->next; else current = MasterSystem->CheckList(); - while (current != nullptr && retval == nullptr) + while (current != NULL && retval == NULL) { // Don't want to limit this to only takeouts // if (current->GetStatus() == CHECK_OPEN && current->IsTakeOut()) @@ -580,14 +570,14 @@ Check *GetNextCheck(Check *current) Check *GetPriorCheck(Check *current) { FnTrace("GetPriorCheck()"); - Check *retval = nullptr; + Check *retval = NULL; - if (current != nullptr) + if (current != NULL) current = current->fore; else current = MasterSystem->CheckListEnd(); - while (current != nullptr && retval == nullptr) + while (current != NULL && retval == NULL) { // Don't want to limit this to only takeouts // if (current->GetStatus() == CHECK_OPEN && current->IsTakeOut()) @@ -604,47 +594,48 @@ SignalResult CheckEditZone::Signal(Terminal *term, const genericChar* message) FnTrace("CheckEditZone::Signal()"); SignalResult retval = SIGNAL_OKAY; static const genericChar* commands[] = { "next", "prior", "change view", "search", - "nextsearch", "save", nullptr}; + "nextsearch", "save", NULL}; int idx = CompareListN(commands, message); int draw = 0; switch (idx) { case 0: //next - if (check != nullptr) + if (check != NULL) SaveRecord(term, 0, 1); term->check = GetNextCheck(term->check); - if (term->check != nullptr && term->check->customer != nullptr) + if (term->check != NULL && term->check->customer != NULL) term->customer = term->check->customer; else - term->customer = nullptr; + term->customer = NULL; draw = 2; - check = nullptr; + check = NULL; break; case 1: //prior - if (check != nullptr) + if (check != NULL) SaveRecord(term, 0, 1); term->check = GetPriorCheck(term->check); - if (term->check != nullptr && term->check->customer != nullptr) + if (term->check != NULL && term->check->customer != NULL) term->customer = term->check->customer; else - term->customer = nullptr; + term->customer = NULL; draw = 2; - check = nullptr; + check = NULL; break; case 2: //change view break; - case 3: // search + case 3: //search + if (Search(term, -1, &message[7]) <= 0) + retval = SIGNAL_IGNORED; + else + draw = 1; + break; case 4: // nextsearch - { - int start = (idx == 3) ? -1 : record_no; - int off = (idx == 3) ? 7 : 11; // skip prefix length - if (Search(term, start, &message[off]) <= 0) + if (Search(term, record_no, &message[11]) <= 0) retval = SIGNAL_IGNORED; else draw = 1; break; - } case 5: // save // We also need to save the customer info. We'll assume CustomerInfoZone // is at group 1, but in the future this should not be necessary. @@ -674,7 +665,7 @@ int CheckEditZone::LoseFocus(Terminal *term, Zone *newfocus) FnTrace("CheckEditZone::LoseFocus()"); int retval = 0; - keyboard_focus = nullptr; + keyboard_focus = NULL; Draw(term, 0); return retval; @@ -689,7 +680,7 @@ int CheckEditZone::LoadRecord(Terminal *term, int record) // this prevented the user being able to add customer information to a check that was not // a takeout order. Some customers want to do name/number all the time. // if (check != NULL && check->GetStatus() == CHECK_OPEN && check->IsTakeOut()) - if (check != nullptr && check->GetStatus() == CHECK_OPEN) + if (check != NULL && check->GetStatus() == CHECK_OPEN) { fields->Set(check->Date()); fields = fields->next; @@ -699,14 +690,14 @@ int CheckEditZone::LoadRecord(Terminal *term, int record) fields->Set(check->Comment()); } - else if (term->check != nullptr) + else if (term->check != NULL) { // We have a non-takeout check. Clear it and redraw everything. We have // to redraw because there are likely other check displays (check report) // on the screen and we don't know if they've already been drawn. To // keep everything synchronized, we make sure all zones displays the // term->check = NULL situation. - term->check = nullptr; + term->check = NULL; term->Draw(1); } @@ -723,9 +714,9 @@ int CheckEditZone::SaveRecord(Terminal *term, int record, int write_file) genericChar buffer[STRLONG]; // Verify we only save open takeout checks (no tables) - if ((check != nullptr) && (check->GetStatus() == CHECK_OPEN) && check->IsTakeOut()) + if ((check != NULL) && (check->GetStatus() == CHECK_OPEN) && check->IsTakeOut()) { - if (term->customer != nullptr) + if (term->customer != NULL) term->customer->Save(); fields->Get(date); @@ -739,9 +730,9 @@ int CheckEditZone::SaveRecord(Terminal *term, int record, int write_file) fields->Get(buffer); check->Comment(buffer); - if (check->customer == nullptr || check->customer->IsBlank() || !term->customer->IsBlank()) + if (check->customer == NULL || check->customer->IsBlank() || !term->customer->IsBlank()) check->customer = term->customer; - if (check->customer != nullptr) + if (check->customer != NULL) check->customer_id = check->customer->CustomerID(); else check->customer_id = -1; @@ -773,7 +764,7 @@ int CheckEditZone::RecordCount(Terminal *term) FnTrace("CheckEditZone::RecordCount()"); int retval = 0; - if (check != nullptr) + if (check != NULL) retval = 1; return retval; diff --git a/zone/check_list_zone.hh b/zone/check_list_zone.hh index 62277a4f..97dcc0ea 100644 --- a/zone/check_list_zone.hh +++ b/zone/check_list_zone.hh @@ -19,7 +19,7 @@ */ #ifndef _CHECK_LIST_ZONE_HH -#define CHECK_LIST_ZONE_HH +#define _CHECK_LIST_ZONE_HH #include "form_zone.hh" #include "layout_zone.hh" @@ -46,12 +46,12 @@ public: CheckListZone(); // Member Functions - int Type() override { return ZONE_CHECK_LIST; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - int Update(Terminal *term, int update_message, const genericChar* value) override; - Flt *Spacing() override { return &spacing; } + int Type() { return ZONE_CHECK_LIST; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Signal(Terminal *term, const genericChar* message); + SignalResult Touch(Terminal *term, int tx, int ty); + int Update(Terminal *term, int update_message, const genericChar* value); + Flt *Spacing() { return &spacing; } int MakeList(Terminal *term); int Search(Terminal *term, const genericChar* name, Employee *start); @@ -71,23 +71,23 @@ class CheckEditZone : public FormZone public: CheckEditZone(); - ~CheckEditZone() override; + ~CheckEditZone(); - int Type() override { return ZONE_CHECK_EDIT; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Keyboard(Terminal *term, int my_key, int state) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - SignalResult Mouse(Terminal *term, int action, int mx, int my) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - int LoseFocus(Terminal *term, Zone *newfocus) override; + int Type() { return ZONE_CHECK_EDIT; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Keyboard(Terminal *term, int my_key, int state); + SignalResult Touch(Terminal *term, int tx, int ty); + SignalResult Mouse(Terminal *term, int action, int mx, int my); + SignalResult Signal(Terminal *term, const genericChar* message); + int LoseFocus(Terminal *term, Zone *newfocus); - Flt *Spacing() override { return &list_spacing; } + Flt *Spacing() { return &list_spacing; } - int LoadRecord(Terminal *term, int record) override; - int SaveRecord(Terminal *term, int record, int write_file) override; - int Search(Terminal *term, int record, const genericChar* word) override; + int LoadRecord(Terminal *term, int record); + int SaveRecord(Terminal *term, int record, int write_file); + int Search(Terminal *term, int record, const genericChar* word); int ListReport(Terminal *term, Report *report); - int RecordCount(Terminal *term) override; + int RecordCount(Terminal *term); }; #endif diff --git a/zone/creditcard_list_zone.cc b/zone/creditcard_list_zone.cc index 67931c54..5693cb11 100644 --- a/zone/creditcard_list_zone.cc +++ b/zone/creditcard_list_zone.cc @@ -42,12 +42,12 @@ CreditCardListZone::CreditCardListZone() { FnTrace("CreditCardListZone::CreditCardListZone()"); - report = nullptr; - credit = nullptr; + report = NULL; + credit = NULL; mode = MODE_EXCEPTIONS; no_line = 1; creditdb = MasterSystem->cc_exception_db.get(); - archive = nullptr; + archive = NULL; lines_shown = 0; list_footer = 1; } @@ -69,13 +69,13 @@ RenderResult CreditCardListZone::Render(Terminal *term, int update_flag) if (update_flag == RENDER_NEW) { - credit = nullptr; - archive = nullptr; + credit = NULL; + archive = NULL; mode = MODE_EXCEPTIONS; creditdb = MasterSystem->cc_exception_db.get(); } - ListFormZone::Render(term, update_flag); + FormZone::Render(term, update_flag); if (mode == MODE_EXCEPTIONS) name.Set(term->Translate("Exceptions")); @@ -95,17 +95,17 @@ RenderResult CreditCardListZone::Render(Terminal *term, int update_flag) indent += num_spaces; TextPosL(term, indent, header_line, term->Translate("Status"), col); - if (update || update_flag || (report == nullptr)) + if (update || update_flag || (report == NULL)) { - if (report != nullptr) + if (report != NULL) delete report; report = new Report; ListReport(term, report); } - if (report != nullptr) + if (report != NULL) { - if (credit != nullptr) + if (credit != NULL) report->selected_line = record_no; else report->selected_line = -1; @@ -128,17 +128,17 @@ SignalResult CreditCardListZone::Signal(Terminal *term, const genericChar* messa SignalResult retval = SIGNAL_OKAY; static const char* commands[] = {"ccexceptions", "ccrefunds", "ccvoids", "next", "prev", "nextperiod", "prevperiod", - "process", nullptr}; + "process", NULL}; int idx = CompareListN(commands, message); - CreditCardDialog *ccdialog = nullptr; + CreditCardDialog *ccdialog = NULL; switch (idx) { case 0: // ccexception if (mode != MODE_EXCEPTIONS) { - credit = nullptr; - archive = nullptr; + credit = NULL; + archive = NULL; record_no = -1; creditdb = term->system_data->cc_exception_db.get(); mode = MODE_EXCEPTIONS; @@ -147,8 +147,8 @@ SignalResult CreditCardListZone::Signal(Terminal *term, const genericChar* messa case 1: // ccrefund if (mode != MODE_REFUNDS) { - credit = nullptr; - archive = nullptr; + credit = NULL; + archive = NULL; record_no = -1; creditdb = term->system_data->cc_refund_db.get(); mode = MODE_REFUNDS; @@ -157,8 +157,8 @@ SignalResult CreditCardListZone::Signal(Terminal *term, const genericChar* messa case 2: // ccvoid if (mode != MODE_VOIDS) { - credit = nullptr; - archive = nullptr; + credit = NULL; + archive = NULL; record_no = -1; creditdb = term->system_data->cc_void_db.get(); mode = MODE_VOIDS; @@ -178,16 +178,16 @@ SignalResult CreditCardListZone::Signal(Terminal *term, const genericChar* messa break; case 5: // nextperiod creditdb = NextCreditDB(term); - credit = nullptr; + credit = NULL; record_no = -1; break; case 6: // prevperiod creditdb = PrevCreditDB(term); - credit = nullptr; + credit = NULL; record_no = -1; break; case 7: // process - if (credit != nullptr) + if (credit != NULL) { term->credit = credit; ccdialog = new CreditCardDialog(term); @@ -209,9 +209,9 @@ SignalResult CreditCardListZone::Touch(Terminal *term, int tx, int ty) FnTrace("CreditCardListZone::Touch()"); SignalResult retval = SIGNAL_IGNORED; - if (report != nullptr) + if (report != NULL) { - ListFormZone::Touch(term, tx, ty); + FormZone::Touch(term, tx, ty); int yy = report->TouchLine(list_spacing, selected_y); int max_page = report->max_pages; int new_page = page; @@ -225,7 +225,7 @@ SignalResult CreditCardListZone::Touch(Terminal *term, int tx, int ty) else if (yy == -2) { // bottom of form: page down if (selected_y > (size_y - 2.0)) - return ListFormZone::Touch(term, tx, ty); + return FormZone::Touch(term, tx, ty); ++new_page; if (new_page >= max_page) @@ -253,10 +253,10 @@ int CreditCardListZone::LoadRecord(Terminal *term, int record) FnTrace("CreditCardListZone::LoadRecord()"); int retval = 1; - if (creditdb != nullptr) + if (creditdb != NULL) credit = creditdb->FindByRecord(term, record); - if (credit != nullptr) + if (credit != NULL) record_no = record; else record_no = -1; @@ -336,21 +336,37 @@ int CreditCardListZone::RecordCount(Terminal *term) CreditDB *CreditCardListZone::GetDB(int in_system) { FnTrace("CreditCardListZone::GetDB()"); - CreditDB *retval = nullptr; + CreditDB *retval = NULL; if (in_system) { - retval = (mode == MODE_EXCEPTIONS) ? MasterSystem->cc_exception_db.get() - : (mode == MODE_REFUNDS) ? MasterSystem->cc_refund_db.get() - : (mode == MODE_VOIDS) ? MasterSystem->cc_void_db.get() - : nullptr; + switch (mode) + { + case MODE_EXCEPTIONS: + retval = MasterSystem->cc_exception_db.get(); + break; + case MODE_REFUNDS: + retval = MasterSystem->cc_refund_db.get(); + break; + case MODE_VOIDS: + retval = MasterSystem->cc_void_db.get(); + break; + } } - else if (archive != nullptr) + else if (archive != NULL) { - retval = (mode == MODE_EXCEPTIONS) ? archive->cc_exception_db - : (mode == MODE_REFUNDS) ? archive->cc_refund_db - : (mode == MODE_VOIDS) ? archive->cc_void_db - : nullptr; + switch (mode) + { + case MODE_EXCEPTIONS: + retval = archive->cc_exception_db; + break; + case MODE_REFUNDS: + retval = archive->cc_refund_db; + break; + case MODE_VOIDS: + retval = archive->cc_void_db; + break; + } } return retval; @@ -359,30 +375,30 @@ CreditDB *CreditCardListZone::GetDB(int in_system) CreditDB *CreditCardListZone::NextCreditDB(Terminal *term) { FnTrace("CreditCardListZone::NextCreditDB()"); - CreditDB *retval = nullptr; + CreditDB *retval = NULL; int loops = 0; - if (creditdb == nullptr) + if (creditdb == NULL) retval = GetDB(FROM_SYSTEM); else { while (loops < MAX_LOOPS) { - if (archive == nullptr) + if (archive == NULL) archive = MasterSystem->ArchiveList(); else { do { archive = archive->next; - } while (archive != nullptr && GetDB(FROM_ARCHIVE) == nullptr); + } while (archive != NULL && GetDB(FROM_ARCHIVE) == NULL); } - if (archive != nullptr) + if (archive != NULL) retval = GetDB(FROM_ARCHIVE); else retval = GetDB(FROM_SYSTEM); - loops += ((retval == nullptr) ? 1 : MAX_LOOPS); + loops += ((retval == NULL) ? 1 : MAX_LOOPS); } } @@ -392,30 +408,30 @@ CreditDB *CreditCardListZone::NextCreditDB(Terminal *term) CreditDB *CreditCardListZone::PrevCreditDB(Terminal *term) { FnTrace("CreditCardListZone::PrevCreditDB()"); - CreditDB *retval = nullptr; + CreditDB *retval = NULL; int loops = 0; - if (creditdb == nullptr) + if (creditdb == NULL) retval = GetDB(FROM_SYSTEM); else { while (loops < MAX_LOOPS) { - if (archive == nullptr) + if (archive == NULL) archive = MasterSystem->ArchiveListEnd(); else { do { archive = archive->fore; - } while (archive != nullptr && GetDB(FROM_ARCHIVE) == nullptr); + } while (archive != NULL && GetDB(FROM_ARCHIVE) == NULL); } - if (archive != nullptr) + if (archive != NULL) retval = GetDB(FROM_ARCHIVE); else retval = GetDB(FROM_SYSTEM); - loops += ((retval == nullptr) ? 1 : MAX_LOOPS); + loops += ((retval == NULL) ? 1 : MAX_LOOPS); } } diff --git a/zone/creditcard_list_zone.hh b/zone/creditcard_list_zone.hh index fbe712b2..eaada679 100644 --- a/zone/creditcard_list_zone.hh +++ b/zone/creditcard_list_zone.hh @@ -39,24 +39,24 @@ class CreditCardListZone : public ListFormZone public: CreditCardListZone(); - ~CreditCardListZone() override; + ~CreditCardListZone(); - int Type() override { return ZONE_CREDITCARD_LIST; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; + int Type() { return ZONE_CREDITCARD_LIST; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Signal(Terminal *term, const genericChar* message); + SignalResult Touch(Terminal *term, int tx, int ty); - Flt *Spacing() override { return &list_spacing; } + Flt *Spacing() { return &list_spacing; } - int LoadRecord(Terminal *term, int record) override; - int SaveRecord(Terminal *term, int record, int write_file) override; + int LoadRecord(Terminal *term, int record); + int SaveRecord(Terminal *term, int record, int write_file); int RestoreRecord(Terminal *term); - int NewRecord(Terminal *term) override; - int KillRecord(Terminal *term, int record) override; - int PrintRecord(Terminal *term, int record) override; - int Search(Terminal *term, int record, const genericChar* word) override; - int ListReport(Terminal *term, Report *report) override; - int RecordCount(Terminal *term) override; + int NewRecord(Terminal *term); + int KillRecord(Terminal *term, int record); + int PrintRecord(Terminal *term, int record); + int Search(Terminal *term, int record, const genericChar* word); + int ListReport(Terminal *term, Report *report); + int RecordCount(Terminal *term); CreditDB *GetDB(int in_system = 1); CreditDB *NextCreditDB(Terminal *term); CreditDB *PrevCreditDB(Terminal *term); diff --git a/zone/dialog_zone.cc b/zone/dialog_zone.cc index badcfda9..34b13503 100644 --- a/zone/dialog_zone.cc +++ b/zone/dialog_zone.cc @@ -122,7 +122,7 @@ int ButtonObj::Render(Terminal *term) ********************************************************************/ DialogZone::DialogZone() { - target_zone = nullptr; + target_zone = NULL; target_index = 0; target_signal[0] = '\0'; color[0] = COLOR_BLACK; @@ -188,9 +188,6 @@ int DialogZone::ClosingAction(int action_type, int action, int arg) cancel_action.type = action; cancel_action.arg = arg; break; - default: - // Unknown action type, ignore - break; } return retval; @@ -211,9 +208,6 @@ int DialogZone::ClosingAction(int action_type, int action, const char* message) cancel_action.type = action; strncpy(cancel_action.msg, message, STRLENGTH); break; - default: - // Unknown action type, ignore - break; } return retval; @@ -342,7 +336,7 @@ int SimpleDialog::RenderInit(Terminal * /*term*/, int /*update_flag*/) RenderResult SimpleDialog::Render(Terminal *term, int update_flag) { FnTrace("SimpleDialog::Render()"); - RenderZone(term, nullptr, update_flag); + RenderZone(term, NULL, update_flag); int bx = 0; int by = 0; int bw = 0; @@ -375,11 +369,11 @@ RenderResult SimpleDialog::Render(Terminal *term, int update_flag) bx = x + border; // last button, if odd number of buttons, is width of dialog // minus border width * 2 - if (zo->next == nullptr && (buttons.Count() % 2)) + if (zo->next == NULL && (buttons.Count() % 2)) bw = w - (border * 2); zo->font = zofont; zo->Layout(term, bx, by, bw, btn_height); - if (((z % 2) == 0) && zo->next != nullptr) + if (((z % 2) == 0) && zo->next != NULL) by += btn_height + gap; z += 1; zo = zo->next; @@ -399,7 +393,7 @@ RenderResult SimpleDialog::Render(Terminal *term, int update_flag) bx = x + border; else bx += bw + gap; - if (zo->next == nullptr) + if (zo->next == NULL) { if (z == 1) bw = w - (border * 2); @@ -408,7 +402,7 @@ RenderResult SimpleDialog::Render(Terminal *term, int update_flag) } zo->font = zofont; zo->Layout(term, bx, by, bw, btn_height); - if (z == 3 && zo->next != nullptr) + if (z == 3 && zo->next != NULL) { by += btn_height + gap; z = 1; @@ -427,7 +421,7 @@ SignalResult SimpleDialog::Touch(Terminal *term, int tx, int ty) { FnTrace("SimpleDialog::Touch()"); ZoneObject *zo = buttons.List(); - if (zo == nullptr || ty < zo->y) + if (zo == NULL || ty < zo->y) return SIGNAL_TERMINATE; zo = buttons.Find(tx, ty); @@ -454,7 +448,7 @@ UnitAmountDialog::UnitAmountDialog(const char* title, UnitAmount &u) FnTrace("UnitAmountDialog::UnitAmountDialog()"); int i; - lit = nullptr; + lit = NULL; name.Set(title); buffer[0] = '\0'; if (u.amount != 0.0) @@ -512,7 +506,7 @@ UnitAmountDialog::UnitAmountDialog(const char* title, UnitAmount &u) { UnitAmount tmp; tmp.type = ul[units]; - unit[units] = Button(tmp.Measurement(), nullptr); + unit[units] = Button(tmp.Measurement(), NULL); ut[units] = tmp.type; ++units; } @@ -527,15 +521,15 @@ RenderResult UnitAmountDialog::Render(Terminal *term, int update_flag) int i; if (update_flag) - lit = nullptr; + lit = NULL; if (lit) { lit->Draw(term, 0); - lit = nullptr; + lit = NULL; return RENDER_OKAY; } - DialogZone::Render(term, update_flag); + LayoutZone::Render(term, update_flag); // Layout buttons int gap = 8; @@ -624,7 +618,7 @@ SignalResult UnitAmountDialog::Touch(Terminal *term, int tx, int ty) { if (lit) lit->Draw(term, 0); - lit = nullptr; + lit = NULL; unit_type = ut[i]; Draw(term, 0); return SIGNAL_OKAY; @@ -639,7 +633,7 @@ SignalResult UnitAmountDialog::Signal(Terminal *term, const genericChar* message FnTrace("UnitAmountDialog::Signal()"); static const genericChar* command[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".", - "enter", "backspace", "cancel", nullptr}; + "enter", "backspace", "cancel", NULL}; int idx = CompareList(message, command); if (idx < 0) @@ -689,16 +683,16 @@ SignalResult UnitAmountDialog::Signal(Terminal *term, const genericChar* message SignalResult UnitAmountDialog::Keyboard(Terminal *term, int my_key, int state) { FnTrace("UnitAmountDialog::Keyboard()"); - const char* action = nullptr; switch (my_key) { - case 27: action = "cancel"; break; // ESC - case 13: action = "enter"; break; // return - case 8: action = "backspace"; break; // backspace - default: break; + case 27: // ESC + return Signal(term, "cancel"); + case 13: // return + return Signal(term, "enter"); + case 8: // backspace + return Signal(term, "backspace"); } - if (action) - return Signal(term, action); + genericChar str[] = {(char) my_key, '\0'}; return Signal(term, str); } @@ -729,7 +723,7 @@ TenKeyDialog::TenKeyDialog() FnTrace("TenKeyDialog::TenKeyDialog()"); int i; - lit = nullptr; + lit = NULL; name.Set(GlobalTranslate("Enter Amount")); buffer = 0; max_amount = 100000; @@ -744,7 +738,7 @@ TenKeyDialog::TenKeyDialog() key[10] = Button(GlobalTranslate("Enter"), "enter"); key[11] = Button(GlobalTranslate("Back Space"), "backspace"); key[12] = Button(GlobalTranslate("Cancel"), "cancel"); - key[13] = nullptr; + key[13] = NULL; w = 420; h = 580; @@ -757,7 +751,7 @@ TenKeyDialog::TenKeyDialog(const char* title, int amount, int cancel, int dp) FnTrace("TenKeyDialog::TenKeyDialog(const char* , int, int, int)"); int i; - lit = nullptr; + lit = NULL; name.Set(title); buffer = amount; max_amount = 100000; @@ -774,11 +768,11 @@ TenKeyDialog::TenKeyDialog(const char* title, int amount, int cancel, int dp) if (cancel) key[12] = Button(GlobalTranslate("Cancel"), "cancel"); else - key[12] = nullptr; + key[12] = NULL; // the decimal will be automatic, so we won't show the button. decimal = dp; - key[13] = nullptr; + key[13] = NULL; w = 420; h = 580; @@ -791,7 +785,7 @@ TenKeyDialog::TenKeyDialog(const char* title, const char* retmsg, int amount, in FnTrace("TenKeyDialog::TenKeyDialog(const char* , const char* , int, int)"); int i; - lit = nullptr; + lit = NULL; name.Set(title); buffer = amount; max_amount = 100000; @@ -809,7 +803,7 @@ TenKeyDialog::TenKeyDialog(const char* title, const char* retmsg, int amount, in // the decimal will be automatic, so we won't show the button. decimal = dp; - key[13] = nullptr; + key[13] = NULL; w = 420; h = 580; @@ -823,15 +817,15 @@ RenderResult TenKeyDialog::Render(Terminal *term, int update_flag) int i; if (update_flag) - lit = nullptr; + lit = NULL; if (lit) { lit->Draw(term, 0); - lit = nullptr; + lit = NULL; return RENDER_OKAY; } - DialogZone::Render(term, update_flag); + LayoutZone::Render(term, update_flag); first_row_y = y + first_row; // Layout Buttons @@ -902,7 +896,7 @@ SignalResult TenKeyDialog::Signal(Terminal *term, const genericChar* message) FnTrace("TenKeyDialog::Signal()"); static const genericChar* command[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", - "enter", "backspace", "cancel", nullptr}; + "enter", "backspace", "cancel", NULL}; int idx = CompareList(message, command); if (idx < 0) @@ -937,16 +931,16 @@ SignalResult TenKeyDialog::Signal(Terminal *term, const genericChar* message) SignalResult TenKeyDialog::Keyboard(Terminal *term, int my_key, int state) { FnTrace("TenKeyDialog::Keyboard()"); - const char* action = nullptr; switch (my_key) { - case 27: action = "cancel"; break; // ESC - case 13: action = "enter"; break; // return - case 8: action = "backspace"; break; // backspace - default: break; + case 27: // ESC + return Signal(term, "cancel"); + case 13: // return + return Signal(term, "enter"); + case 8: // backspace + return Signal(term, "backspace"); } - if (action) - return Signal(term, action); + genericChar str[] = {(char) my_key, '\0'}; return Signal(term, str); } @@ -986,7 +980,7 @@ GetTextDialog::GetTextDialog() FnTrace("GetTextDialog::GetTextDialog()"); int i; - lit = nullptr; + lit = NULL; w = 950; h = 680; hh = 90; @@ -1020,7 +1014,7 @@ GetTextDialog::GetTextDialog(const char* msg, const char* retmsg, int mlen) FnTrace("GetTextDialog::GetTextDialog(const char* )"); int i; - lit = nullptr; + lit = NULL; w = 950; h = 680; hh = 90; @@ -1055,15 +1049,15 @@ RenderResult GetTextDialog::Render(Terminal *term, int update_flag) RenderResult retval = RENDER_OKAY; if (update_flag) - lit = nullptr; + lit = NULL; if (lit) { lit->Draw(term, 0); - lit = nullptr; + lit = NULL; return RENDER_OKAY; } - DialogZone::Render(term, update_flag); + LayoutZone::Render(term, update_flag); first_row_y = y + first_row; // Layout buttons @@ -1143,7 +1137,7 @@ SignalResult GetTextDialog::Signal(Terminal *term, const genericChar* message) FnTrace("GetTextDialog::Signal()"); SignalResult retval = SIGNAL_OKAY; static const genericChar* commands[] = { - "backspace", "clear", "enter", "cancel", nullptr}; + "backspace", "clear", "enter", "cancel", NULL}; int idx = CompareList(message, commands); int error = 0; genericChar msgbuf[STRLENGTH]; @@ -1206,19 +1200,21 @@ SignalResult GetTextDialog::Keyboard(Terminal *term, int my_key, int state) FnTrace("GetTextDialog::Keyboard()"); SignalResult retval = SIGNAL_IGNORED; - const char* action = nullptr; switch (my_key) { - case 8: action = "backspace"; break; // Backspace - case 13: action = "enter"; break; // Enter - case 27: action = "cancel"; break; // Esc - default: break; - } - if (action) - return Signal(term, action); - { + case 8: // Backspace + retval = Signal(term, "backspace"); + break; + case 13: // Enter + retval = Signal(term, "enter"); + break; + case 27: // Esc + retval = Signal(term, "cancel"); + break; + default: genericChar str[] = {(char) my_key, '\0'}; retval = Signal(term, str); + break; } return retval; @@ -1366,7 +1362,7 @@ SignalResult PasswordDialog::Signal(Terminal *term, const genericChar* message) { FnTrace("PasswordDialog::Signal()"); static const genericChar* commands[] = { - "enter", "change", "cancel", nullptr}; + "enter", "change", "cancel", NULL}; Employee *e = term->user; int error = 0; @@ -1407,7 +1403,7 @@ SignalResult PasswordDialog::Signal(Terminal *term, const genericChar* message) return SIGNAL_OKAY; case 3: - if (StringCompare(new_password, buffer) || e == nullptr) + if (StringCompare(new_password, buffer) || e == NULL) PasswordFailed(term); else { @@ -1516,8 +1512,8 @@ SignalResult CreditCardAmountDialog::Signal(Terminal *term, const genericChar* m { FnTrace("CreditCardAmountDialog::Signal()"); SignalResult retval = SIGNAL_IGNORED; - static const genericChar* command[] = { "cancel", "enter", nullptr }; - CreditCardDialog *ccm = nullptr; + static const genericChar* command[] = { "cancel", "enter", NULL }; + CreditCardDialog *ccm = NULL; int idx = CompareList(message, command); switch (idx) @@ -1529,15 +1525,15 @@ SignalResult CreditCardAmountDialog::Signal(Terminal *term, const genericChar* m if (cct_type == CC_REFUND) ccm = new CreditCardDialog(term, AUTH_REFUND, REFUND_MSG); else - ccm = new CreditCardDialog(term, 0, nullptr); + ccm = new CreditCardDialog(term, 0, NULL); term->NextDialog(ccm); - if (idx == 1 && term->credit != nullptr) + if (idx == 1 && term->credit != NULL) { if (cct_type == CC_TIP) { term->credit->Tip(buffer); if (term->GetSettings()->auto_authorize && - term->credit != nullptr && + term->credit != NULL && term->credit->IsPreauthed()) { term->auth_action = AUTH_COMPLETE; @@ -1575,7 +1571,7 @@ CreditCardEntryDialog::CreditCardEntryDialog() cc_expire[0] = '\0'; max_expire = 5; // 'mm/yy' == 4 + 1 current = cc_num; - last_current = nullptr; + last_current = NULL; max_current = max_num; curr_entry = &entry_pos[0]; } @@ -1677,10 +1673,10 @@ SignalResult CreditCardEntryDialog::Signal(Terminal *term, const genericChar* me FnTrace("CreditCardEntryDialog::Signal()"); static const genericChar* command[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", - "enter", "backspace", "cancel", nullptr }; + "enter", "backspace", "cancel", NULL }; int len; SignalResult retval = SIGNAL_OKAY; - CreditCardDialog *ccm = nullptr; + CreditCardDialog *ccm = NULL; int idx = CompareList(message, command); if (idx < 0) @@ -1708,7 +1704,7 @@ SignalResult CreditCardEntryDialog::Signal(Terminal *term, const genericChar* me } break; case 11: // backspace - if (current != nullptr) + if (current != NULL) { len = strlen(current); if (current[len - 1] == ' ' || current[len - 1] == '/') @@ -1723,7 +1719,7 @@ SignalResult CreditCardEntryDialog::Signal(Terminal *term, const genericChar* me retval = SIGNAL_TERMINATE; break; default: - if (current != nullptr) + if (current != NULL) { len = strlen(current); if (len < max_current) @@ -1842,12 +1838,12 @@ CreditCardVoiceDialog::CreditCardVoiceDialog(const char* msg, const char* retmsg { FnTrace("CreditCardVoiceDialog::CreditCardVoiceDialog(const char* , const char* , int)"); - if (msg != nullptr) + if (msg != NULL) vt_safe_string::safe_copy(display_string, STRLENGTH, msg); else vt_safe_string::safe_copy(display_string, STRLENGTH, CCVD_DISPLAY); - if (retmsg != nullptr) + if (retmsg != NULL) vt_safe_string::safe_copy(return_message, STRLENGTH, retmsg); else vt_safe_string::safe_copy(return_message, STRLENGTH, CCVD_RETURN); @@ -1857,7 +1853,8 @@ CreditCardVoiceDialog::CreditCardVoiceDialog(const char* msg, const char* retmsg } CreditCardVoiceDialog::~CreditCardVoiceDialog() -= default; +{ +} RenderResult CreditCardVoiceDialog::Render(Terminal *term, int update_flag) { @@ -1887,10 +1884,10 @@ SignalResult CreditCardVoiceDialog::Signal(Terminal *term, const genericChar* me FnTrace("CreditCardVoiceDialog::Signal()"); SignalResult retval = SIGNAL_OKAY; static const genericChar* commands[] = { - "enter", "cancel", nullptr}; + "enter", "cancel", NULL}; int idx = CompareList(message, commands); int error = 0; - CreditCardDialog *ccm = nullptr; + CreditCardDialog *ccm = NULL; switch (idx) { @@ -1932,8 +1929,8 @@ CreditCardDialog::CreditCardDialog() FnTrace("CreditCardDialog::CreditCardDialog()"); authorizing = AUTH_NONE; - SetMessage(nullptr, nullptr, nullptr); - Init(nullptr, nullptr, nullptr); + SetMessage(NULL, NULL, NULL); + Init(NULL, NULL, NULL); } CreditCardDialog::CreditCardDialog(Terminal *term, const char* swipe_value) @@ -1941,8 +1938,8 @@ CreditCardDialog::CreditCardDialog(Terminal *term, const char* swipe_value) FnTrace("CreditCardDialog::CreditCardDialog(Terminal, const char* )"); authorizing = AUTH_NONE; - SetMessage(nullptr, nullptr, nullptr); - Init(term, nullptr, swipe_value); + SetMessage(NULL, NULL, NULL); + Init(term, NULL, swipe_value); } CreditCardDialog::CreditCardDialog(Terminal *term, SubCheck *subch, const char* swipe_value) @@ -1950,7 +1947,7 @@ CreditCardDialog::CreditCardDialog(Terminal *term, SubCheck *subch, const char* FnTrace("CreditCardDialog::CreditCardDialog(Terminal, SubCheck, const char* )"); authorizing = AUTH_NONE; - SetMessage(nullptr, nullptr, nullptr); + SetMessage(NULL, NULL, NULL); Init(term, subch, swipe_value); } @@ -1960,10 +1957,10 @@ CreditCardDialog::CreditCardDialog(Terminal *term, int action, const char* messa const char* swipe_msg = WAIT_MSG; authorizing = action; - if (term != nullptr && term->credit != nullptr && term->credit->CardType() == CARD_TYPE_DEBIT) + if (term != NULL && term->credit != NULL && term->credit->CardType() == CARD_TYPE_DEBIT) swipe_msg = SWIPE_MSG; SetMessage(term, message, swipe_msg); - Init(term, nullptr, nullptr); + Init(term, NULL, NULL); } @@ -1998,8 +1995,8 @@ void CreditCardDialog::Init(Terminal *term, SubCheck *subch, const char* swipe_v clear_key = Button("Clear", "ccclear"); voice_key = Button("Voice Authorization", "ccvoice"); - lit = nullptr; - saved_credit = nullptr; + lit = NULL; + saved_credit = NULL; declined = 0; finalizing = 0; from_swipe = 0; @@ -2014,17 +2011,17 @@ void CreditCardDialog::Init(Terminal *term, SubCheck *subch, const char* swipe_v name.Set("CCM"); last_message[0] = '\0'; - if (term != nullptr) + if (term != NULL) { - if (subch != nullptr) + if (subch != NULL) term->pending_subcheck = subch; - if (swipe_value != nullptr) + if (swipe_value != NULL) { - if (term->credit != nullptr) + if (term->credit != NULL) term->credit->ParseSwipe(swipe_value); else ProcessSwipe(term, swipe_value); - if (term->credit != nullptr && term->credit->IsValid() && + if (term->credit != NULL && term->credit->IsValid() && term->auth_action == 0 && !term->credit->IsAuthed() && !term->credit->IsPreauthed() && @@ -2040,9 +2037,9 @@ void CreditCardDialog::Init(Terminal *term, SubCheck *subch, const char* swipe_v if (term->credit->CardType() == CARD_TYPE_NONE) from_swipe = 1; else - SetAction(term, AUTH_PICK, nullptr); + SetAction(term, AUTH_PICK, NULL); } - } else if (term->credit != nullptr && + } else if (term->credit != NULL && term->auth_voice.size() > 0 && term->credit->GetStatus() == CC_STATUS_NONE) { @@ -2059,13 +2056,13 @@ const char* CreditCardDialog::SetMessage(Terminal *term, const char* msg1, const { FnTrace("SetMessage()"); - if (msg1 == nullptr) + if (msg1 == NULL) { message_str[0] = '\0'; } - else if (term != nullptr) + else if (term != NULL) { - if (msg2 == nullptr) + if (msg2 == NULL) { if (term->credit->CardType() == CARD_TYPE_DEBIT) msg2 = SWIPE_MSG; @@ -2080,7 +2077,7 @@ const char* CreditCardDialog::SetMessage(Terminal *term, const char* msg1, const } else { - if (msg2 == nullptr) + if (msg2 == NULL) msg2 = WAIT_MSG; snprintf(message_str, STRLENGTH, "%s...%s", msg1, msg2); } @@ -2105,7 +2102,7 @@ RenderResult CreditCardDialog::Render(Terminal *term, int update_flag) Flt space = 0.7; Flt line = 0.0; Settings *settings = term->GetSettings(); - SubCheck *sc = nullptr; + SubCheck *sc = NULL; Employee *employee = term->user; [[maybe_unused]] int ismanager = 0; // Reserved for future use int font_color; @@ -2119,38 +2116,38 @@ RenderResult CreditCardDialog::Render(Terminal *term, int update_flag) message_line = 4; - if (term->pending_subcheck != nullptr) + if (term->pending_subcheck != NULL) sc = term->pending_subcheck; - else if (term->check != nullptr) + else if (term->check != NULL) sc = term->check->current_sub; - if (employee != nullptr && employee->IsManager(settings)) + if (employee != NULL && employee->IsManager(settings)) ismanager = 1; - if (sc != nullptr && sc->TotalTip() > 0) + if (sc != NULL && sc->TotalTip() > 0) have_tip = 1; - if (lit != nullptr) + if (lit != NULL) { lit->Draw(term, 0); - lit = nullptr; + lit = NULL; } - DialogZone::Render(term, update_flag); + LayoutZone::Render(term, update_flag); - if (term->credit == nullptr && + if (term->credit == NULL && finalizing == 0 && settings->CanDoDebit() == 0 && settings->CanDoGift() == 0) { term->credit = new Credit(); - if (term->credit != nullptr) + if (term->credit != NULL) term->credit->SetCardType(CARD_TYPE_CREDIT); } // First, find out what amount should go on the credit card and // initiate an action if all is done (card is valid and we haven't // already initiated action). - if (term->credit != nullptr) + if (term->credit != NULL) { if (term->auth_amount > 0) { @@ -2158,7 +2155,7 @@ RenderResult CreditCardDialog::Render(Terminal *term, int update_flag) } else if (term->credit->Amount() == 0) { - if (sc != nullptr) + if (sc != NULL) { sc->FigureTotals(settings); term->credit->Amount(sc->balance); @@ -2179,7 +2176,7 @@ RenderResult CreditCardDialog::Render(Terminal *term, int update_flag) have_tip) { authorizing = AUTH_AUTHORIZE; - if (term->auth_message != nullptr) + if (term->auth_message != NULL) SetMessage(term, term->auth_message, term->auth_message2); else SetMessage(term, AUTHORIZE_MSG); @@ -2187,7 +2184,7 @@ RenderResult CreditCardDialog::Render(Terminal *term, int update_flag) else { authorizing = AUTH_PREAUTH; - if (term->auth_message != nullptr) + if (term->auth_message != NULL) SetMessage(term, term->auth_message, term->auth_message2); else SetMessage(term, PREAUTH_MSG); @@ -2199,7 +2196,7 @@ RenderResult CreditCardDialog::Render(Terminal *term, int update_flag) } // Render the top information (cc#, expiry, name) - if (term->credit != nullptr && term->credit->IsValid()) + if (term->credit != NULL && term->credit->IsValid()) { status = term->credit->GetStatus(); @@ -2251,7 +2248,7 @@ RenderResult CreditCardDialog::Render(Terminal *term, int update_flag) } // Do we at least have an error message of some sort? - if (term->credit != nullptr && authorizing == 0) + if (term->credit != NULL && authorizing == 0) { str[0] = '\0'; // Initialize to ensure it's not garbage if (term->credit->IsVoided()) @@ -2297,7 +2294,7 @@ RenderResult CreditCardDialog::Render(Terminal *term, int update_flag) bypos = y + h - (bshort + bborder); // display buttons - if (term->credit == nullptr || + if (term->credit == NULL || term->credit->CardType() == CARD_TYPE_NONE) { TextC(term, query_line, term->Translate("Please select card type."), color_text); @@ -2492,11 +2489,11 @@ SignalResult CreditCardDialog::Touch(Terminal *term, int tx, int ty) SignalResult retval = SIGNAL_IGNORED; ZoneObject *zo = buttons.Find(tx, ty); - if (zo != nullptr) + if (zo != NULL) { if (lit) lit->Draw(term, 0); - lit = nullptr; + lit = NULL; ButtonObj *b = (ButtonObj *) zo; b->Draw(term, 1); retval = Signal(term, b->message.Value()); @@ -2512,7 +2509,7 @@ int CreditCardDialog::SetAction(Terminal *term, int action, const char* msg1, co FnTrace("CreditCardDialog::SetAction()"); int retval = 1; - if (term->credit != nullptr) + if (term->credit != NULL) { saved_credit = term->credit->Copy(); if (term->credit->RequireSwipe()) @@ -2539,12 +2536,12 @@ int CreditCardDialog::ClearAction(Terminal *term, int all) term->auth_amount = 0; term->auth_action = AUTH_NONE; term->auth_swipe = 0; - term->auth_message = nullptr; - term->auth_message2 = nullptr; + term->auth_message = NULL; + term->auth_message2 = NULL; term->auth_voice.Clear(); authorizing = 0; - SetMessage(nullptr, nullptr, nullptr); + SetMessage(NULL, NULL, NULL); last_message[0] = '\0'; return retval; @@ -2554,12 +2551,12 @@ int CreditCardDialog::DialogDone(Terminal *term) { int retval = 0; - if (term->credit != nullptr) + if (term->credit != NULL) { FinishCreditCard(term); term->Signal("ccamountchanged", 0); - term->credit = nullptr; - term->pending_subcheck = nullptr; + term->credit = NULL; + term->pending_subcheck = NULL; ClearAction(term); PrepareForClose(ACTION_SUCCESS); } @@ -2575,12 +2572,12 @@ SignalResult CreditCardDialog::Signal(Terminal *term, const genericChar* message "ccvoid", "ccrefund", "ccaddtip", "cccancel", "ccmanual", "ccdone", "ccprocessed", "cccredit", "ccdebit", "ccswipe", "ccundorefund", "ccclear", - "ccvoice", "ccadvice", nullptr }; + "ccvoice", "ccadvice", NULL }; int idx = CompareListN(commands, message); - CreditCardEntryDialog *cce = nullptr; - CreditCardAmountDialog *cct = nullptr; - CreditCardVoiceDialog *ccv = nullptr; - SimpleDialog *sd = nullptr; + CreditCardEntryDialog *cce = NULL; + CreditCardAmountDialog *cct = NULL; + CreditCardVoiceDialog *ccv = NULL; + SimpleDialog *sd = NULL; int draw = 0; Settings *settings = term->GetSettings(); @@ -2591,12 +2588,12 @@ SignalResult CreditCardDialog::Signal(Terminal *term, const genericChar* message settings->auto_authorize == 1) { if (term->auth_action == AUTH_NONE) - SetAction(term, AUTH_PICK, nullptr); + SetAction(term, AUTH_PICK, NULL); } draw = 1; break; case 1: // ccauthorize - if (term->credit != nullptr) + if (term->credit != NULL) { SetAction(term, AUTH_AUTHORIZE, AUTHORIZE_MSG); draw = 1; @@ -2605,7 +2602,7 @@ SignalResult CreditCardDialog::Signal(Terminal *term, const genericChar* message retval = SIGNAL_TERMINATE; break; case 2: // ccpreauth - if (term->credit != nullptr) + if (term->credit != NULL) { SetAction(term, AUTH_PREAUTH, PREAUTH_MSG); draw = 1; @@ -2614,7 +2611,7 @@ SignalResult CreditCardDialog::Signal(Terminal *term, const genericChar* message retval = SIGNAL_TERMINATE; break; case 3: // cccomplete - if (term->credit != nullptr) + if (term->credit != NULL) { SetAction(term, AUTH_COMPLETE, COMPLETE_MSG); draw = 1; @@ -2624,7 +2621,7 @@ SignalResult CreditCardDialog::Signal(Terminal *term, const genericChar* message if (term->user->IsManager(settings)) { term->auth_amount = term->void_amount; - if (term->credit != nullptr) + if (term->credit != NULL) { SetAction(term, AUTH_VOID, VOID_MSG); draw = 1; @@ -2643,7 +2640,7 @@ SignalResult CreditCardDialog::Signal(Terminal *term, const genericChar* message case 5: // ccrefund if (term->user->IsManager(settings)) { - if (term->credit != nullptr) + if (term->credit != NULL) { SetAction(term, AUTH_REFUND, REFUND_MSG); draw = 1; @@ -2667,7 +2664,7 @@ SignalResult CreditCardDialog::Signal(Terminal *term, const genericChar* message retval = SIGNAL_TERMINATE; break; case 7: // cccancel - if (term->credit != nullptr) + if (term->credit != NULL) { if (term->credit->IsAuthed(1)) { @@ -2676,7 +2673,7 @@ SignalResult CreditCardDialog::Signal(Terminal *term, const genericChar* message } else { - term->credit = nullptr; + term->credit = NULL; retval = SIGNAL_TERMINATE; } } @@ -2697,7 +2694,7 @@ SignalResult CreditCardDialog::Signal(Terminal *term, const genericChar* message case 10: // ccprocessed retval = ProcessCreditCard(term); ClearAction(term); - if (term->credit != nullptr && + if (term->credit != NULL && term->credit->IsAuthed() && settings->auto_authorize) { @@ -2706,11 +2703,11 @@ SignalResult CreditCardDialog::Signal(Terminal *term, const genericChar* message draw = 1; break; case 11: // cccredit - if (term->credit == nullptr) + if (term->credit == NULL) term->credit = new Credit(); else if (from_swipe == 0) term->credit->Clear(); - if (term->credit != nullptr) + if (term->credit != NULL) { term->credit->SetCardType(CARD_TYPE_CREDIT); draw = 1; @@ -2718,11 +2715,11 @@ SignalResult CreditCardDialog::Signal(Terminal *term, const genericChar* message from_swipe = 0; break; case 12: // ccdebit - if (term->credit == nullptr) + if (term->credit == NULL) term->credit = new Credit(); else if (from_swipe == 0) term->credit->Clear(); - if (term->credit != nullptr) + if (term->credit != NULL) { term->credit->SetCardType(CARD_TYPE_DEBIT); SetAction(term, AUTH_AUTHORIZE, AUTHORIZE_MSG, SWIPE_MSG); @@ -2733,7 +2730,7 @@ SignalResult CreditCardDialog::Signal(Terminal *term, const genericChar* message case 13: // ccswipe // This should only be called for CreditCheq Multi. // Starts the authorization process without a card number. - if (term->credit != nullptr) + if (term->credit != NULL) { term->auth_swipe = 1; if (term->auth_action == AUTH_NONE) @@ -2744,21 +2741,21 @@ SignalResult CreditCardDialog::Signal(Terminal *term, const genericChar* message retval = SIGNAL_TERMINATE; break; case 14: // ccundorefund - if (term->credit != nullptr) + if (term->credit != NULL) { SetAction(term, AUTH_REFUND_CORRECT, REFUND_CANCEL_MSG); draw = 1; } break; case 15: // ccclear - if (term->credit != nullptr) + if (term->credit != NULL) { term->credit->Clear(); draw = 1; } break; case 16: // ccvoice - if (term->credit != nullptr && term->credit->CardType() != CARD_TYPE_NONE) + if (term->credit != NULL && term->credit->CardType() != CARD_TYPE_NONE) { ccv = new CreditCardVoiceDialog(); term->NextDialog(ccv); @@ -2768,7 +2765,7 @@ SignalResult CreditCardDialog::Signal(Terminal *term, const genericChar* message retval = SIGNAL_IGNORED; break; case 17: // ccadvice - if (term->credit != nullptr) + if (term->credit != NULL) { SetAction(term, AUTH_ADVICE, ADVICE_MSG); draw = 1; @@ -2793,30 +2790,27 @@ SignalResult CreditCardDialog::Signal(Terminal *term, const genericChar* message SignalResult CreditCardDialog::Keyboard(Terminal *term, int my_key, int state) { FnTrace("CreditCardDialog::Keyboard()"); - enum class Action { None, Voice, Print }; - Action action = Action::None; - - if (my_key == 118 && debug_mode) // 'v' - action = Action::Voice; - else if (my_key == 114) // 'r' - action = Action::Print; + SignalResult retval = SIGNAL_IGNORED; + CreditCardVoiceDialog *ccv = NULL; - switch (action) - { - case Action::Voice: + switch (my_key) { - auto *ccv = new CreditCardVoiceDialog(); - term->NextDialog(ccv); - return SIGNAL_TERMINATE; - } - case Action::Print: - if (term->credit != nullptr) + case 118: // v + if (debug_mode) + { + ccv = new CreditCardVoiceDialog(); + term->NextDialog(ccv); + retval = SIGNAL_TERMINATE; + } + break; + case 114: // r + if (term->credit != NULL) term->credit->PrintReceipt(term); - return SIGNAL_OKAY; - case Action::None: - default: - return SIGNAL_IGNORED; + retval = SIGNAL_OKAY; + break; } + + return retval; } @@ -2826,19 +2820,19 @@ int CreditCardDialog::ProcessSwipe(Terminal *term, const char* swipe_value) int retval = 0; Employee *employee = term->user; - if (employee == nullptr) + if (employee == NULL) return 1; - if (term->credit == nullptr) + if (term->credit == NULL) term->credit = new Credit(swipe_value); else term->credit->ParseSwipe(swipe_value); - if (term->credit == nullptr || term->credit->IsValid() < 1) + if (term->credit == NULL || term->credit->IsValid() < 1) { - if (term->credit != nullptr) + if (term->credit != NULL) delete term->credit; - term->credit = nullptr; + term->credit = NULL; retval = 1; } @@ -2862,7 +2856,7 @@ int CreditCardDialog::FinishCreditCard(Terminal *term) // term->credit == NULL should not even be an option at this point, // but we'll double check it for safety. - if (term->credit != nullptr) + if (term->credit != NULL) { finalizing = 1; // The only time preauth_time or auth_time is set is from @@ -2917,12 +2911,12 @@ int CreditCardDialog::FinishCreditCard(Terminal *term) { // Probably opening a tab (otherwise: fatal error). We // need to add the payment manually. - if (term->check != nullptr && - term->page != nullptr && + if (term->check != NULL && + term->page != NULL && term->page->id != -20) { SubCheck *sc = term->check->current_sub; - if (sc == nullptr) + if (sc == NULL) sc = term->check->NewSubCheck(); Payment *paymnt = sc->NewPayment(tender, cc_id, 0, term->credit->Total()); paymnt->credit = term->credit; @@ -2945,10 +2939,10 @@ SignalResult CreditCardDialog::ProcessCreditCard(Terminal *term) { FnTrace("CreditCardDialog::ProcessCreditCard()"); SignalResult retval = SIGNAL_OKAY; - SimpleDialog *sd = nullptr; + SimpleDialog *sd = NULL; Settings *settings = term->GetSettings(); - if (term->credit != nullptr) + if (term->credit != NULL) { declined = 0; @@ -2983,14 +2977,14 @@ SignalResult CreditCardDialog::ProcessCreditCard(Terminal *term) term->credit->GetStatus() == CC_STATUS_DENY) { declined = 1; - if (saved_credit != nullptr) + if (saved_credit != NULL) { // We do not delete term->credit because we store it // in the credit card as an error. saved_credit->SetVerb(term->credit->Verb()); saved_credit->AddError(term->credit); term->credit->Copy(saved_credit); - saved_credit = nullptr; + saved_credit = NULL; } else if (debug_mode) { @@ -3010,10 +3004,10 @@ SignalResult CreditCardDialog::ProcessCreditCard(Terminal *term) retval = SIGNAL_TERMINATE; } } - else if (saved_credit != nullptr) + else if (saved_credit != NULL) { delete saved_credit; - saved_credit = nullptr; + saved_credit = NULL; } Draw(term, 1); @@ -3056,7 +3050,7 @@ RenderResult JobFilterDialog::Render(Terminal *term, int update_flag) if (update_flag) filter = term->job_filter; - DialogZone::Render(term, update_flag); + LayoutZone::Render(term, update_flag); TextC(term, 0, term->Translate("Wage Group Filter")); int ww = w - border * 2; @@ -3128,7 +3122,7 @@ RenderResult JobFilterDialog::Render(Terminal *term, int update_flag) SignalResult JobFilterDialog::Signal(Terminal *term, const genericChar* message) { FnTrace("JobFilterDialog::Signal()"); - static const genericChar* commands[] = {"okay", "cancel", nullptr}; + static const genericChar* commands[] = {"okay", "cancel", NULL}; int idx = CompareList(message, commands); switch (idx) @@ -3138,7 +3132,7 @@ SignalResult JobFilterDialog::Signal(Terminal *term, const genericChar* message) if (term->job_filter != filter) { term->job_filter = filter; - term->Update(UPDATE_JOB_FILTER, nullptr); + term->Update(UPDATE_JOB_FILTER, NULL); } return SIGNAL_TERMINATE; case 1: @@ -3208,7 +3202,7 @@ OpenTabDialog::OpenTabDialog(CustomerInfo *custinfo) max_comment = 35; current = customer_name; - last_current = nullptr; + last_current = NULL; max_current = max_name; name.Set("Open Customer Tab"); @@ -3277,15 +3271,15 @@ SignalResult OpenTabDialog::Signal(Terminal *term, const genericChar* message) { FnTrace("OpenTabDialog::Signal()"); SignalResult retval = SIGNAL_OKAY; - static const char* command[] = { "enter", "backspace", "cancel", "clear", nullptr }; + static const char* command[] = { "enter", "backspace", "cancel", "clear", NULL }; int len; int idx = CompareList(message, command); switch (idx) { case 0: // enter - if (customer != nullptr && - term->check != nullptr && + if (customer != NULL && + term->check != NULL && (customer_name[0] != '\0' || customer_phone[0] != '\0' || customer_comment[0] != '\0')) @@ -3306,7 +3300,7 @@ SignalResult OpenTabDialog::Signal(Terminal *term, const genericChar* message) } break; case 1: // backspace - if (current != nullptr && (len = strlen(current)) > 0) + if (current != NULL && (len = strlen(current)) > 0) { current[len - 1] = '\0'; } @@ -3321,7 +3315,7 @@ SignalResult OpenTabDialog::Signal(Terminal *term, const genericChar* message) customer_comment[0] = '\0'; break; default: - if (current != nullptr) + if (current != NULL) { len = strlen(current); if (len < max_current) @@ -3340,12 +3334,12 @@ SignalResult OpenTabDialog::Signal(Terminal *term, const genericChar* message) SignalResult OpenTabDialog::Keyboard(Terminal *term, int kb_key, int state) { FnTrace("OpenTabDialog::Keyboard()"); - const char *cmd = nullptr; + SignalResult retval = SIGNAL_IGNORED; switch (kb_key) { case 8: // backspace - cmd = "backspace"; + retval = Signal(term, "backspace"); break; case 9: // tab if (current == customer_name) @@ -3354,18 +3348,20 @@ SignalResult OpenTabDialog::Keyboard(Terminal *term, int kb_key, int state) SetCurrent(term, customer_comment); else SetCurrent(term, customer_name); - return SIGNAL_OKAY; + retval = SIGNAL_OKAY; + break; case 13: // enter - cmd = "enter"; + retval = Signal(term, "enter"); break; case 27: // ESC - cmd = "cancel"; + retval = Signal(term, "cancel"); break; default: - return GetTextDialog::Keyboard(term, kb_key, state); + retval = GetTextDialog::Keyboard(term, kb_key, state); + break; } - return cmd ? Signal(term, cmd) : SIGNAL_IGNORED; + return retval; } int OpenTabDialog::RenderEntry(Terminal *term) @@ -3449,16 +3445,16 @@ RenderResult OrderCommentDialog::Render(Terminal *term, int update_flag) RenderResult retval = RENDER_OKAY; if (update_flag) - lit = nullptr; + lit = NULL; if (lit) { lit->Draw(term, 0); - lit = nullptr; + lit = NULL; return RENDER_OKAY; } // Call parent Render to set up keyboard layout - GetTextDialog::Render(term, update_flag); + LayoutZone::Render(term, update_flag); first_row_y = y + first_row; // Layout buttons - reuse GetTextDialog layout code @@ -3539,7 +3535,7 @@ SignalResult OrderCommentDialog::Signal(Terminal *term, const genericChar* messa FnTrace("OrderCommentDialog::Signal()"); SignalResult retval = SIGNAL_OKAY; static const genericChar* commands[] = { - "backspace", "clear", "enter", "cancel", nullptr}; + "backspace", "clear", "enter", "cancel", NULL}; int idx = CompareList(message, commands); genericChar msgbuf[STRLENGTH]; @@ -3555,7 +3551,7 @@ SignalResult OrderCommentDialog::Signal(Terminal *term, const genericChar* messa break; case 2: // enter (Done) // Add comment as a modifier order under the currently selected order - if (term->check != nullptr && term->order != nullptr && buffidx > 0 && buffer[0] != '\0') + if (term->check != NULL && term->order != NULL && buffidx > 0 && buffer[0] != '\0') { Order *parent_order = term->order; // Make sure we're working with the parent order, not a modifier @@ -3564,7 +3560,7 @@ SignalResult OrderCommentDialog::Signal(Terminal *term, const genericChar* messa // Create a new modifier order with the comment text Order *comment_order = new Order(buffer, 0); // Price is 0 for comments - if (comment_order != nullptr) + if (comment_order != NULL) { comment_order->item_type = ITEM_MODIFIER; comment_order->call_order = 4; // Standard call order for modifiers @@ -3577,12 +3573,12 @@ SignalResult OrderCommentDialog::Signal(Terminal *term, const genericChar* messa { // Successfully added - update totals and display SubCheck *sc = term->check->current_sub; - if (sc != nullptr) + if (sc != NULL) { Settings *s = term->GetSettings(); sc->FigureTotals(s); } - term->Update(UPDATE_ORDERS, nullptr); + term->Update(UPDATE_ORDERS, NULL); } else { diff --git a/zone/dialog_zone.hh b/zone/dialog_zone.hh index c464d282..08c0710a 100644 --- a/zone/dialog_zone.hh +++ b/zone/dialog_zone.hh @@ -19,7 +19,7 @@ */ #ifndef _DIALOG_ZONE_HH -#define DIALOG_ZONE_HH +#define _DIALOG_ZONE_HH #include "check.hh" #include "layout_zone.hh" @@ -67,9 +67,9 @@ public: Str message; int color; - ButtonObj(const char* text, const genericChar* message = nullptr); + ButtonObj(const char* text, const genericChar* message = NULL); - int Render(Terminal *term) override; + int Render(Terminal *term); int SetLabel(const char* newlabel) { return label.Set(newlabel); } int SetMessage(const char* newmessage) { return message.Set(newmessage); } }; @@ -93,17 +93,17 @@ public: DialogZone(); - std::unique_ptr Copy() override + std::unique_ptr Copy() { printf("Error: No DialogZone::Copy() method defined for subclass!\n"); return nullptr; } - int Type() override { return ZONE_DLG_UNKNOWN; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - SignalResult Mouse(Terminal *term, int action, int mx, int my) override; + int Type() { return ZONE_DLG_UNKNOWN; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Touch(Terminal *term, int tx, int ty); + SignalResult Mouse(Terminal *term, int action, int mx, int my); - ButtonObj *Button(const char* text, const genericChar* message = nullptr); + ButtonObj *Button(const char* text, const genericChar* message = NULL); int ClosingAction(int action_type, int action, int arg); int ClosingAction(int action_type, int action, const char* message); int SetAllActions(DialogZone *dest); @@ -126,9 +126,9 @@ public: SimpleDialog(const char* title, int format = 0); void SetTitle(const char* new_title) { name.Set(new_title); } - int RenderInit(Terminal *term, int update_flag) override; - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; + int RenderInit(Terminal *term, int update_flag); + RenderResult Render(Terminal *term, int update_flag); + SignalResult Touch(Terminal *term, int tx, int ty); }; class UnitAmountDialog : public DialogZone @@ -144,10 +144,10 @@ class UnitAmountDialog : public DialogZone public: UnitAmountDialog(const char* title, UnitAmount &ua); - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Keyboard(Terminal *term, int key, int state) override; + RenderResult Render(Terminal *term, int update_flag); + SignalResult Touch(Terminal *term, int tx, int ty); + SignalResult Signal(Terminal *term, const genericChar* message); + SignalResult Keyboard(Terminal *term, int key, int state); int RenderEntry(Terminal *term); }; @@ -171,12 +171,12 @@ public: TenKeyDialog(const char* title, int amount, int cancel = 1, int dp = 0); TenKeyDialog(const char* title, const char* retmsg, int amount, int dp = 0); - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Keyboard(Terminal *term, int key, int state) override; + RenderResult Render(Terminal *term, int update_flag); + SignalResult Touch(Terminal *term, int tx, int ty); + SignalResult Signal(Terminal *term, const genericChar* message); + SignalResult Keyboard(Terminal *term, int key, int state); - int RenderEntry(Terminal *term); + virtual int RenderEntry(Terminal *term); }; class GetTextDialog : public DialogZone @@ -203,15 +203,15 @@ public: GetTextDialog(); GetTextDialog(const char* msg, const char* retmsg, int mlen = 20); - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Keyboard(Terminal *term, int key, int state) override; + virtual RenderResult Render(Terminal *term, int update_flag); + virtual SignalResult Touch(Terminal *term, int tx, int ty); + virtual SignalResult Signal(Terminal *term, const genericChar* message); + virtual SignalResult Keyboard(Terminal *term, int key, int state); - int RenderEntry(Terminal *term); - int DrawEntry(Terminal *term); - int AddChar(Terminal *term, genericChar val); - int Backspace(Terminal *term); + virtual int RenderEntry(Terminal *term); + virtual int DrawEntry(Terminal *term); + virtual int AddChar(Terminal *term, genericChar val); + virtual int Backspace(Terminal *term); }; class PasswordDialog : public GetTextDialog @@ -227,8 +227,8 @@ protected: public: PasswordDialog(const char* password); - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; + RenderResult Render(Terminal *term, int update_flag); + SignalResult Signal(Terminal *term, const genericChar* message); int RenderEntry(Terminal *term); int PasswordOkay(Terminal *term); @@ -244,7 +244,7 @@ public: CreditCardAmountDialog(); CreditCardAmountDialog(Terminal *term, const char* title, int type); - SignalResult Signal(Terminal *term, const genericChar* message) override; + SignalResult Signal(Terminal *term, const genericChar* message); }; class CreditCardEntryDialog : public TenKeyDialog @@ -265,12 +265,12 @@ class CreditCardEntryDialog : public TenKeyDialog public: CreditCardEntryDialog(); - int ZoneStates() override { return 1; } + int ZoneStates() { return 1; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Keyboard(Terminal *term, int key, int state) override; + RenderResult Render(Terminal *term, int update_flag); + SignalResult Touch(Terminal *term, int tx, int ty); + SignalResult Signal(Terminal *term, const genericChar* message); + SignalResult Keyboard(Terminal *term, int key, int state); int RenderEntry(Terminal *term); }; @@ -280,10 +280,10 @@ class CreditCardVoiceDialog : public GetTextDialog public: CreditCardVoiceDialog(); CreditCardVoiceDialog(const char* msg, const char* retmsg, int mlen = 20); - ~CreditCardVoiceDialog() override; + ~CreditCardVoiceDialog(); - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; + virtual RenderResult Render(Terminal *term, int update_flag); + virtual SignalResult Signal(Terminal *term, const genericChar* message); }; class CreditCardDialog : public DialogZone @@ -318,21 +318,21 @@ class CreditCardDialog : public DialogZone Credit *saved_credit; void Init(Terminal *term, SubCheck *subch, const char* swipe_value); - const char* SetMessage(Terminal *term, const char* msg1, const char* msg2 = nullptr); + const char* SetMessage(Terminal *term, const char* msg1, const char* msg2 = NULL); public: CreditCardDialog(); - CreditCardDialog(Terminal *term, const char* swipe_value = nullptr); - CreditCardDialog(Terminal *term, SubCheck *subch, const char* swipe_value = nullptr); + CreditCardDialog(Terminal *term, const char* swipe_value = NULL); + CreditCardDialog(Terminal *term, SubCheck *subch, const char* swipe_value = NULL); CreditCardDialog(Terminal *term, int action, const char* message); - int Type() override { return ZONE_DLG_CREDIT; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - int SetAction(Terminal *term, int action, const char* msg1, const char* msg2 = nullptr); + int Type() { return ZONE_DLG_CREDIT; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Touch(Terminal *term, int tx, int ty); + int SetAction(Terminal *term, int action, const char* msg1, const char* msg2 = NULL); int ClearAction(Terminal *term, int all = 0); - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Keyboard(Terminal *term, int my_key, int state) override; + SignalResult Signal(Terminal *term, const genericChar* message); + SignalResult Keyboard(Terminal *term, int my_key, int state); int ProcessSwipe(Terminal *term, const char* swipe_value); int DialogDone(Terminal *term); int FinishCreditCard(Terminal *term); @@ -347,10 +347,10 @@ class JobFilterDialog : public DialogZone public: JobFilterDialog(); - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Keyboard(Terminal *term, int key, int state) override; + RenderResult Render(Terminal *term, int update_flag); + SignalResult Touch(Terminal *term, int tx, int ty); + SignalResult Signal(Terminal *term, const genericChar* message); + SignalResult Keyboard(Terminal *term, int key, int state); }; class SwipeDialog : public DialogZone @@ -360,10 +360,10 @@ class SwipeDialog : public DialogZone public: SwipeDialog(); - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Keyboard(Terminal *term, int key, int state) override; + RenderResult Render(Terminal *term, int update_flag); + SignalResult Touch(Terminal *term, int tx, int ty); + SignalResult Signal(Terminal *term, const genericChar* message); + SignalResult Keyboard(Terminal *term, int key, int state); }; class OpenTabDialog : public GetTextDialog @@ -389,12 +389,12 @@ class OpenTabDialog : public GetTextDialog public: OpenTabDialog(CustomerInfo *custinfo); - int ZoneStates() override { return 1; } + int ZoneStates() { return 1; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Keyboard(Terminal *term, int kb_key, int state) override; + RenderResult Render(Terminal *term, int update_flag); + SignalResult Touch(Terminal *term, int tx, int ty); + SignalResult Signal(Terminal *term, const genericChar* message); + SignalResult Keyboard(Terminal *term, int kb_key, int state); int RenderEntry(Terminal *term); }; @@ -405,10 +405,10 @@ public: OrderCommentDialog(); OrderCommentDialog(const char* msg, const char* retmsg, int mlen = 100); - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Keyboard(Terminal *term, int kb_key, int state) override; + RenderResult Render(Terminal *term, int update_flag); + SignalResult Touch(Terminal *term, int tx, int ty); + SignalResult Signal(Terminal *term, const genericChar* message); + SignalResult Keyboard(Terminal *term, int kb_key, int state); int RenderEntry(Terminal *term); }; diff --git a/zone/drawer_zone.cc b/zone/drawer_zone.cc index 894c3e58..44caf353 100644 --- a/zone/drawer_zone.cc +++ b/zone/drawer_zone.cc @@ -26,8 +26,6 @@ #include "system.hh" #include "dialog_zone.hh" #include "settings.hh" -#include "main/data/settings_enums.hh" -#include "src/utils/vt_enum_utils.hh" #include "labor.hh" #include "image_data.hh" #include "archive.hh" @@ -39,7 +37,7 @@ #include #endif -#define ALL_DRAWERS (-1) +#define ALL_DRAWERS -1 /********************************************************************* * DrawerObj Class for DrawerManageZone @@ -52,7 +50,7 @@ class DrawerObj : public ZoneObject int status; DrawerObj(Drawer *d); - int Render(Terminal *term) override; + int Render(Terminal *term); }; DrawerObj::DrawerObj(Drawer *d) @@ -166,8 +164,8 @@ class ServerDrawerObj : public ZoneObject ServerDrawerObj(Terminal *term, Employee *employee); - int Render(Terminal *term) override; - int Layout(Terminal *term, int lx, int ly, int lw, int lh) override; + int Render(Terminal *term); + int Layout(Terminal *term, int lx, int ly, int lw, int lh); }; ServerDrawerObj::ServerDrawerObj(Terminal *term, Employee *employee) @@ -176,10 +174,10 @@ ServerDrawerObj::ServerDrawerObj(Terminal *term, Employee *employee) user = employee; Drawer *d = term->system_data->FirstDrawer(); - while (d != nullptr) + while (d != NULL) { - if (((employee == nullptr && d->owner_id == 0) || - (employee != nullptr && d->owner_id == employee->id)) && + if (((employee == NULL && d->owner_id == 0) || + (employee != NULL && d->owner_id == employee->id)) && d->GetStatus() == DRAWER_OPEN && !d->IsServerBank()) drawers.Add(new DrawerObj(d)); d = d->next; @@ -202,7 +200,7 @@ int ServerDrawerObj::Layout(Terminal *term, int lx, int ly, int lw, int lh) height = height_left; // lay drawer out left to right, top to bottom - for (ZoneObject *zo = drawers.List(); zo != nullptr; zo = zo->next) + for (ZoneObject *zo = drawers.List(); zo != NULL; zo = zo->next) { if (width > width_left) { @@ -255,13 +253,13 @@ int ServerDrawerObj::Render(Terminal *term) RenderResult DrawerAssignZone::Render(Terminal *term, int update_flag) { FnTrace("DrawerAssignZone::Render()"); - RenderZone(term, nullptr, update_flag); + RenderZone(term, NULL, update_flag); System *sys = term->system_data; Settings *s = &(sys->settings); if (update_flag) { servers.Purge(); - for (Employee *employee = sys->user_db.UserList(); employee != nullptr; employee = employee->next) + for (Employee *employee = sys->user_db.UserList(); employee != NULL; employee = employee->next) { if ((employee->CanSettle(s) && sys->labor_db.IsUserOnClock(employee)) || sys->CountDrawersOwned(employee->id) > 0) @@ -271,7 +269,7 @@ RenderResult DrawerAssignZone::Render(Terminal *term, int update_flag) } // Create unassigned drawer area - servers.Add(new ServerDrawerObj(term, nullptr)); + servers.Add(new ServerDrawerObj(term, NULL)); } servers.LayoutGrid(term, x + border, y + border, @@ -308,7 +306,7 @@ int DrawerAssignZone::MoveDrawers(Terminal *term, Employee *user) FnTrace("DrawerAssignZone::MoveDrawers()"); int count = 0; ZoneObject *list = servers.List(); - while (list != nullptr) + while (list != NULL) { count += ((ServerDrawerObj *)list)->drawers.CountSelected(); list = list->next; @@ -321,13 +319,13 @@ int DrawerAssignZone::MoveDrawers(Terminal *term, Employee *user) while (list) { ZoneObject *zo = ((ServerDrawerObj *)list)->drawers.List(); - for (; zo != nullptr; zo = zo->next) + for (; zo != NULL; zo = zo->next) { if (zo->selected) { zo->selected = 0; Drawer *d = ((DrawerObj *)zo)->drawer; - if (user == nullptr) + if (user == NULL) d->ChangeOwner(0); else d->ChangeOwner(user->id); @@ -348,13 +346,13 @@ int DrawerAssignZone::MoveDrawers(Terminal *term, Employee *user) DrawerManageZone::DrawerManageZone() { - current = nullptr; - report = nullptr; + current = NULL; + report = NULL; mode = DRAWER_OPEN; left_margin = 128; view = DRAWER_OPEN; - drawer_list = nullptr; - check_list = nullptr; + drawer_list = NULL; + check_list = NULL; page = 0; max_pages = 0; media = 0; @@ -379,11 +377,11 @@ RenderResult DrawerManageZone::Render(Terminal *term, int update_flag) System *sys = term->system_data; Settings *s = &(sys->settings); Archive *archive = term->archive; - Check *check_list_save = nullptr; + Check *check_list_save = NULL; int idx; if (drawer_zone_type == DRAWER_ZONE_SELECT) - archive = nullptr; + archive = NULL; LayoutZone::Render(term, update_flag); if (update_flag) @@ -413,7 +411,7 @@ RenderResult DrawerManageZone::Render(Terminal *term, int update_flag) if (report) { delete report; - report = nullptr; + report = NULL; } CreateDrawers(term); group = 0; @@ -463,7 +461,7 @@ RenderResult DrawerManageZone::Render(Terminal *term, int update_flag) } // Render the right side report for the currently selected Drawer object - Drawer *d = nullptr; + Drawer *d = NULL; if (current) d = ((DrawerObj *)current)->drawer; @@ -473,17 +471,17 @@ RenderResult DrawerManageZone::Render(Terminal *term, int update_flag) // first copy all of the checks over int all = term->user->IsSupervisor(s); int dstat; - Drawer *scdrawer = nullptr; + Drawer *scdrawer = NULL; Check *currcheck = check_list; - while (drawer_list != nullptr && currcheck != nullptr) + while (drawer_list != NULL && currcheck != NULL) { Check *newcheck = currcheck->Copy(s); // set all SubChecks to our virtual drawer SubCheck *scheck = newcheck->SubList(); - while (scheck != nullptr) + while (scheck != NULL) { scdrawer = drawer_list->FindBySerial(scheck->drawer_id); - if (scdrawer != nullptr) + if (scdrawer != NULL) dstat = scdrawer->GetStatus(); else dstat = 0; @@ -507,7 +505,7 @@ RenderResult DrawerManageZone::Render(Terminal *term, int update_flag) } for (idx = 0; idx < MAX_BALANCES; idx++) - balance_list[idx] = nullptr; + balance_list[idx] = NULL; // set up balance list if (d) @@ -619,12 +617,12 @@ RenderResult DrawerManageZone::Render(Terminal *term, int update_flag) } genericChar str[256]; - if (d == nullptr) + if (d == NULL) { if (report) { delete report; - report = nullptr; + report = NULL; } report = new Report; @@ -633,7 +631,7 @@ RenderResult DrawerManageZone::Render(Terminal *term, int update_flag) else report->TextC(term->Translate("There Are No Balanced Drawers For")); report->NewLine(); - if (archive == nullptr) + if (archive == NULL) vt_safe_string::safe_copy(str, 256, term->Translate("Today")); else { @@ -657,7 +655,7 @@ RenderResult DrawerManageZone::Render(Terminal *term, int update_flag) switch (mode) { default: - if (report == nullptr) + if (report == NULL) { report = new Report; d->MakeReport(term, check_list, report); @@ -677,7 +675,7 @@ RenderResult DrawerManageZone::Render(Terminal *term, int update_flag) if (report) { delete report; - report = nullptr; + report = NULL; } int pcolor; @@ -690,7 +688,7 @@ RenderResult DrawerManageZone::Render(Terminal *term, int update_flag) { DrawerBalance *db = balance_list[balance_count]; int p = balance_count / per_page; - if (p != page || db == nullptr) + if (p != page || db == NULL) { balance_count += 1; continue; @@ -721,16 +719,16 @@ RenderResult DrawerManageZone::Render(Terminal *term, int update_flag) TextC(term, 0, term->Translate("Please Enter These Amounts"), color[0]); // Add the terminal name - if (d != nullptr) + if (d != NULL) { Terminal *termlist = term->parent->TermList(); - while (termlist != nullptr) + while (termlist != NULL) { if (termlist->host == d->host) { snprintf(str, 256, "%s", termlist->name.Value()); TextC(term, 1, str, color[0]); - termlist = nullptr; + termlist = NULL; } else { @@ -761,7 +759,7 @@ RenderResult DrawerManageZone::Render(Terminal *term, int update_flag) } } - if (check_list_save != nullptr) + if (check_list_save != NULL) check_list = check_list_save; return RENDER_OKAY; @@ -773,21 +771,21 @@ SignalResult DrawerManageZone::Signal(Terminal *term, const genericChar* message static const genericChar* commands[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "00", "-", "backspace", "clear", "enter", "pull", "save", "change view", - "localprint", "reportprint", "merge", "mergeterm", "mergeall", nullptr}; + "localprint", "reportprint", "merge", "mergeterm", "mergeall", NULL}; Employee *employee; Drawer *drawer; DrawerBalance *db; - const auto drawer_print = vt::IntToEnum(term->GetSettings()->drawer_print); + int drawer_print = term->GetSettings()->drawer_print; employee = term->user; - if (employee == nullptr) + if (employee == NULL) return SIGNAL_IGNORED; - drawer = nullptr; + drawer = NULL; if (current) drawer = ((DrawerObj *)current)->drawer; - db = nullptr; + db = NULL; if (media >= 0 && media < balances) db = balance_list[media]; @@ -859,14 +857,14 @@ SignalResult DrawerManageZone::Signal(Terminal *term, const genericChar* message media = 0; if (mode == DRAWER_OPEN) { - if (drawer_print && (*drawer_print == DrawerPrintType::OnBoth || *drawer_print == DrawerPrintType::OnPull)) + if (drawer_print == DRAWER_PRINT_BOTH || drawer_print == DRAWER_PRINT_PULL) Print(term, RP_PRINT_REPORT); drawer->Pull(employee->id); Draw(term, 0); } else if (mode == DRAWER_PULLED) { - if (drawer_print && (*drawer_print == DrawerPrintType::OnBoth || *drawer_print == DrawerPrintType::OnBalance)) + if (drawer_print == DRAWER_PRINT_BOTH || drawer_print == DRAWER_PRINT_BALANCE) Print(term, RP_PRINT_REPORT); drawer->Balance(employee->id); DrawerBalance *drawer_balance = drawer->FindBalance(TENDER_EXPENSE, 0); @@ -924,7 +922,7 @@ SignalResult DrawerManageZone::Signal(Terminal *term, const genericChar* message if (report) { delete report; - report = nullptr; + report = NULL; } Draw(term, 0); return SIGNAL_OKAY; @@ -948,7 +946,7 @@ SignalResult DrawerManageZone::Signal(Terminal *term, const genericChar* message if (report) { delete report; - report = nullptr; + report = NULL; } Draw(term, 0); return SIGNAL_OKAY; @@ -991,7 +989,7 @@ SignalResult DrawerManageZone::Touch(Terminal *term, int tx, int ty) if (report) { delete report; - report = nullptr; + report = NULL; } media = TENDER_CASH; Draw(term, 0); @@ -1042,26 +1040,31 @@ SignalResult DrawerManageZone::Keyboard(Terminal *term, int my_key, int state) FnTrace("DrawerManageZone::Keyboard()"); genericChar str[16]; - int delta = 0; - if (my_key == 16) // page up - delta = -1; - else if (my_key == 14) // page down - delta = 1; - else if (my_key == 13) // enter + int new_page = page; + switch (my_key) + { + case 16: // page_up + --new_page; + break; + case 14: // page down + ++new_page; + break; + case 13: // enter return Signal(term, "enter"); - else if (my_key == 8) // backspace + break; + case 8: // backspace return Signal(term, "backspace"); - else - { + break; + default: str[0] = (char) my_key; str[1] = '\0'; return Signal(term, str); + break; } - if (report == nullptr) + if (report == NULL) return SIGNAL_IGNORED; - int new_page = page + delta; int max_page = report->max_pages; if (new_page >= max_page) new_page = 0; @@ -1087,7 +1090,7 @@ int DrawerManageZone::Update(Terminal *term, int update_message, const genericCh if (report) { delete report; - report = nullptr; + report = NULL; } return Draw(term, 0); } @@ -1104,12 +1107,12 @@ int DrawerManageZone::CreateDrawers(Terminal *term) int all = employee->IsSupervisor(s); int count = 0; - for (Drawer *drawer = drawer_list; drawer != nullptr; drawer = drawer->next) + for (Drawer *drawer = drawer_list; drawer != NULL; drawer = drawer->next) { if (all || drawer->owner_id == employee->id) { // Server Bank drawers will not have term set, but we need it - if (drawer->term == nullptr) + if (drawer->term == NULL) drawer->term = term; drawer->Total(check_list); if ((drawer_zone_type == DRAWER_ZONE_SELECT) || (drawer->IsEmpty() == 0)) @@ -1143,12 +1146,12 @@ int DrawerManageZone::Print(Terminal *term, int print_mode) return 0; Employee *employee = term->user; - if (employee == nullptr || current == nullptr || report == nullptr) + if (employee == NULL || current == NULL || report == NULL) return 1; Printer *p1 = term->FindPrinter(PRINTER_RECEIPT); Printer *p2 = term->FindPrinter(PRINTER_REPORT); - if (p1 == nullptr && p2 == nullptr) + if (p1 == NULL && p2 == NULL) return 1; if (print_mode == RP_ASK) @@ -1160,10 +1163,10 @@ int DrawerManageZone::Print(Terminal *term, int print_mode) } Printer *p = p1; - if ((print_mode == RP_PRINT_REPORT && p2) || p1 == nullptr) + if ((print_mode == RP_PRINT_REPORT && p2) || p1 == NULL) p = p2; - if (p == nullptr) + if (p == NULL) return 1; report->CreateHeader(term, p, employee); diff --git a/zone/drawer_zone.hh b/zone/drawer_zone.hh index 5f77fd10..d7763d17 100644 --- a/zone/drawer_zone.hh +++ b/zone/drawer_zone.hh @@ -19,7 +19,7 @@ */ #ifndef _DRAWER_ZONE_HH -#define DRAWER_ZONE_HH +#define _DRAWER_ZONE_HH #include "layout_zone.hh" #include "zone_object.hh" @@ -48,11 +48,11 @@ class DrawerAssignZone : public PosZone public: // Member Functions - int Type() override { return ZONE_DRAWER_ASSIGN; } - RenderResult Render(Terminal *t, int update_flag) override; - SignalResult Touch(Terminal *t, int tx, int ty) override; - int Update(Terminal *t, int update_message, const genericChar* value) override; - int ZoneStates() override { return 1; } + int Type() { return ZONE_DRAWER_ASSIGN; } + RenderResult Render(Terminal *t, int update_flag); + SignalResult Touch(Terminal *t, int tx, int ty); + int Update(Terminal *t, int update_message, const genericChar* value); + int ZoneStates() { return 1; } int MoveDrawers(Terminal *t, Employee *user); }; @@ -82,17 +82,17 @@ public: // Constructor DrawerManageZone(); // Destructor - ~DrawerManageZone() override; + ~DrawerManageZone(); // Member Functions - int Type() override { return ZONE_DRAWER_MANAGE; } - RenderResult Render(Terminal *t, int update_flag) override; - SignalResult Signal(Terminal *t, const genericChar* message) override; - SignalResult Touch(Terminal *t, int tx, int ty) override; - SignalResult Keyboard(Terminal *t, int key, int state) override; - int Update(Terminal *t, int update_message, const genericChar* value) override; - Flt *Spacing() override { return &spacing; } - int *DrawerZoneType() override { return &drawer_zone_type; } + int Type() { return ZONE_DRAWER_MANAGE; } + RenderResult Render(Terminal *t, int update_flag); + SignalResult Signal(Terminal *t, const genericChar* message); + SignalResult Touch(Terminal *t, int tx, int ty); + SignalResult Keyboard(Terminal *t, int key, int state); + int Update(Terminal *t, int update_message, const genericChar* value); + Flt *Spacing() { return &spacing; } + int *DrawerZoneType() { return &drawer_zone_type; } int CreateDrawers(Terminal *t); int Print(Terminal *t, int mode); diff --git a/zone/expense_zone.cc b/zone/expense_zone.cc index 15e5704f..c92e6008 100644 --- a/zone/expense_zone.cc +++ b/zone/expense_zone.cc @@ -31,28 +31,28 @@ ExpenseZone::ExpenseZone() { - expense = nullptr; - saved_expense = nullptr; + expense = NULL; + saved_expense = NULL; show_expense = 0; // form_header defines the top of the space where the form fields will be drawn form_header = -11; list_footer = 12; form_spacing = 0.65; AddTextField(GlobalTranslate("Expense ID"), 5, 0); - AddListField(GlobalTranslate("Payer"), nullptr); + AddListField(GlobalTranslate("Payer"), NULL); AddNewLine(); AddTextField(GlobalTranslate("Expense Amount"), 10); SetFlag(FF_MONEY); - AddListField(GlobalTranslate("Expense Drawer"), nullptr); + AddListField(GlobalTranslate("Expense Drawer"), NULL); AddLabel(" or "); - AddListField(GlobalTranslate("Account"), nullptr); + AddListField(GlobalTranslate("Account"), NULL); AddNewLine(); - AddListField(GlobalTranslate("Destination Account"), nullptr); + AddListField(GlobalTranslate("Destination Account"), NULL); AddNewLine(); AddTextField(GlobalTranslate("Tax Amount"), 10); SetFlag(FF_MONEY); - AddListField(GlobalTranslate("Tax Account"), nullptr); + AddListField(GlobalTranslate("Tax Account"), NULL); AddNewLine(); AddTextField(GlobalTranslate("Document"), 25); @@ -61,7 +61,7 @@ ExpenseZone::ExpenseZone() AddSubmit(GlobalTranslate("Submit"), 10); record_no = -1; - report = nullptr; + report = NULL; page = 0; no_line = 1; lines_shown = 0; @@ -70,9 +70,9 @@ ExpenseZone::ExpenseZone() ExpenseZone::~ExpenseZone() { - if (report != nullptr) + if (report != NULL) delete report; - if (saved_expense != nullptr) + if (saved_expense != NULL) delete saved_expense; } @@ -112,9 +112,9 @@ RenderResult ExpenseZone::Render(Terminal *term, int update_flag) TextC(term, size_y - 1, buff, col); // generate and display the list of expenses - if (update || update_flag || (report == nullptr)) + if (update || update_flag || (report == NULL)) { - if (report != nullptr) + if (report != NULL) delete report; report = new Report; ListReport(term, report); @@ -140,7 +140,7 @@ SignalResult ExpenseZone::Signal(Terminal *term, const genericChar* message) FnTrace("ExpenseZone::Signal()"); SignalResult signal = SIGNAL_IGNORED; static const genericChar* commands[] = {"next", "prior", "change view", - "restore", "test", "new", nullptr}; + "restore", "test", "new", NULL}; int idx = CompareListN(commands, message); int draw = 0; @@ -185,7 +185,7 @@ SignalResult ExpenseZone::Signal(Terminal *term, const genericChar* message) case 4: // test -- this could mess everything up. Don't do it in live code { ExpenseDB *exp_db = &(term->system_data->expense_db); - exp_db->MoveAll(nullptr); + exp_db->MoveAll(NULL); draw = 1; break; } @@ -224,7 +224,7 @@ SignalResult ExpenseZone::Touch(Terminal *term, int tx, int ty) FnTrace("ExpenseZone::Touch()"); SignalResult retval = SIGNAL_IGNORED; - if (report != nullptr) + if (report != NULL) { FormZone::Touch(term, tx, ty); int yy = report->TouchLine(list_spacing, selected_y); @@ -286,7 +286,7 @@ int ExpenseZone::UpdateForm(Terminal *term, int record) Str doc; FormField *field = FieldList(); - if (expense == nullptr || show_expense == 0) + if (expense == NULL || show_expense == 0) return 1; field = field->next; // skip expense id label @@ -334,10 +334,10 @@ int ExpenseZone::UpdateForm(Terminal *term, int record) if (changed) { - if (report != nullptr) + if (report != NULL) { delete report; - report = nullptr; + report = NULL; } update = 1; } @@ -349,7 +349,7 @@ int ExpenseZone::HideFields() FnTrace("ExpenseZone::HideFields()"); FormField *field = FieldList(); - while (field != nullptr) + while (field != NULL) { field->active = 0; field = field->next; @@ -362,7 +362,7 @@ int ExpenseZone::ShowFields() FnTrace("ExpenseZone::ShowFields()"); FormField *field = FieldList(); - while (field != nullptr) + while (field != NULL) { field->active = 1; field = field->next; @@ -375,21 +375,21 @@ int ExpenseZone::LoadRecord(Terminal *term, int record) FnTrace("ExpenseZone::LoadRecord()"); FormField *field = FieldList(); UserDB *employees = &(term->system_data->user_db); - Employee *employee = nullptr; + Employee *employee = NULL; AccountDB *accounts = &(term->system_data->account_db); - Account *account = nullptr; + Account *account = NULL; genericChar buffer[STRLENGTH]; if (show_expense) expense = term->system_data->expense_db.FindByRecord(term, record); else - expense = nullptr; + expense = NULL; - if (expense != nullptr) + if (expense != NULL) { record_no = record; // save off the expense for Undo - if (saved_expense == nullptr) + if (saved_expense == NULL) saved_expense = new Expense; saved_expense->Copy(expense); // AddTextField("Expense ID", 5, 0); @@ -401,7 +401,7 @@ int ExpenseZone::LoadRecord(Terminal *term, int record) if (term->GetSettings()->allow_user_select) { employee = employees->UserList(); - while (employee != nullptr) + while (employee != NULL) { if (employee->active) field->AddEntry(employee->system_name.Value(), employee->id); @@ -425,7 +425,7 @@ int ExpenseZone::LoadRecord(Terminal *term, int record) field->ClearEntries(); Drawer *drawer = term->system_data->DrawerList(); field->AddEntry(GlobalTranslate("Not Set"), -1); - while (drawer != nullptr) + while (drawer != NULL) { if (drawer->IsOpen()) { @@ -461,7 +461,7 @@ int ExpenseZone::LoadRecord(Terminal *term, int record) field->ClearEntries(); account = accounts->AccountList(); field->AddEntry(GlobalTranslate("Not Set"), -1); - while (account != nullptr) + while (account != NULL) { if (IsValidAccountNumber(term, account->number)) field->AddEntry(account->name.Value(), account->number); @@ -474,7 +474,7 @@ int ExpenseZone::LoadRecord(Terminal *term, int record) field->ClearEntries(); account = accounts->AccountList(); field->AddEntry(GlobalTranslate("Not Set"), -1); - while (account != nullptr) + while (account != NULL) { if (IsValidAccountNumber(term, account->number)) field->AddEntry(account->name.Value(), account->number); @@ -490,7 +490,7 @@ int ExpenseZone::LoadRecord(Terminal *term, int record) // AddListField("Tax Account", NULL); field->ClearEntries(); account = accounts->AccountList(); - while (account != nullptr) + while (account != NULL) { field->AddEntry(account->name.Value(), account->number); account = account->next; @@ -524,7 +524,7 @@ int ExpenseZone::SaveRecord(Terminal *term, int record, int write_file) FnTrace("ExpenseZone::SaveRecord()"); Drawer *dlist = term->system_data->DrawerList(); - if (expense != nullptr) + if (expense != NULL) { FormField *field = FieldList(); field->Get(expense->eid); field = field->next; @@ -544,17 +544,17 @@ int ExpenseZone::SaveRecord(Terminal *term, int record, int write_file) //...coming back to this page should reset everything, but who knows... if (record == -1) term->system_data->expense_db.Save(); - else if (expense != nullptr) + else if (expense != NULL) term->system_data->expense_db.Save(expense->eid); records = RecordCount(term); if (record_no >= records) record_no = records - 1; // Update the drawer balance entry term->system_data->expense_db.AddDrawerPayments(dlist); - if (report != nullptr) + if (report != NULL) delete report; - report = nullptr; - expense = nullptr; + report = NULL; + expense = NULL; show_expense = 0; update = 1; return 0; @@ -564,7 +564,7 @@ int ExpenseZone::RestoreRecord(Terminal *term) { FnTrace("ExpenseZone::RestoreRecord()"); - if (expense != nullptr && saved_expense != nullptr) + if (expense != NULL && saved_expense != NULL) { expense->Copy(saved_expense); LoadRecord(term, record_no); @@ -578,7 +578,7 @@ int ExpenseZone::NewRecord(Terminal *term) expense = term->system_data->expense_db.NewExpense(); // Critical fix: Check if term->user exists before accessing it - if (term->user != nullptr) + if (term->user != NULL) { if (term->GetSettings()->allow_user_select == 0) expense->employee_id = term->user->id; @@ -613,7 +613,7 @@ int ExpenseZone::KillRecord(Terminal *term, int record) { term->system_data->expense_db.Remove(delexp); delete delexp; - expense = nullptr; + expense = NULL; records = RecordCount(term); if (record_no > records) record_no = records - 1; @@ -655,7 +655,7 @@ int ExpenseZone::Search(Terminal *term, int record, const genericChar* word) record_no = -1; show_expense = 0; delete report; - report = nullptr; + report = NULL; } return 1; } @@ -678,10 +678,10 @@ int ExpenseZone::ListReport(Terminal *term, Report *my_report) if (records < 1) my_report->TextC("No Expenses Entered", my_color); - while (currExpense != nullptr) + while (currExpense != NULL) { drawer = dlist->FindBySerial(currExpense->drawer_id); - if ((drawer == nullptr) || (drawer->GetStatus() == DRAWER_OPEN)) + if ((drawer == NULL) || (drawer->GetStatus() == DRAWER_OPEN)) { if (currExpense->IsTraining()) my_color = COLOR_BLUE; diff --git a/zone/expense_zone.hh b/zone/expense_zone.hh index b1eef695..c69ec666 100644 --- a/zone/expense_zone.hh +++ b/zone/expense_zone.hh @@ -19,7 +19,7 @@ */ #ifndef _EXPENSE_ZONE_HH -#define EXPENSE_ZONE_HH +#define _EXPENSE_ZONE_HH #include "form_zone.hh" #include "expense.hh" @@ -40,29 +40,29 @@ class ExpenseZone : public FormZone int allow_balanced; public: ExpenseZone(); - ~ExpenseZone() override; + ~ExpenseZone(); - int Type() override { return ZONE_EXPENSE; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - int Update(Terminal *term, int update_message, const genericChar* value) override + int Type() { return ZONE_EXPENSE; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Signal(Terminal *term, const genericChar* message); + SignalResult Touch(Terminal *term, int tx, int ty); + int Update(Terminal *term, int update_message, const genericChar* value) { return FormZone::Update( term, update_message, value); } - int UpdateForm(Terminal *term, int record) override; + int UpdateForm(Terminal *term, int record); int HideFields(); int ShowFields(); - Flt *Spacing() override { return &list_spacing; } + Flt *Spacing() { return &list_spacing; } - int LoadRecord(Terminal *term, int record) override; - int SaveRecord(Terminal *term, int record, int write_file) override; + int LoadRecord(Terminal *term, int record); + int SaveRecord(Terminal *term, int record, int write_file); int RestoreRecord(Terminal *term); - int NewRecord(Terminal *term) override; - int KillRecord(Terminal *term, int record) override; - int PrintRecord(Terminal *term, int record) override; - int Search(Terminal *term, int record, const genericChar* word) override; + int NewRecord(Terminal *term); + int KillRecord(Terminal *term, int record); + int PrintRecord(Terminal *term, int record); + int Search(Terminal *term, int record, const genericChar* word); int ListReport(Terminal *term, Report *report); - int RecordCount(Terminal *term) override; + int RecordCount(Terminal *term); }; #endif diff --git a/zone/form_zone.cc b/zone/form_zone.cc index b9e74dd7..02bd731a 100644 --- a/zone/form_zone.cc +++ b/zone/form_zone.cc @@ -205,7 +205,7 @@ class ListField : public FormField // Constructor ListField( const genericChar* lbl, const genericChar** options, int* values, Flt min_label, Flt min_list ); // Destructor - ~ListField() override; + ~ListField(); // Member Functions ListFieldEntry *EntryList() { return entry_list.Head(); } @@ -336,7 +336,7 @@ int TemplatePos(const genericChar* temp, int cursor) // Constructor FormZone::FormZone() { - keyboard_focus = nullptr; + keyboard_focus = NULL; record_no = 0; keep_focus = 1; wrap = 1; @@ -362,7 +362,7 @@ RenderResult FormZone::Render(Terminal *term, int update_flag) } if (update_flag || keep_focus == 0) - keyboard_focus = nullptr; + keyboard_focus = NULL; LayoutZone::Render(term, update_flag); @@ -382,7 +382,7 @@ RenderResult FormZone::Render(Terminal *term, int update_flag) LayoutForm(term); - for (FormField *f = FieldList(); f != nullptr; f = f->next) + for (FormField *f = FieldList(); f != NULL; f = f->next) { f->selected = (keyboard_focus == f); if (f->active) @@ -397,14 +397,14 @@ SignalResult FormZone::Signal(Terminal *term, const genericChar* message) static const genericChar* commands[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "00", ".", "backspace", "clear", "new", "search", "nextsearch ", "restore", - "next", "prior", "save", "delete", "print", "unfocus", nullptr}; + "next", "prior", "save", "delete", "print", "unfocus", NULL}; Employee *e = term->user; Printer *p = term->FindPrinter(PRINTER_REPORT); int idx = CompareListN(commands, message); // initial decisions; put these here so we don'term have to duplicate them for // various cases below - if (keyboard_focus == nullptr && idx < 14) + if (keyboard_focus == NULL && idx < 14) { // don'term handle numeric keypad if we don'term have any fields selected return SIGNAL_IGNORED; @@ -490,7 +490,7 @@ SignalResult FormZone::Signal(Terminal *term, const genericChar* message) LoadRecord(term, record_no); break; case 22: // Print - if (p == nullptr || e == nullptr) + if (p == NULL || e == NULL) return SIGNAL_IGNORED; SaveRecord(term, record_no, 0); if (PrintRecord(term, record_no)) @@ -588,7 +588,7 @@ SignalResult FormZone::Keyboard(Terminal *term, int my_key, int state) return Signal(term, "next"); } - if (keyboard_focus == nullptr) + if (keyboard_focus == NULL) return SIGNAL_IGNORED; switch (my_key) @@ -613,7 +613,7 @@ SignalResult FormZone::Keyboard(Terminal *term, int my_key, int state) int FormZone::Add(FormField *fe) { FnTrace("FormZone::Add()"); - if (fe == nullptr) + if (fe == NULL) return 1; // Error field_list.AddToTail(fe); @@ -758,7 +758,7 @@ int FormZone::RightAlign() int FormZone::Remove(FormField *f) { FnTrace("FormZone::Remove()"); - if (f == nullptr) + if (f == NULL) return 1; return field_list.Remove(f); @@ -822,7 +822,7 @@ int FormZone::LayoutForm(Terminal *term) FormField *FormZone::Find(Flt px, Flt py) { FnTrace("FormZone::Find()"); - for (FormField *fe = FieldList(); fe != nullptr; fe = fe->next) + for (FormField *fe = FieldList(); fe != NULL; fe = fe->next) { if (fe->active && fe->modify && py >= (fe->y -.5) && py <= (fe->y + fe->h -.5) && @@ -831,19 +831,19 @@ FormField *FormZone::Find(Flt px, Flt py) return fe; } } - return nullptr; + return NULL; } int FormZone::NextField() { FnTrace("FormZone::NextField()"); - if (keyboard_focus == nullptr) + if (keyboard_focus == NULL) return FirstField(); do { keyboard_focus = keyboard_focus->next; - if (keyboard_focus == nullptr) + if (keyboard_focus == NULL) return FirstField(); } while (keyboard_focus->modify == 0 || keyboard_focus->active == 0); @@ -853,13 +853,13 @@ int FormZone::NextField() int FormZone::ForeField() { FnTrace("FormZone::ForeField()"); - if (keyboard_focus == nullptr) + if (keyboard_focus == NULL) return LastField(); do { keyboard_focus = keyboard_focus->fore; - if (keyboard_focus == nullptr) + if (keyboard_focus == NULL) return LastField(); } while (keyboard_focus->modify == 0 || keyboard_focus->active == 0); @@ -920,9 +920,9 @@ RenderResult ListFormZone::Render(Terminal *term, int update_flag) } if (update_flag || keep_focus == 0) - keyboard_focus = nullptr; + keyboard_focus = NULL; - FormZone::Render(term, update_flag); + LayoutZone::Render(term, update_flag); if (show_list) { @@ -949,7 +949,7 @@ RenderResult ListFormZone::Render(Terminal *term, int update_flag) if (records > 0) { LayoutForm(term); - for (FormField *f = FieldList(); f != nullptr; f = f->next) + for (FormField *f = FieldList(); f != NULL; f = f->next) { f->selected = (keyboard_focus == f); if (f->active) @@ -965,7 +965,7 @@ SignalResult ListFormZone::Signal(Terminal *term, const genericChar* message) FnTrace("ListFormZone::Signal()"); static const genericChar* commands[] = { "new", "next", "prior", "save", "restore", - "delete", "print", "unfocus", "change view", nullptr}; + "delete", "print", "unfocus", "change view", NULL}; int idx = CompareListN(commands, message); if (idx == -1) @@ -1039,7 +1039,7 @@ SignalResult ListFormZone::Signal(Terminal *term, const genericChar* message) LoadRecord(term, record_no); break; case 6: // Print - if (p == nullptr || e == nullptr) + if (p == NULL || e == NULL) return SIGNAL_IGNORED; if (show_list) { @@ -1089,7 +1089,7 @@ SignalResult ListFormZone::Touch(Terminal *term, int tx, int ty) if (records <= 0) return SIGNAL_IGNORED; - FormZone::Touch(term, tx, ty); + LayoutZone::Touch(term, tx, ty); if (show_list) { int new_page = list_page; @@ -1145,7 +1145,7 @@ SignalResult ListFormZone::Mouse(Terminal *term, int action, int mx, int my) return sig; } - FormZone::Touch(term, mx, my); + LayoutZone::Touch(term, mx, my); if (show_list) { int new_page = list_page; @@ -1234,7 +1234,7 @@ SignalResult ListFormZone::Keyboard(Terminal *term, int my_key, int state) return SIGNAL_OKAY; } - if (keyboard_focus == nullptr) + if (keyboard_focus == NULL) return SIGNAL_IGNORED; switch (my_key) @@ -1269,8 +1269,8 @@ int ListFormZone::Update(Terminal *term, int update_message, const genericChar* // Constructor FormField::FormField() { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; new_line = 0; x = 0; y = 0; @@ -1675,7 +1675,7 @@ int TextField::Append(const genericChar* my_string) int TextField::Append(Str &my_string) { FnTrace("TextField::Append()"); - genericChar* tbuff = nullptr; + genericChar* tbuff = NULL; int retval = 0; int numdigits = 1; @@ -2420,7 +2420,7 @@ int TimeDayField::Set(TimeInfo *tinfo) { FnTrace("TimeDayField::Set(TimeInfo *)"); - if (tinfo != nullptr && tinfo->IsSet()) + if (tinfo != NULL && tinfo->IsSet()) { is_unset = 0; day = tinfo->WeekDay(); @@ -2655,8 +2655,8 @@ int WeekDayField::Get(int &d) // Constructor ListFieldEntry::ListFieldEntry(const genericChar* lbl, int val) { - next = nullptr; - fore = nullptr; + next = NULL; + fore = NULL; label.Set(lbl); value = val; active = 1; @@ -2667,7 +2667,7 @@ ListFieldEntry::ListFieldEntry(const genericChar* lbl, int val) ListField::ListField(const genericChar* lbl, const genericChar* *options, int *values, Flt min_label, Flt min_list) { - current = nullptr; + current = NULL; label.Set(lbl); SetList(options, values); modify = 1; @@ -2687,7 +2687,7 @@ int ListField::Init(Terminal *term, FormZone *fzone) { FnTrace("ListField::Init()"); entry_width = min_entry_width; - for (ListFieldEntry *lfe = EntryList(); lfe != nullptr; lfe = lfe->next) + for (ListFieldEntry *lfe = EntryList(); lfe != NULL; lfe = lfe->next) { Flt len = fzone->TextWidth(term, lfe->label.Value()); if (len > entry_width) @@ -2722,7 +2722,7 @@ RenderResult ListField::Render(Terminal *term, FormZone *fzone) xx += label_width + 1; } - if (current == nullptr) + if (current == NULL) current = EntryList(); fzone->Button(term, xx, y, entry_width, selected); @@ -2784,7 +2784,7 @@ SignalResult ListField::Mouse(Terminal *term, FormZone *fzone, else if (action & MOUSE_RIGHT) ForeEntry(); else if (action & MOUSE_MIDDLE) - current = nullptr; + current = NULL; } return SIGNAL_OKAY; } @@ -2794,13 +2794,13 @@ int ListField::NextEntry(int loop) FnTrace("ListField::NextEntry()"); if (current) current = current->next; - if (current == nullptr) + if (current == NULL) { current = EntryList(); ++loop; } - if (current == nullptr || loop > 1) + if (current == NULL || loop > 1) return 1; if (current->active == 0) return NextEntry(loop); @@ -2813,13 +2813,13 @@ int ListField::ForeEntry(int loop) FnTrace("ListField::ForeEntry()"); if (current) current = current->fore; - if (current == nullptr) + if (current == NULL) { current = EntryListEnd(); ++loop; } - if (current == nullptr || loop > 1) + if (current == NULL || loop > 1) return 1; if (current->active == 0) return ForeEntry(loop); @@ -2830,7 +2830,7 @@ int ListField::ForeEntry(int loop) int ListField::Set(int v) { FnTrace("ListField::Set()"); - for (ListFieldEntry *lfe = EntryList(); lfe != nullptr; lfe = lfe->next) + for (ListFieldEntry *lfe = EntryList(); lfe != NULL; lfe = lfe->next) { if (lfe->value == v) { @@ -2858,13 +2858,13 @@ int ListField::SetName(Str &set_name) int retval = 1; ListFieldEntry *lfe = EntryList(); - while (lfe != nullptr) + while (lfe != NULL) { if (strcmp(set_name.Value(), lfe->label.Value()) == 0) { current = lfe; retval = 0; - lfe = nullptr; + lfe = NULL; } else lfe = lfe->next; @@ -2878,7 +2878,7 @@ int ListField::GetName(Str &get_name) FnTrace("ListField::GetName()"); int retval = 1; - if (current != nullptr) + if (current != NULL) { get_name.Set(current->label.Value()); retval = 0; @@ -2891,11 +2891,11 @@ int ListField::SetList(const genericChar* *option_list, int *value_list) { FnTrace("ListField::SetList()"); ClearEntries(); - if (option_list == nullptr) + if (option_list == NULL) return 0; int i = 0; - while (option_list[i] != nullptr) + while (option_list[i] != NULL) { int val = i; if (value_list) @@ -2930,7 +2930,7 @@ int ListField::ClearEntries() { FnTrace("ListField::ClearEntries()"); entry_list.Purge(); - current = nullptr; + current = NULL; return 0; } diff --git a/zone/form_zone.hh b/zone/form_zone.hh index 8d393765..bc84dd37 100644 --- a/zone/form_zone.hh +++ b/zone/form_zone.hh @@ -18,8 +18,8 @@ * base touch zone for data entry and display */ -#ifndef FORM_ZONE_HH -#define FORM_ZONE_HH +#ifndef _FORM_ZONE_HH +#define _FORM_ZONE_HH #include "layout_zone.hh" #include "report.hh" @@ -63,11 +63,11 @@ public: FormField *FieldList() { return field_list.Head(); } FormField *FieldListEnd() { return field_list.Tail(); } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Keyboard(Terminal *term, int key, int state) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - SignalResult Mouse(Terminal *term, int action, int mx, int my) override; + virtual RenderResult Render(Terminal *term, int update_flag); + virtual SignalResult Signal(Terminal *term, const genericChar* message); + virtual SignalResult Keyboard(Terminal *term, int key, int state); + virtual SignalResult Touch(Terminal *term, int tx, int ty); + virtual SignalResult Mouse(Terminal *term, int action, int mx, int my); virtual int LoadRecord(Terminal *term, int record) = 0; virtual int SaveRecord(Terminal *term, int record, int write_file) = 0; @@ -86,7 +86,7 @@ public: int AddTimeDateField(const genericChar* l, int mod = 1, int can_unset = 1); int AddTimeDayField(const genericChar* l, int mod = 1, int can_unset = 1); int AddWeekDayField(const genericChar* l, int mod = 1); - int AddListField( const genericChar* label, const genericChar** item_array, int* value_array = nullptr, Flt min1 = 0, Flt min2 = 0 ); + int AddListField( const genericChar* label, const genericChar** item_array, int* value_array = 0, Flt min1 = 0, Flt min2 = 0 ); int AddButtonField(const genericChar* label, const genericChar* message); int AddTemplateField(const genericChar* label, const genericChar* temp, Flt min_label = 0); int AddNewLine(int lines = 1); @@ -120,12 +120,12 @@ public: ListFormZone(); // Member Functions - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Keyboard(Terminal *term, int key, int state) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - SignalResult Mouse(Terminal *term, int action, int mx, int my) override; - int Update(Terminal *term, int update_message, const genericChar* value) override; + virtual RenderResult Render(Terminal *term, int update_flag); + virtual SignalResult Signal(Terminal *term, const genericChar* message); + virtual SignalResult Keyboard(Terminal *term, int key, int state); + virtual SignalResult Touch(Terminal *term, int tx, int ty); + virtual SignalResult Mouse(Terminal *term, int action, int mx, int my); + virtual int Update(Terminal *term, int update_message, const genericChar* value); virtual int ListReport(Terminal *term, Report *report) = 0; }; @@ -153,7 +153,7 @@ public: // Constructor FormField(); // Destructor - virtual ~FormField() = default; + virtual ~FormField() { } // Member Functions int Draw(Terminal *term, FormZone *z); @@ -198,7 +198,7 @@ public: virtual int ClearEntries() { return 1; } virtual int AddEntry(const genericChar* name, int value) { return 1; } - virtual void Print(); // debug function, not for live code + virtual void Print(void); // debug function, not for live code }; -#endif // FORM_ZONE_HH +#endif diff --git a/zone/hardware_zone.cc b/zone/hardware_zone.cc index 5ab7ca2f..38d83811 100644 --- a/zone/hardware_zone.cc +++ b/zone/hardware_zone.cc @@ -46,12 +46,12 @@ int IsKitchenPrinter(int type) /**** HardwareZone class ****/ static const genericChar* DrawerCountName[] = { - "None", "One", "Two", nullptr}; + "None", "One", "Two", NULL}; static int DrawerCountValue[] = { 0, 1, 2, -1}; static const genericChar* DrawerPulseName[] = { - "Pulse 1", "Pulse 2", nullptr }; + "Pulse 1", "Pulse 2", NULL }; static int DrawerPulseValue[] = { 0, 1, -1 }; @@ -66,9 +66,7 @@ HardwareZone::HardwareZone() // Term Fields AddTextField("This Display's Name is", 32); term_start = FieldListEnd(); - AddListField("This Display's Function is", - const_cast(TermTypeName.data()), - const_cast(TermTypeValue.data())); + AddListField("This Display's Function is", TermTypeName, TermTypeValue); AddListField("If This Display is a Kitchen Video Then It Sorts By", CheckDisplayOrderName, CheckDisplayOrderValue); AddListField("The Requisition Ticket Heading is", WOHeadingName, WOHeadingValue); AddListField("Does This Display Print Requisition Tickets?", NoYesName, NoYesValue); @@ -119,9 +117,7 @@ HardwareZone::HardwareZone() // Printer Fields AddTextField("This Printer Is Identified As", 20); printer_start = FieldListEnd(); - AddListField("This Printer's Performance Assignment Is", - const_cast(PrinterTypeName.data()), - const_cast(PrinterTypeValue.data())); + AddListField("This Printer's Performance Assignment Is", PrinterTypeName, PrinterTypeValue); AddTextField("This Printer's Queue Name Is", 20); //AddListField("Connection Interface", PortName, PortValue); AddListField("This Printer's Output Is Formatted For", PrinterModelName, PrinterModelValue); @@ -218,9 +214,9 @@ SignalResult HardwareZone::Signal(Terminal *term, const genericChar* message) static const genericChar* commands[] = { "section0", "section1", "changestatus", "calibrate", "testreceipt", "testreport", - "printertest", "opendrawer1", "opendrawer2", nullptr}; + "printertest", "opendrawer1", "opendrawer2", NULL}; - Printer *printer = nullptr; + Printer *printer = NULL; int idx = CompareList(message, commands); switch (idx) { @@ -265,11 +261,11 @@ SignalResult HardwareZone::Signal(Terminal *term, const genericChar* message) int HardwareZone::LoadRecord(Terminal *term, int record) { FnTrace("HardwareZone::LoadRecord()"); - PrinterInfo *pi = nullptr; - TermInfo *ti = nullptr; - FormField *thisForm = nullptr; + PrinterInfo *pi = NULL; + TermInfo *ti = NULL; + FormField *thisForm = NULL; - for (FormField *field = FieldList(); field != nullptr; field = field->next) + for (FormField *field = FieldList(); field != NULL; field = field->next) field->active = 0; Settings *settings = term->GetSettings(); @@ -277,7 +273,7 @@ int HardwareZone::LoadRecord(Terminal *term, int record) { case 1: // remote printer pi = settings->FindPrinterByRecord(record); - if (pi == nullptr) + if (pi == NULL) break; thisForm = printer_start; @@ -297,7 +293,7 @@ int HardwareZone::LoadRecord(Terminal *term, int record) break; default: // terminal ti = settings->FindTermByRecord(record); - if (ti == nullptr) + if (ti == NULL) break; thisForm = term_start; @@ -348,10 +344,10 @@ int HardwareZone::LoadRecord(Terminal *term, int record) int HardwareZone::SaveRecord(Terminal *term, int record, int write_file) { FnTrace("HardwareZone::SaveRecord()"); - TermInfo *ti = nullptr; - PrinterInfo *pi = nullptr; + TermInfo *ti = NULL; + PrinterInfo *pi = NULL; Settings *settings = term->GetSettings(); - FormField *field = nullptr; + FormField *field = NULL; switch (section) { @@ -513,16 +509,16 @@ int HardwareZone::ChangeStatus(Terminal *term) { FnTrace("HardwareZone::ChangeStatus()"); Settings *settings = term->GetSettings(); - TermInfo *ti = nullptr; - Terminal *terminal = nullptr; - PrinterInfo *pi = nullptr; - Printer *printer = nullptr; + TermInfo *ti = NULL; + Terminal *terminal = NULL; + PrinterInfo *pi = NULL; + Printer *printer = NULL; switch (section) { default: ti = settings->FindTermByRecord(record_no); - if (ti == nullptr || ti->IsServer()) + if (ti == NULL || ti->IsServer()) return 0; terminal = ti->FindTerm(term->parent); @@ -539,14 +535,14 @@ int HardwareZone::ChangeStatus(Terminal *term) term->OpenDialog("Starting The Display Terminal\\Please Wait"); ti->OpenTerm(term->parent, 1); term->KillDialog(); - term->UpdateAllTerms(UPDATE_TERMINALS | UPDATE_PRINTERS, nullptr); + term->UpdateAllTerms(UPDATE_TERMINALS | UPDATE_PRINTERS, NULL); // enable any associated printers pi = settings->PrinterList(); while (pi) { printer = pi->FindPrinter(term->parent); - if (printer == nullptr && + if (printer == NULL && (pi->host == ti->printer_host || pi->host == ti->display_host)) pi->OpenPrinter(term->parent, 1); pi = pi->next; @@ -558,7 +554,7 @@ int HardwareZone::ChangeStatus(Terminal *term) break; case 1: pi = settings->FindPrinterByRecord(record_no); - if (pi == nullptr) + if (pi == NULL) return 0; printer = pi->FindPrinter(term->parent); @@ -573,7 +569,7 @@ int HardwareZone::ChangeStatus(Terminal *term) term->OpenDialog("Starting The Printer\\Please Wait"); pi->OpenPrinter(term->parent, 1); term->KillDialog(); - term->UpdateAllTerms(UPDATE_PRINTERS, nullptr); + term->UpdateAllTerms(UPDATE_PRINTERS, NULL); } break; } @@ -588,11 +584,11 @@ int HardwareZone::Calibrate(Terminal *term) Settings *settings = term->GetSettings(); TermInfo *ti = settings->FindTermByRecord(record_no); - if (ti == nullptr) + if (ti == NULL) return 0; Terminal *parent_term = ti->FindTerm(term->parent); - if (parent_term == nullptr) + if (parent_term == NULL) return 0; else return parent_term->CalibrateTS(); @@ -606,5 +602,5 @@ Printer *HardwareZone::FindPrinter(Terminal *term) if (ti) return ti->FindPrinter(MasterControl); else - return nullptr; + return NULL; } diff --git a/zone/hardware_zone.hh b/zone/hardware_zone.hh index ff8f5cf3..4b0a2447 100644 --- a/zone/hardware_zone.hh +++ b/zone/hardware_zone.hh @@ -19,7 +19,7 @@ */ #ifndef _HARDWARE_ZONE_HH -#define HARDWARE_ZONE_HH +#define _HARDWARE_ZONE_HH #include "form_zone.hh" @@ -41,18 +41,18 @@ public: HardwareZone(); // Member Functions - int Type() override { return ZONE_HARDWARE; } - RenderResult Render(Terminal *t, int update_flag) override; - SignalResult Signal(Terminal *t, const genericChar* message) override; - Flt *Spacing() override { return &list_spacing; } - - int UpdateForm(Terminal *term, int record) override; - int LoadRecord(Terminal *t, int record) override; - int SaveRecord(Terminal *t, int record, int write_file) override; - int NewRecord(Terminal *t) override; - int KillRecord(Terminal *t, int record) override; - int ListReport(Terminal *t, Report *r) override; - int RecordCount(Terminal *t) override; + int Type() { return ZONE_HARDWARE; } + RenderResult Render(Terminal *t, int update_flag); + SignalResult Signal(Terminal *t, const genericChar* message); + Flt *Spacing() { return &list_spacing; } + + int UpdateForm(Terminal *term, int record); + int LoadRecord(Terminal *t, int record); + int SaveRecord(Terminal *t, int record, int write_file); + int NewRecord(Terminal *t); + int KillRecord(Terminal *t, int record); + int ListReport(Terminal *t, Report *r); + int RecordCount(Terminal *t); int ChangeSection(Terminal *t, int no); int ChangeStatus(Terminal *t); int Calibrate(Terminal *t); diff --git a/zone/inventory_zone.cc b/zone/inventory_zone.cc index ce096be9..166de8aa 100644 --- a/zone/inventory_zone.cc +++ b/zone/inventory_zone.cc @@ -118,7 +118,7 @@ RenderResult ProductZone::Render(Terminal *t, int update_flag) if (update_flag == RENDER_NEW) record_no = 0; - if (t->stock == nullptr) + if (t->stock == NULL) t->stock = t->system_data->inventory.CurrentStock(); ListFormZone::Render(t, update_flag); @@ -181,7 +181,7 @@ SignalResult ProductZone::Signal(Terminal *term, const genericChar* message) FnTrace("ProductZone::Signal()"); static const genericChar* commands[] = { "count", "increase", "decrease", "cancel", "save", - "input", "next stock", "prior stock", "check", "print", nullptr}; + "input", "next stock", "prior stock", "check", "print", NULL}; int idx = -1; if (StringCompare(message, "amount ", 7) == 0) @@ -191,16 +191,16 @@ SignalResult ProductZone::Signal(Terminal *term, const genericChar* message) if (idx < 0) return ListFormZone::Signal(term, message); - if (term->stock == nullptr) + if (term->stock == NULL) return SIGNAL_IGNORED; System *sys = term->system_data; Product *pr = sys->inventory.FindProductByRecord(record_no); - if (pr == nullptr) + if (pr == NULL) return SIGNAL_IGNORED; int final = term->stock->end_time.IsSet(); - StockEntry *stock_entry = nullptr; + StockEntry *stock_entry = NULL; if (final) stock_entry = term->stock->FindStock(pr->id, 1); @@ -250,19 +250,19 @@ SignalResult ProductZone::Signal(Terminal *term, const genericChar* message) return SIGNAL_IGNORED; case 6: // next stock - if (term->stock == nullptr || term->stock->next == nullptr) + if (term->stock == NULL || term->stock->next == NULL) return SIGNAL_IGNORED; term->stock = term->stock->next; break; case 7: // prior stock - if (term->stock == nullptr || term->stock->fore == nullptr) + if (term->stock == NULL || term->stock->fore == NULL) return SIGNAL_IGNORED; term->stock = term->stock->fore; break; case 8: // check - if (term->stock == nullptr) + if (term->stock == NULL) return SIGNAL_IGNORED; if (term->stock->next) term->stock = sys->inventory.CurrentStock(); @@ -326,7 +326,7 @@ int ProductZone::LoadRecord(Terminal *term, int record) FnTrace("ProductZone::LoadRecord()"); Product *prod = term->system_data->inventory.FindProductByRecord(record); - if (prod == nullptr) + if (prod == NULL) { printf("Can'term Load Record %d\n", record); return 1; @@ -460,7 +460,7 @@ int ProductZone::KillRecord(Terminal *t, int record) FnTrace("ProductZone::KillRecord()"); System *sys = t->system_data; Product *pr = sys->inventory.FindProductByRecord(record); - if (pr == nullptr) + if (pr == NULL) return 1; sys->inventory.Remove(pr); delete pr; @@ -485,7 +485,7 @@ int ProductZone::Search(Terminal *t, int record, const genericChar* word) FnTrace("ProductZone::Search()"); int r = 0; Product *pr = t->system_data->inventory.FindProductByWord(word, r); - if (pr == nullptr) + if (pr == NULL) return 0; // no matches record_no = r; return 1; // one match (only one for now) @@ -496,17 +496,18 @@ int ProductZone::Search(Terminal *t, int record, const genericChar* word) // Constructor RC_Part::RC_Part() { - next = nullptr; - rc = nullptr; - pr = nullptr; - rp = nullptr; + next = NULL; + rc = NULL; + pr = NULL; + rp = NULL; page = 0; lit = 0; } // Destructor RC_Part::~RC_Part() -= default; +{ +} // Member Functions int RC_Part::Render(Terminal *t) @@ -600,7 +601,7 @@ int RC_Part::RemoveIngredient(Recipe *r) { r->Remove(rp); delete rp; - rp = nullptr; + rp = NULL; return 0; } else @@ -677,12 +678,12 @@ RenderResult RecipeZone::Render(Terminal *t, int update_flag) { RC_Part *p; LayoutParts(); - for (p = part_list.Head(); p != nullptr; p = p->next) + for (p = part_list.Head(); p != NULL; p = p->next) if (p->page == part_page) p->Render(t); LayoutRecipe(); - for (p = recipe_list.Head(); p != nullptr; p = p->next) + for (p = recipe_list.Head(); p != NULL; p = p->next) p->Render(t); } @@ -729,7 +730,7 @@ SignalResult RecipeZone::Touch(Terminal *t, int tx, int ty) if (p->page == part_page && p->IsPointIn(tx, ty)) { Recipe *rc = sys->inventory.FindRecipeByRecord(record_no); - if (rc == nullptr) + if (rc == NULL) return SIGNAL_IGNORED; p->lit = 1; p->Draw(t); @@ -746,7 +747,7 @@ SignalResult RecipeZone::Touch(Terminal *t, int tx, int ty) if (p->IsPointIn(tx, ty)) { Recipe *rc = sys->inventory.FindRecipeByRecord(record_no); - if (rc == nullptr) + if (rc == NULL) return SIGNAL_IGNORED; p->lit = 1; p->Draw(t); @@ -764,7 +765,7 @@ int RecipeZone::LoadRecord(Terminal *t, int record) { FnTrace("RecipeZone::LoadRecord()"); Recipe *rc = t->system_data->inventory.FindRecipeByRecord(record); - if (rc == nullptr) + if (rc == NULL) return 1; FormField *f = FieldList(); @@ -810,7 +811,7 @@ int RecipeZone::NewRecord(Terminal *t) { FnTrace("RecipeZone::NewRecord()"); Recipe *rc = new Recipe; - if (rc == nullptr) + if (rc == NULL) return 1; if (t->system_data->inventory.Add(rc)) { @@ -831,7 +832,7 @@ int RecipeZone::KillRecord(Terminal *t, int record) FnTrace("RecipeZone::KillRecord()"); System *sys = t->system_data; Recipe *rc = sys->inventory.FindRecipeByRecord(record); - if (rc == nullptr) + if (rc == NULL) return 1; sys->inventory.Remove(rc); delete rc; @@ -844,7 +845,7 @@ int RecipeZone::Search(Terminal *t, int record, const genericChar* word) FnTrace("RecipeZone::Search()"); int r = 0; Recipe *rc = t->system_data->inventory.FindRecipeByWord(word, r); - if (rc == nullptr) + if (rc == NULL) return 0; // no matches record_no = r; return 1; // one match (only one for now) @@ -853,12 +854,12 @@ int RecipeZone::Search(Terminal *t, int record, const genericChar* word) int RecipeZone::ListReport(Terminal *t, Report *r) { FnTrace("RecipeZone::ListReport()"); - if (r == nullptr) + if (r == NULL) return 1; r->update_flag = UPDATE_MENU; Recipe *rc = t->system_data->inventory.RecipeList(); - if (rc == nullptr) + if (rc == NULL) { r->TextC(t->Translate("There are no recipes defined")); return 0; @@ -888,7 +889,7 @@ int RecipeZone::LayoutParts() int my_page = 0; int xx = x + border; int yy = y + b; - for (RC_Part *rpart = part_list.Head(); rpart != nullptr; rpart = rpart->next) + for (RC_Part *rpart = part_list.Head(); rpart != NULL; rpart = rpart->next) { rpart->lit = 0; rpart->x = xx; @@ -912,7 +913,7 @@ int RecipeZone::LayoutParts() int RecipeZone::MakeRecipe(Terminal *t, Recipe *rc) { FnTrace("RecipeZone::MakeRecipe()"); - if (rc == nullptr) + if (rc == NULL) return 1; System *sys = t->system_data; @@ -948,7 +949,7 @@ int RecipeZone::LayoutRecipe() int hh = 36; int xx = topx, yy = topy; - for (RC_Part *p = recipe_list.Head(); p != nullptr; p = p->next) + for (RC_Part *p = recipe_list.Head(); p != NULL; p = p->next) { p->lit = 0; p->x = xx; @@ -1010,7 +1011,7 @@ int VendorZone::LoadRecord(Terminal *t, int record) { FnTrace("VendorZone::LoadRecord()"); Vendor *v = t->system_data->inventory.FindVendorByRecord(record); - if (v == nullptr) + if (v == NULL) return 1; FormField *f = FieldList(); @@ -1078,7 +1079,7 @@ int VendorZone::KillRecord(Terminal *t, int record) FnTrace("VendorZone::KillRecord()"); System *sys = t->system_data; Vendor *v = sys->inventory.FindVendorByRecord(record); - if (v == nullptr) + if (v == NULL) return 1; sys->inventory.Remove(v); delete v; @@ -1091,7 +1092,7 @@ int VendorZone::Search(Terminal *t, int record, const genericChar* word) FnTrace("VendorZone::Search()"); int r = 0; Vendor *v = t->system_data->inventory.FindVendorByWord(word, r); - if (v == nullptr) + if (v == NULL) return 0; // no matches record_no = r; return 1; // one match (only one for now) @@ -1100,11 +1101,11 @@ int VendorZone::Search(Terminal *t, int record, const genericChar* word) int VendorZone::ListReport(Terminal *t, Report *r) { FnTrace("VendorZone::ListReport()"); - if (r == nullptr) + if (r == NULL) return 1; Vendor *v = t->system_data->inventory.VendorList(); - if (v == nullptr) + if (v == NULL) { r->TextC(t->Translate("There are no vendors defined")); return 0; @@ -1355,7 +1356,7 @@ int ItemListZone::LoadRecord(Terminal *t, int record) } } - if (si == nullptr) + if (si == NULL) return 1; FormField *f = FieldList(); @@ -1444,7 +1445,7 @@ int ItemListZone::SaveRecord(Terminal *t, int record, int write_file) si = si->fore; ++record_no; } - t->UpdateOtherTerms(UPDATE_MENU, nullptr); + t->UpdateOtherTerms(UPDATE_MENU, NULL); } } @@ -1466,7 +1467,7 @@ int ItemListZone::Search(Terminal *t, int record, const genericChar* word) FnTrace("ItemListZone::Search()"); int r = 0; SalesItem *mi = t->system_data->menu.FindByWord(word, r); - if (mi == nullptr) + if (mi == NULL) return 0; // no matches record_no = r; return 1; // one match (only 1 for now) @@ -1475,12 +1476,12 @@ int ItemListZone::Search(Terminal *t, int record, const genericChar* word) int ItemListZone::ListReport(Terminal *t, Report *r) { FnTrace("ItemListZone::ListRecord()"); - if (r == nullptr) + if (r == NULL) return 1; r->update_flag = UPDATE_MENU; SalesItem *si = t->system_data->menu.ItemList(); - if (si == nullptr) + if (si == NULL) { r->TextC(t->Translate("There are no menu items defined")); return 0; @@ -1566,13 +1567,13 @@ const genericChar* ItemListZone::GetItemTypeName(int item_type) // Constructor InvoiceZone::InvoiceZone() { - invoice_report = nullptr; + invoice_report = NULL; invoice_page = 0; edit = 0; list_header = 3; form_header = 2; - AddListField("Vendor", nullptr); + AddListField("Vendor", NULL); AddTextField("ID", 9); AddDateField("Date", 1, 0); } @@ -1593,7 +1594,7 @@ RenderResult InvoiceZone::Render(Terminal *t, int update_flag) if (invoice_report) { delete invoice_report; - invoice_report = nullptr; + invoice_report = NULL; } if (update_flag == RENDER_NEW) { @@ -1604,7 +1605,7 @@ RenderResult InvoiceZone::Render(Terminal *t, int update_flag) } System *sys = t->system_data; - if (t->stock == nullptr) + if (t->stock == NULL) t->stock = sys->inventory.CurrentStock(); FormField *f = FieldList(); @@ -1614,12 +1615,12 @@ RenderResult InvoiceZone::Render(Terminal *t, int update_flag) no_line = !show_list; ListFormZone::Render(t, update_flag); - if (t->stock == nullptr) + if (t->stock == NULL) return RENDER_OKAY; Invoice *in = t->stock->FindInvoiceByRecord(record_no); int col = color[0]; - if (in == nullptr || show_list) + if (in == NULL || show_list) { // normal list mode genericChar tm1[32], tm2[32]; @@ -1642,7 +1643,7 @@ RenderResult InvoiceZone::Render(Terminal *t, int update_flag) if (invoice_report) { delete invoice_report; - invoice_report = nullptr; + invoice_report = NULL; } } else @@ -1655,7 +1656,7 @@ RenderResult InvoiceZone::Render(Terminal *t, int update_flag) TextPosR(t, size_x - 20, 4, "Amount", COLOR_RED); TextPosR(t, size_x - 10, 4, "Unit Cost", col); TextPosR(t, size_x, 4, "Total Cost", col); - if (invoice_report == nullptr) + if (invoice_report == NULL) { invoice_report = new Report; sys->inventory.ProductListReport(t, in, invoice_report); @@ -1670,7 +1671,7 @@ RenderResult InvoiceZone::Render(Terminal *t, int update_flag) { // invoice view TextC(t, 0, GlobalTranslate("View Invoice"), col); - if (invoice_report == nullptr) + if (invoice_report == NULL) { invoice_report = new Report; sys->inventory.InvoiceReport(t, in, invoice_report); @@ -1690,7 +1691,7 @@ SignalResult InvoiceZone::Signal(Terminal *t, const genericChar* message) FnTrace("InvoiceZone::Signal()"); static const genericChar* commands[] = { "print", "save", "next", "prior", "input", "cancel", "edit", - "next stock", "prior stock", nullptr}; + "next stock", "prior stock", NULL}; int idx = -1; if (StringCompare(message, "amount ", 7) == 0) @@ -1701,7 +1702,7 @@ SignalResult InvoiceZone::Signal(Terminal *t, const genericChar* message) return ListFormZone::Signal(t, message); System *sys = t->system_data; - Invoice *in = t->stock ? t->stock->FindInvoiceByRecord(record_no) : nullptr; + Invoice *in = t->stock ? t->stock->FindInvoiceByRecord(record_no) : NULL; switch (idx) { case 0: // print @@ -1762,7 +1763,7 @@ SignalResult InvoiceZone::Signal(Terminal *t, const genericChar* message) Draw(t, 1); return SIGNAL_OKAY; case 7: // next stock - if (t->stock == nullptr || t->stock->next == nullptr) + if (t->stock == NULL || t->stock->next == NULL) return SIGNAL_IGNORED; t->stock = t->stock->next; record_no = 0; @@ -1771,7 +1772,7 @@ SignalResult InvoiceZone::Signal(Terminal *t, const genericChar* message) Draw(t, 1); return SIGNAL_OKAY; case 8: // prior stock - if (t->stock == nullptr || t->stock->fore == nullptr) + if (t->stock == NULL || t->stock->fore == NULL) return SIGNAL_IGNORED; t->stock = t->stock->fore; record_no = 0; @@ -1794,7 +1795,7 @@ SignalResult InvoiceZone::Signal(Terminal *t, const genericChar* message) ie->amount.type = ut; ie->amount.amount = amt; delete invoice_report; - invoice_report = nullptr; + invoice_report = NULL; Draw(t, 0); return SIGNAL_OKAY; } @@ -1811,7 +1812,7 @@ SignalResult InvoiceZone::Touch(Terminal *t, int tx, int ty) if (edit && invoice_report) { // FIX - support multiple pages - ListFormZone::Touch(t, tx, ty); + LayoutZone::Touch(t, tx, ty); int line = invoice_report->TouchLine(list_spacing, selected_y); if (line >= 0 && line < t->system_data->inventory.ProductCount()) { @@ -1832,7 +1833,7 @@ SignalResult InvoiceZone::Mouse(Terminal *t, int action, int mx, int my) if (edit && invoice_report) { // FIX - support multiple pages - ListFormZone::Touch(t, mx, my); + LayoutZone::Touch(t, mx, my); int line = invoice_report->TouchLine(list_spacing, selected_y); if (line >= 0 && line < t->system_data->inventory.ProductCount()) { @@ -1850,15 +1851,15 @@ int InvoiceZone::LoadRecord(Terminal *t, int record) if (invoice_report) { delete invoice_report; - invoice_report = nullptr; + invoice_report = NULL; entry_no = 0; } - if (t->stock == nullptr) + if (t->stock == NULL) return 1; Invoice *in = t->stock->FindInvoiceByRecord(record); - if (in == nullptr) + if (in == NULL) return 1; FormField *f = FieldList(); @@ -1883,11 +1884,11 @@ int InvoiceZone::LoadRecord(Terminal *t, int record) int InvoiceZone::SaveRecord(Terminal *t, int record, int write_file) { FnTrace("InvoiceZone::SaveRecord()"); - if (t->stock == nullptr) + if (t->stock == NULL) return 1; Invoice *in = t->stock->FindInvoiceByRecord(record); - if (in == nullptr) + if (in == NULL) return 1; FormField *f = FieldList(); f->Get(in->vendor_id); f = f->next; @@ -1899,7 +1900,7 @@ int InvoiceZone::SaveRecord(Terminal *t, int record, int write_file) int InvoiceZone::NewRecord(Terminal *t) { FnTrace("InvoiceZone::NewRecord()"); - if (t->stock == nullptr) + if (t->stock == NULL) return 1; t->stock->NewInvoice(0); edit = 1; @@ -1909,7 +1910,7 @@ int InvoiceZone::NewRecord(Terminal *t) int InvoiceZone::KillRecord(Terminal *t, int record) { FnTrace("InvoiceZone::KillRecord()"); - if (t->stock == nullptr) + if (t->stock == NULL) return 1; return 1; } @@ -1923,11 +1924,11 @@ int InvoiceZone::Search(Terminal *t, int record, const genericChar* word) int InvoiceZone::ListReport(Terminal *t, Report *r) { FnTrace("InvoiceZone::ListReport()"); - if (r == nullptr) + if (r == NULL) return 1; Stock *s = t->stock; - if (s == nullptr || s->InvoiceList() == nullptr) + if (s == NULL || s->InvoiceList() == NULL) { r->TextC(t->Translate("No Invoices for this period")); return 0; @@ -1955,7 +1956,7 @@ int InvoiceZone::ListReport(Terminal *t, Report *r) int InvoiceZone::RecordCount(Terminal *t) { FnTrace("InvoiceZone::RecordCount()"); - if (t->stock == nullptr) + if (t->stock == NULL) return 0; return t->stock->InvoiceCount(); diff --git a/zone/inventory_zone.hh b/zone/inventory_zone.hh index 9ccab56a..28a00ae7 100644 --- a/zone/inventory_zone.hh +++ b/zone/inventory_zone.hh @@ -19,7 +19,7 @@ */ #ifndef _INVENTORY_ZONE_HH -#define INVENTORY_ZONE_HH +#define _INVENTORY_ZONE_HH #include "form_zone.hh" @@ -45,7 +45,7 @@ public: RC_Part(); // Destructor - ~RC_Part() override; + virtual ~RC_Part(); // Member Functions int Render(Terminal *t); @@ -63,20 +63,20 @@ public: ProductZone(); // Member Functions - int Type() override { return ZONE_INVENTORY; } - RenderResult Render(Terminal *t, int update_flag) override; - SignalResult Signal(Terminal *t, const genericChar* message) override; - SignalResult Mouse(Terminal *t, int action, int mx, int my) override; - Flt *Spacing() override { return &list_spacing; } - - int LoadRecord(Terminal *t, int record) override; - int SaveRecord(Terminal *t, int record, int write_file) override; - int UpdateForm(Terminal *t, int record) override; - int NewRecord(Terminal *t) override; - int KillRecord(Terminal *t, int record) override; - int Search(Terminal *t, int record, const genericChar* word) override; - int ListReport(Terminal *t, Report *r) override; - int RecordCount(Terminal *t) override; + int Type() { return ZONE_INVENTORY; } + RenderResult Render(Terminal *t, int update_flag); + SignalResult Signal(Terminal *t, const genericChar* message); + SignalResult Mouse(Terminal *t, int action, int mx, int my); + Flt *Spacing() { return &list_spacing; } + + int LoadRecord(Terminal *t, int record); + int SaveRecord(Terminal *t, int record, int write_file); + int UpdateForm(Terminal *t, int record); + int NewRecord(Terminal *t); + int KillRecord(Terminal *t, int record); + int Search(Terminal *t, int record, const genericChar* word); + int ListReport(Terminal *t, Report *r); + int RecordCount(Terminal *t); }; class RecipeZone : public ListFormZone @@ -91,18 +91,18 @@ public: RecipeZone(); // Member Functions - int Type() override { return ZONE_RECIPE; } - RenderResult Render(Terminal *t, int update_flag) override; - SignalResult Touch(Terminal *t, int tx, int ty) override; - Flt *Spacing() override { return &list_spacing; } - - int LoadRecord(Terminal *t, int record) override; - int SaveRecord(Terminal *t, int record, int write_file) override; - int NewRecord(Terminal *t) override; - int KillRecord(Terminal *t, int record) override; - int Search(Terminal *t, int record, const genericChar* word) override; - int ListReport(Terminal *t, Report *r) override; - int RecordCount(Terminal *t) override; + int Type() { return ZONE_RECIPE; } + RenderResult Render(Terminal *t, int update_flag); + SignalResult Touch(Terminal *t, int tx, int ty); + Flt *Spacing() { return &list_spacing; } + + int LoadRecord(Terminal *t, int record); + int SaveRecord(Terminal *t, int record, int write_file); + int NewRecord(Terminal *t); + int KillRecord(Terminal *t, int record); + int Search(Terminal *t, int record, const genericChar* word); + int ListReport(Terminal *t, Report *r); + int RecordCount(Terminal *t); int MakeRecipe(Terminal *t, Recipe *rc); int LayoutParts(); @@ -116,17 +116,17 @@ public: VendorZone(); // Member Functions - int Type() override { return ZONE_VENDOR; } - RenderResult Render(Terminal *t, int update_flag) override; - Flt *Spacing() override { return &list_spacing; } - - int LoadRecord(Terminal *t, int record) override; - int SaveRecord(Terminal *t, int record, int write_file) override; - int NewRecord(Terminal *t) override; - int KillRecord(Terminal *t, int record) override; - int Search(Terminal *t, int record, const genericChar* word) override; - int ListReport(Terminal *t, Report *r) override; - int RecordCount(Terminal *t) override; + int Type() { return ZONE_VENDOR; } + RenderResult Render(Terminal *t, int update_flag); + Flt *Spacing() { return &list_spacing; } + + int LoadRecord(Terminal *t, int record); + int SaveRecord(Terminal *t, int record, int write_file); + int NewRecord(Terminal *t); + int KillRecord(Terminal *t, int record); + int Search(Terminal *t, int record, const genericChar* word); + int ListReport(Terminal *t, Report *r); + int RecordCount(Terminal *t); }; class ItemListZone : public ListFormZone @@ -140,18 +140,18 @@ public: ItemListZone(); // Member Functions - int Type() override { return ZONE_ITEM_LIST; } + int Type() { return ZONE_ITEM_LIST; } int AddFields(); - RenderResult Render(Terminal *t, int update_flag) override; - SignalResult Signal(Terminal *t, const genericChar* message) override; - SignalResult Mouse(Terminal *t, int action, int mx, int my) override; - Flt *Spacing() override { return &list_spacing; } - - int LoadRecord(Terminal *t, int record) override; - int SaveRecord(Terminal *t, int record, int write_file) override; - int Search(Terminal *t, int record, const genericChar* word) override; - int ListReport(Terminal *t, Report *r) override; - int RecordCount(Terminal *t) override; + RenderResult Render(Terminal *t, int update_flag); + SignalResult Signal(Terminal *t, const genericChar* message); + SignalResult Mouse(Terminal *t, int action, int mx, int my); + Flt *Spacing() { return &list_spacing; } + + int LoadRecord(Terminal *t, int record); + int SaveRecord(Terminal *t, int record, int write_file); + int Search(Terminal *t, int record, const genericChar* word); + int ListReport(Terminal *t, Report *r); + int RecordCount(Terminal *t); // Helper functions for filtering int GetItemTypeColor(int item_type); @@ -169,23 +169,23 @@ public: // Constructor InvoiceZone(); // Destructor - ~InvoiceZone() override; + ~InvoiceZone(); // Member Functions - int Type() override { return ZONE_INVOICE; } - RenderResult Render(Terminal *t, int update_flag) override; - SignalResult Signal(Terminal *t, const genericChar* message) override; - SignalResult Touch(Terminal *t, int tx, int ty) override; - SignalResult Mouse(Terminal *t, int action, int mx, int my) override; - Flt *Spacing() override { return &list_spacing; } - - int LoadRecord(Terminal *t, int record) override; - int SaveRecord(Terminal *t, int record, int write_file) override; - int NewRecord(Terminal *t) override; - int KillRecord(Terminal *t, int record) override; - int Search(Terminal *t, int record, const genericChar* word) override; - int ListReport(Terminal *t, Report *r) override; - int RecordCount(Terminal *t) override; + int Type() { return ZONE_INVOICE; } + RenderResult Render(Terminal *t, int update_flag); + SignalResult Signal(Terminal *t, const genericChar* message); + SignalResult Touch(Terminal *t, int tx, int ty); + SignalResult Mouse(Terminal *t, int action, int mx, int my); + Flt *Spacing() { return &list_spacing; } + + int LoadRecord(Terminal *t, int record); + int SaveRecord(Terminal *t, int record, int write_file); + int NewRecord(Terminal *t); + int KillRecord(Terminal *t, int record); + int Search(Terminal *t, int record, const genericChar* word); + int ListReport(Terminal *t, Report *r); + int RecordCount(Terminal *t); }; #endif diff --git a/zone/labor_zone.cc b/zone/labor_zone.cc index a562c3a9..839c6378 100644 --- a/zone/labor_zone.cc +++ b/zone/labor_zone.cc @@ -42,9 +42,9 @@ extern int AdjustPeriod(TimeInfo &ref, int period, int adjust); // Constructor LaborZone::LaborZone() { - report = nullptr; - period = nullptr; - work = nullptr; + report = NULL; + period = NULL; + work = NULL; page = 0; day_view = 1; spacing = 1.0; @@ -59,7 +59,7 @@ LaborZone::LaborZone() AddButtonField(GlobalTranslate("Start Break"), "break"); Color(COLOR_DEFAULT); AddNewLine(); - AddListField(GlobalTranslate("Job"), nullptr); + AddListField(GlobalTranslate("Job"), NULL); AddTextField(GlobalTranslate("Pay"), 7); AddListField(GlobalTranslate("Rate"), PayRateName, PayRateValue); AddTextField(GlobalTranslate("Tips"), 7); @@ -78,18 +78,18 @@ RenderResult LaborZone::Render(Terminal *term, int update_flag) //printf("LaborZone::Render update_flag=%d; period=%d RENDER_NEW=%d\n",update_flag, period, RENDER_NEW); FnTrace("LaborZone::Render()"); System *sys = term->system_data; - if (update_flag || period == nullptr) + if (update_flag || period == NULL) { if (report) { delete report; - report = nullptr; + report = NULL; } - if (update_flag == RENDER_NEW || period == nullptr) + if (update_flag == RENDER_NEW || period == NULL) { ref = SystemTime; - work = nullptr; + work = NULL; page = 0; period = sys->labor_db.CurrentPeriod(); day_view = 1; @@ -118,7 +118,7 @@ RenderResult LaborZone::Render(Terminal *term, int update_flag) //printf("Render after settings:LaborPeriod: ref=%d/%d/%d : start=%d/%d/%d: end=%d/%d/%d : System=%d/%d/%d\n", ref.Month(), ref.Day(), ref.Year(), start.Month(), start.Day(), start.Year(), end.Month(), end.Day(), end.Year(), SystemTime.Month(), SystemTime.Day(), SystemTime.Year()); } - if (report == nullptr && period) + if (report == NULL && period) { report = new Report; report->SetTitle(GlobalTranslate("Time Clock Summary")); @@ -174,10 +174,10 @@ SignalResult LaborZone::Signal(Terminal *term, const genericChar* message) "clockout", "break", "undo edit", "change view", "next server", "prior server", "next", "prior", "change period", "day", "period", - "print", "localprint", "reportprint", nullptr}; + "print", "localprint", "reportprint", NULL}; Employee *employee = term->user; - if (employee == nullptr || period == nullptr) + if (employee == NULL || period == NULL) return SIGNAL_IGNORED; System *sys = term->system_data; @@ -221,19 +221,19 @@ SignalResult LaborZone::Signal(Terminal *term, const genericChar* message) break; case 3: // change view if (term->server) - term->server = nullptr; + term->server = NULL; else if (work) term->server = sys->user_db.FindByID(work->user_id); else term->server = sys->user_db.UserList(); - term->Update(UPDATE_SERVER, nullptr); + term->Update(UPDATE_SERVER, NULL); return SIGNAL_OKAY; case 4: // next server if (term->server) { if (work) { - work = nullptr; + work = NULL; LoadRecord(term, 0); } term->server = sys->user_db.NextUser(term, term->server); @@ -242,14 +242,14 @@ SignalResult LaborZone::Signal(Terminal *term, const genericChar* message) term->server = sys->user_db.FindByID(work->user_id); else term->server = sys->user_db.UserList(); - term->Update(UPDATE_SERVER, nullptr); + term->Update(UPDATE_SERVER, NULL); return SIGNAL_OKAY; case 5: // prior server if (term->server) { if (work) { - work = nullptr; + work = NULL; LoadRecord(term, 0); } term->server = sys->user_db.ForeUser(term, term->server); @@ -258,22 +258,22 @@ SignalResult LaborZone::Signal(Terminal *term, const genericChar* message) term->server = sys->user_db.FindByID(work->user_id); else term->server = sys->user_db.UserList(); - term->Update(UPDATE_SERVER, nullptr); + term->Update(UPDATE_SERVER, NULL); return SIGNAL_OKAY; case 6: // next //printf("\n\nlabor_zone -> next(): ref=%d/%d/%d : start=%d/%d/%d: end=%d/%d/%d : System=%d/%d/%d\n", ref.Month(), ref.Day(), ref.Year(), start.Month(), start.Day(), start.Year(), end.Month(), end.Day(), end.Year(), SystemTime.Month(), SystemTime.Day(), SystemTime.Year()); if (day_view) { - if (term->archive == nullptr) + if (term->archive == NULL) return SIGNAL_IGNORED; term->archive = term->archive->next; - term->Update(UPDATE_ARCHIVE, nullptr); + term->Update(UPDATE_ARCHIVE, NULL); } else { ref = end; //printf("labor_zone->next prior to AdjustPeriod ref=%d/%d/%d : start=%d/%d/%d: end=%d/%d/%d : System=%d/%d/%d\n", ref.Month(), ref.Day(), ref.Year(), start.Month(), start.Day(), start.Year(), end.Month(), end.Day(), end.Year(), SystemTime.Month(), SystemTime.Day(), SystemTime.Year()); AdjustPeriod(ref, s->labor_period, 1); //printf("AfterAdjustPeriod: ref=%d/%d/%d : start=%d/%d/%d: end=%d/%d/%d : System=%d/%d/%d\n", ref.Month(), ref.Day(), ref.Year(), start.Month(), start.Day(), start.Year(), end.Month(), end.Day(), end.Year(), SystemTime.Month(), SystemTime.Day(), SystemTime.Year()); - s->SetPeriod(ref, start, end, s->labor_period, nullptr); + s->SetPeriod(ref, start, end, s->labor_period, 0); //printf("AfterSetPeriod: ref=%d/%d/%d : start=%d/%d/%d: end=%d/%d/%d : System=%d/%d/%d\n", ref.Month(), ref.Day(), ref.Year(), start.Month(), start.Day(), start.Year(), end.Month(), end.Day(), end.Year(), SystemTime.Month(), SystemTime.Day(), SystemTime.Year()); Draw(term, 1); } @@ -283,19 +283,19 @@ SignalResult LaborZone::Signal(Terminal *term, const genericChar* message) //printf("\n\nlabor_zone -> prior(): ref=%d/%d/%d : start=%d/%d/%d: end=%d/%d/%d : System=%d/%d/%d\n", ref.Month(), ref.Day(), ref.Year(), start.Month(), start.Day(), start.Year(), end.Month(), end.Day(), end.Year(), SystemTime.Month(), SystemTime.Day(), SystemTime.Year()); if (day_view) { - if (term->archive == nullptr) + if (term->archive == NULL) term->archive = sys->ArchiveListEnd(); else if (term->archive->fore) term->archive = term->archive->fore; else return SIGNAL_IGNORED; - term->Update(UPDATE_ARCHIVE, nullptr); + term->Update(UPDATE_ARCHIVE, NULL); } else { ref = start; //printf("labor_zone->prior before Adjust ref=%d/%d/%d : start=%d/%d/%d: end=%d/%d/%d : System=%d/%d/%d\n", ref.Month(), ref.Day(), ref.Year(), start.Month(), start.Day(), start.Year(), end.Month(), end.Day(), end.Year(), SystemTime.Month(), SystemTime.Day(), SystemTime.Year()); AdjustPeriod(ref, s->labor_period, -1); //printf("labor_zone->prior after Adjust ref=%d/%d/%d : start=%d/%d/%d: end=%d/%d/%d : System=%d/%d/%d\n", ref.Month(), ref.Day(), ref.Year(), start.Month(), start.Day(), start.Year(), end.Month(), end.Day(), end.Year(), SystemTime.Month(), SystemTime.Day(), SystemTime.Year()); - s->SetPeriod(ref, start, end, s->labor_period, nullptr); + s->SetPeriod(ref, start, end, s->labor_period, 0); //printf("labor_zone->prior after SetPeriod ref=%d/%d/%d : start=%d/%d/%d: end=%d/%d/%d : System=%d/%d/%d\n", ref.Month(), ref.Day(), ref.Year(), start.Month(), start.Day(), start.Year(), end.Month(), end.Day(), end.Year(), SystemTime.Month(), SystemTime.Day(), SystemTime.Year()); Draw(term, 1); //printf("Drawing Term ref=%d/%d/%d : start=%d/%d/%d: end=%d/%d/%d : System=%d/%d/%d\n", ref.Month(), ref.Day(), ref.Year(), start.Month(), start.Day(), start.Year(), end.Month(), end.Day(), end.Year(), SystemTime.Month(), SystemTime.Day(), SystemTime.Year()); @@ -341,10 +341,10 @@ SignalResult LaborZone::Signal(Terminal *term, const genericChar* message) SignalResult LaborZone::Touch(Terminal *term, int tx, int ty) { FnTrace("LaborZone::Touch()"); - if (period == nullptr || report == nullptr) + if (period == NULL || report == NULL) return SIGNAL_IGNORED; - FormZone::Touch(term, tx, ty); + LayoutZone::Touch(term, tx, ty); int yy = report->TouchLine(spacing, selected_y); int max_page = report->max_pages; @@ -392,7 +392,7 @@ int LaborZone::Update(Terminal *term, int update_message, const genericChar* val { FnTrace("LaborZone::Update()"); Report *r = report; - if (r == nullptr || r->update_flag & update_message) + if (r == NULL || r->update_flag & update_message) return Draw(term, 1); // FIX - obsolete - replace with value in r->update_flag @@ -405,7 +405,7 @@ int LaborZone::LoadRecord(Terminal *term, int record) { FnTrace("LaborZone::LoadRecord()"); FormField *f = FieldList(); - if (work == nullptr) + if (work == NULL) { while (f) { @@ -437,7 +437,7 @@ int LaborZone::LoadRecord(Terminal *term, int record) Employee *employee = term->system_data->user_db.FindByID(work->user_id); if (employee) { - for (JobInfo *j = employee->JobList(); j != nullptr; j = j->next) + for (JobInfo *j = employee->JobList(); j != NULL; j = j->next) f->AddEntry(j->Title(term), j->job); } else @@ -463,7 +463,7 @@ int LaborZone::SaveRecord(Terminal *term, int record, int write_file) { FnTrace("LaborZone::SaveRecord()"); Employee *employee = term->user; - if (employee == nullptr) + if (employee == NULL) return 1; if (work) @@ -504,7 +504,7 @@ int LaborZone::UpdateForm(Terminal *term, int record) { FnTrace("LaborZone::UpdateForm()"); Employee *employee = term->user; - if (employee == nullptr || work == nullptr) + if (employee == NULL || work == NULL) return 1; TimeInfo work_start; @@ -521,7 +521,7 @@ int LaborZone::UpdateForm(Terminal *term, int record) if (report) { delete report; - report = nullptr; + report = NULL; } } return 0; @@ -534,12 +534,12 @@ int LaborZone::Print(Terminal *term, int print_mode) return 0; Employee *employee = term->user; - if (employee == nullptr || report == nullptr) + if (employee == NULL || report == NULL) return 1; Printer *p1 = term->FindPrinter(PRINTER_RECEIPT); Printer *p2 = term->FindPrinter(PRINTER_REPORT); - if (p1 == nullptr && p2 == nullptr) + if (p1 == NULL && p2 == NULL) return 1; if (print_mode == RP_ASK) @@ -551,9 +551,9 @@ int LaborZone::Print(Terminal *term, int print_mode) } Printer *printer = p1; - if ((print_mode == RP_PRINT_REPORT && p2) || p1 == nullptr) + if ((print_mode == RP_PRINT_REPORT && p2) || p1 == NULL) printer = p2; - if (printer == nullptr) + if (printer == NULL) return 1; report->CreateHeader(term, printer, employee); @@ -576,13 +576,13 @@ RenderResult ScheduleZone::Render(Terminal *term, int update_flag) FnTrace("ScheduleZone::Render()"); Employee *employee; - RenderZone(term, nullptr, update_flag); + RenderZone(term, NULL, update_flag); int users = 0; name_len = 0; System *sys = term->system_data; Settings *s = &(sys->settings); - for (employee = sys->user_db.UserList(); employee != nullptr; employee = employee->next) + for (employee = sys->user_db.UserList(); employee != NULL; employee = employee->next) { if (employee->active && employee->system_name.size() > name_len) { @@ -616,7 +616,7 @@ RenderResult ScheduleZone::Render(Terminal *term, int update_flag) } int no = 0; - for (employee = sys->user_db.UserList(); employee != nullptr; employee = employee->next) + for (employee = sys->user_db.UserList(); employee != NULL; employee = employee->next) { if (employee->active) { diff --git a/zone/labor_zone.hh b/zone/labor_zone.hh index 3d69903f..0edd31ba 100644 --- a/zone/labor_zone.hh +++ b/zone/labor_zone.hh @@ -19,7 +19,7 @@ */ #ifndef _LABOR_ZONE_HH -#define LABOR_ZONE_HH +#define _LABOR_ZONE_HH #include "form_zone.hh" @@ -47,18 +47,18 @@ public: // Constructor LaborZone(); // Destructor - ~LaborZone() override; + ~LaborZone(); // Member Functions - int Type() override { return ZONE_LABOR; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - int Update(Terminal *term, int update_message, const genericChar* value) override; - int LoadRecord(Terminal *term, int record) override; - int SaveRecord(Terminal *term, int record, int write_file) override; - int UpdateForm(Terminal *term, int record) override; - Flt *Spacing() override { return &spacing; } + int Type() { return ZONE_LABOR; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Signal(Terminal *term, const genericChar* message); + SignalResult Touch(Terminal *term, int tx, int ty); + int Update(Terminal *term, int update_message, const genericChar* value); + int LoadRecord(Terminal *term, int record); + int SaveRecord(Terminal *term, int record, int write_file); + int UpdateForm(Terminal *term, int record); + Flt *Spacing() { return &spacing; } int Print(Terminal *term, int mode); }; @@ -73,12 +73,12 @@ public: ScheduleZone(); // Member Functions - int Type() override { return ZONE_SCHEDULE; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - SignalResult Mouse(Terminal *term, int action, int mx, int my) override; - int ZoneStates() override { return 1; } + int Type() { return ZONE_SCHEDULE; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Signal(Terminal *term, const genericChar* message); + SignalResult Touch(Terminal *term, int tx, int ty); + SignalResult Mouse(Terminal *term, int action, int mx, int my); + int ZoneStates() { return 1; } }; #endif diff --git a/zone/layout_zone.cc b/zone/layout_zone.cc index 2ab65ae9..a2b5c53f 100644 --- a/zone/layout_zone.cc +++ b/zone/layout_zone.cc @@ -50,7 +50,7 @@ LayoutZone::LayoutZone() RenderResult LayoutZone::Render(Terminal *term, int update_flag) { FnTrace("LayoutZone::Render()"); - RenderZone(term, nullptr, update_flag); + RenderZone(term, NULL, update_flag); term->FontSize(font, font_width, font_height); int lw = w - (border * 2) - left_margin - right_margin; @@ -94,7 +94,7 @@ int LayoutZone::SetSize(Terminal *t, int width, int height) Flt LayoutZone::TextWidth(Terminal *t, const genericChar* str, int len) { - if (str == nullptr) + if (str == NULL) return 0.0; if (len <= 0) @@ -117,7 +117,7 @@ int LayoutZone::SetMargins(int left, int right) int LayoutZone::TextL(Terminal *t, Flt line, const genericChar* text, int my_color, int mode) { FnTrace("LayoutZone::TextL()"); - if (line < 0.0 || line >= size_y || text == nullptr) + if (line < 0.0 || line >= size_y || text == NULL) return 1; // Can't draw text if (my_color == COLOR_DEFAULT) @@ -133,7 +133,7 @@ int LayoutZone::TextL(Terminal *t, Flt line, const genericChar* text, int my_col int LayoutZone::TextC(Terminal *t, Flt line, const genericChar* text, int my_color, int mode) { FnTrace("LayoutZone::TextC()"); - if (line < 0.0 || line >= size_y || text == nullptr) + if (line < 0.0 || line >= size_y || text == NULL) return 1; // Can't draw text if (my_color == COLOR_DEFAULT) @@ -149,7 +149,7 @@ int LayoutZone::TextC(Terminal *t, Flt line, const genericChar* text, int my_col int LayoutZone::TextR(Terminal *t, Flt line, const genericChar* text, int my_color, int mode) { FnTrace("LayoutZone::TextR()"); - if (line < 0.0 || line >= size_y || text == nullptr) + if (line < 0.0 || line >= size_y || text == NULL) return 1; // Can't draw text if (my_color == COLOR_DEFAULT) @@ -172,7 +172,7 @@ int LayoutZone::TextPosL(Terminal *t, Flt row, Flt line, const genericChar* text int my_color, int mode) { FnTrace("LayoutZone::TextPosL()"); - if (line < 0.0 || line >= size_y || text == nullptr) + if (line < 0.0 || line >= size_y || text == NULL) return 1; // Can't draw text if (my_color == COLOR_DEFAULT) @@ -193,7 +193,7 @@ int LayoutZone::TextPosC(Terminal *t, Flt row, Flt line, const genericChar* text int my_color, int mode) { FnTrace("LayoutZone::TextPosC()"); - if (line < 0.0 || line >= size_y || text == nullptr) + if (line < 0.0 || line >= size_y || text == NULL) return 1; if (my_color == COLOR_DEFAULT) @@ -210,7 +210,7 @@ int LayoutZone::TextPosR(Terminal *t, Flt row, Flt line, const genericChar* text int my_color, int mode) { FnTrace("LayoutZone::TextPosR()"); - if (line < 0.0 || line >= size_y || text == nullptr) + if (line < 0.0 || line >= size_y || text == NULL) return 1; if (my_color == COLOR_DEFAULT) @@ -332,7 +332,7 @@ int LayoutZone::Entry(Terminal *t, Flt px, Flt py, Flt len, RegionInfo *place) t->RenderFilledFrame(sx, sy, sw, sh, 2, ft, FRAME_INSET | FRAME_2COLOR); - if (place != nullptr) + if (place != NULL) { place->x = sx; place->y = sy; diff --git a/zone/layout_zone.hh b/zone/layout_zone.hh index a830d3b6..30dbe0cd 100644 --- a/zone/layout_zone.hh +++ b/zone/layout_zone.hh @@ -18,8 +18,8 @@ * base class zone object for display layout */ -#ifndef LAYOUT_ZONE_HH -#define LAYOUT_ZONE_HH +#ifndef _LAYOUT_ZONE_HH +#define _LAYOUT_ZONE_HH #include "pos_zone.hh" #include "terminal.hh" @@ -47,10 +47,10 @@ public: LayoutZone(); // Member Functions - RenderResult Render(Terminal *t, int update_flag) override; - SignalResult Touch(Terminal *t, int tx, int ty) override; - int SetSize(Terminal *t, int width, int height) override; - int ZoneStates() override { return 1; } + virtual RenderResult Render(Terminal *t, int update_flag); + virtual SignalResult Touch(Terminal *t, int tx, int ty); + virtual int SetSize(Terminal *t, int width, int height); + virtual int ZoneStates() { return 1; } Flt TextWidth(Terminal *t, const genericChar* str, int len = 0); int SetMargins(int left, int right); @@ -75,7 +75,7 @@ public: int LinePos(Terminal *t, Flt row, Flt line, Flt len, int color = COLOR_DEFAULT); - int Entry(Terminal *t, Flt px, Flt py, Flt len, RegionInfo *place = nullptr); + int Entry(Terminal *t, Flt px, Flt py, Flt len, RegionInfo *place = NULL); int Button(Terminal *t, Flt px, Flt py, Flt len, int lit = 0); int Background(Terminal *t, Flt line, Flt h, int texture); int Raised(Terminal *t, Flt line, Flt h); diff --git a/zone/login_zone.cc b/zone/login_zone.cc index d81dbf00..60dd3d29 100644 --- a/zone/login_zone.cc +++ b/zone/login_zone.cc @@ -108,7 +108,7 @@ RenderResult LoginZone::Render(Terminal *term, int update_flag) Settings *settings = term->GetSettings(); Employee *employee = term->user; - if (employee == nullptr && state == STATE_USER_ONLINE) + if (employee == NULL && state == STATE_USER_ONLINE) state = STATE_GET_USER_ID; //this switch statement assigns the message in the upper @@ -210,7 +210,7 @@ SignalResult LoginZone::Signal(Terminal *term, const genericChar* message) "job0", "job1", "job2", "passwordgood", "passwordfailed", "passwordcancel", "faststart", "starttakeout", "gettextcancel", "pickup", "quicktogo", "quickdinein", - "kds1", "kds2", "bar1", "bar2", nullptr}; + "kds1", "kds2", "bar1", "bar2", NULL}; int idx = CompareList(message, commands); if (idx < 0) @@ -233,7 +233,7 @@ SignalResult LoginZone::Signal(Terminal *term, const genericChar* message) { case 10: // start Start(term); - if (term->user == nullptr) + if (term->user == NULL) return SIGNAL_ERROR; break; case 11: // clear @@ -339,16 +339,19 @@ SignalResult LoginZone::Keyboard(Terminal *term, int my_key, int key_state) genericChar str[] = {(char) my_key, '\0'}; return Signal(term, str); } - - const char *cmd = nullptr; - if (my_key == 8) - cmd = "backspace"; + else if (my_key == 8) + { + return Signal(term, "backspace"); + } else if (my_key == 13) - cmd = "start"; // handle ENTER key as 'normal' start + { + //handle the ENTER key as 'normal' start + return Signal(term, "start"); + } else + { return SIGNAL_IGNORED; - - return Signal(term, cmd); + } } int LoginZone::Update(Terminal *term, int update_message, const genericChar* value) @@ -371,10 +374,10 @@ int LoginZone::ClockOn(Terminal *term, int job_no) Employee *employee = term->user; Settings *settings = &(sys->settings); - if (employee == nullptr) + if (employee == NULL) employee = sys->user_db.FindByKey(input); - if (employee == nullptr) + if (employee == NULL) { state = STATE_UNKNOWN_USER; Draw(term, 0); @@ -404,7 +407,7 @@ int LoginZone::ClockOn(Terminal *term, int job_no) if (job_no >= 0) { JobInfo *j = employee->FindJobByNumber(job_no); - if (j == nullptr) + if (j == NULL) { printf("error finding job!\n"); return 1; // shouldn't happen @@ -435,7 +438,7 @@ int LoginZone::ClockOn(Terminal *term, int job_no) SimpleDialog *d = new SimpleDialog(str); int n = 0; - for (JobInfo *j = employee->JobList(); j != nullptr; j = j->next) + for (JobInfo *j = employee->JobList(); j != NULL; j = j->next) { snprintf(str, sizeof(str), "job%d", n++); d->Button(j->Title(term), str); @@ -474,7 +477,7 @@ int LoginZone::ClockOff(Terminal *term) FnTrace("LoginZone::ClockOff()"); System *sys = term->system_data; Employee *employee = term->user; - if (employee == nullptr) + if (employee == NULL) { employee = sys->user_db.FindByKey(input); input = 0; @@ -514,7 +517,7 @@ int LoginZone::Start(Terminal *term, short expedite) // the 'expedite' param is the flag to invoke fast food mode System *sys = term->system_data; Settings *settings = &(sys->settings); - Employee *employee = nullptr; + Employee *employee = NULL; //establish the current meal period and use that info //to determine which meal index page to load @@ -549,7 +552,7 @@ int LoginZone::Start(Terminal *term, short expedite) return 0; } - if (employee == nullptr) + if (employee == NULL) { // no user found for given key state = STATE_UNKNOWN_USER; @@ -739,7 +742,7 @@ int LoginZone::Start(Terminal *term, short expedite) LogoutZone::LogoutZone() { - work = nullptr; + work = NULL; } RenderResult LogoutZone::Render(Terminal *term, int update_flag) @@ -747,7 +750,7 @@ RenderResult LogoutZone::Render(Terminal *term, int update_flag) FnTrace("LogoutZone::Render()"); LayoutZone::Render(term, update_flag); Employee *employee = term->user; - if (employee == nullptr) + if (employee == NULL) { TextC(term, 1, term->Translate("No Employee Logged In")); return RENDER_OKAY; @@ -761,7 +764,7 @@ RenderResult LogoutZone::Render(Terminal *term, int update_flag) work = sys->labor_db.CurrentWorkEntry(employee); } - if (work == nullptr) + if (work == NULL) { TextC(term, 1, term->Translate("Strange, No Work Info For You...")); return RENDER_OKAY; @@ -820,7 +823,7 @@ SignalResult LogoutZone::Signal(Terminal *term, const genericChar* message) FnTrace("LogoutZone::Signal()"); static const genericChar* commands[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "00", - "cancel", "clockoff", "backspace", "clear", "save", "break", nullptr}; + "cancel", "clockoff", "backspace", "clear", "save", "break", NULL}; int idx = CompareList(message, commands); if (idx < 0) @@ -834,7 +837,7 @@ SignalResult LogoutZone::Signal(Terminal *term, const genericChar* message) } Employee *employee = term->user; - if (employee == nullptr || work == nullptr) + if (employee == NULL || work == NULL) return SIGNAL_IGNORED; System *sys = term->system_data; @@ -907,22 +910,18 @@ SignalResult LogoutZone::Keyboard(Terminal *term, int my_key, int state) genericChar str[] = {(char) my_key, '\0'}; return Signal(term, str); } - - const char *cmd = nullptr; - if (my_key == 8) - cmd = "backspace"; + else if (my_key == 8) + return Signal(term, "backspace"); else if (my_key == 27) - cmd = "cancel"; + return Signal(term, "cancel"); else return SIGNAL_IGNORED; - - return Signal(term, cmd); } int LogoutZone::RenderPaymentEntry(Terminal *term, int line) { FnTrace("LogoutZone::RenderPaymentEntry()"); - if (work == nullptr) + if (work == NULL) return 1; genericChar str[128]; @@ -952,7 +951,7 @@ int LogoutZone::ClockOff(Terminal *term, int end_shift) { FnTrace("LogoutZone::ClockOff()"); Employee *e = term->user; - if (e == nullptr || work == nullptr) + if (e == NULL || work == NULL) return 1; System *sys = term->system_data; diff --git a/zone/login_zone.hh b/zone/login_zone.hh index c6e762ed..8230107d 100644 --- a/zone/login_zone.hh +++ b/zone/login_zone.hh @@ -19,7 +19,7 @@ */ #ifndef _LOGIN_ZONE_HH -#define LOGIN_ZONE_HH +#define _LOGIN_ZONE_HH #include "layout_zone.hh" @@ -38,11 +38,11 @@ public: LoginZone(); // Member Functions - int Type() override { return ZONE_LOGIN; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Keyboard(Terminal *term, int key, int state) override; - int Update(Terminal *term, int update_message, const genericChar* value) override; + int Type() { return ZONE_LOGIN; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Signal(Terminal *term, const genericChar* message); + SignalResult Keyboard(Terminal *term, int key, int state); + int Update(Terminal *term, int update_message, const genericChar* value); int ClockOn(Terminal *term, int job = -1); int ClockOff(Terminal *term); @@ -60,10 +60,10 @@ public: LogoutZone(); // Member Functions - int Type() override { return ZONE_LOGOUT; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Keyboard(Terminal *term, int key, int state) override; + int Type() { return ZONE_LOGOUT; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Signal(Terminal *term, const genericChar* message); + SignalResult Keyboard(Terminal *term, int key, int state); int RenderPaymentEntry(Terminal *term, int line); int DrawPaymentEntry(Terminal *term, int line); diff --git a/zone/merchant_zone.cc b/zone/merchant_zone.cc index 3b0c6592..95fb0ef7 100644 --- a/zone/merchant_zone.cc +++ b/zone/merchant_zone.cc @@ -30,12 +30,12 @@ /**** Module Data ****/ static const genericChar* TimeZoneName[] = { - "Eastern", "Central", "Mountain", "Pacific", nullptr}; + "Eastern", "Central", "Mountain", "Pacific", NULL}; static int TimeZoneValue[] = { 705, 706, 707, 708, -1}; static const genericChar* LanguageName[] = { - "U.S. English", "Spanish", "Portuguese", nullptr}; + "U.S. English", "Spanish", "Portuguese", NULL}; static int LanguageValue[] = { 0, 1, 2, -1}; diff --git a/zone/merchant_zone.hh b/zone/merchant_zone.hh index b607089c..51dbd6bb 100644 --- a/zone/merchant_zone.hh +++ b/zone/merchant_zone.hh @@ -19,7 +19,7 @@ */ #ifndef _MERCHANT_ZONE_HH -#define MERCHANT_ZONE_HH +#define _MERCHANT_ZONE_HH #include "form_zone.hh" @@ -32,12 +32,12 @@ public: MerchantZone(); // Member Functions - int Type() override { return ZONE_MERCHANT; } - RenderResult Render(Terminal *t, int update_flag) override; - Flt *Spacing() override { return &form_spacing; } + int Type() { return ZONE_MERCHANT; } + RenderResult Render(Terminal *t, int update_flag); + Flt *Spacing() { return &form_spacing; } - int LoadRecord(Terminal *t, int record_no) override; - int SaveRecord(Terminal *t, int record_no, int write_file) override; + int LoadRecord(Terminal *t, int record_no); + int SaveRecord(Terminal *t, int record_no, int write_file); }; #endif diff --git a/zone/order_zone.cc b/zone/order_zone.cc index 0223a3cc..d3f974c6 100644 --- a/zone/order_zone.cc +++ b/zone/order_zone.cc @@ -77,7 +77,7 @@ int OrderEntryZone::RenderInit(Terminal *term, int /*update_flag*/) } Check *thisCheck = term->check; - if (thisCheck == nullptr || orders_per_page <= 0) + if (thisCheck == NULL || orders_per_page <= 0) return 0; // Error int use_seats = currSettings->use_seats; @@ -85,16 +85,16 @@ int OrderEntryZone::RenderInit(Terminal *term, int /*update_flag*/) use_seats = 0; SubCheck *thisSubCheck = thisCheck->current_sub; - if (thisSubCheck == nullptr) + if (thisSubCheck == NULL) { - term->order = nullptr; + term->order = NULL; term->seat = 0; if (use_seats) thisSubCheck = thisCheck->FirstOpenSubCheck(0); else thisSubCheck = thisCheck->FirstOpenSubCheck(); - if (thisSubCheck == nullptr) + if (thisSubCheck == NULL) return 0; } @@ -113,7 +113,7 @@ int OrderEntryZone::RenderInit(Terminal *term, int /*update_flag*/) int offset = orders_per_page * page_no; shown_count = 0; - for (Order *o = thisSubCheck->OrderList(); o != nullptr; o = o->next) + for (Order *o = thisSubCheck->OrderList(); o != NULL; o = o->next) { if (use_seats == 0 || o->seat == term->seat) { @@ -122,7 +122,7 @@ int OrderEntryZone::RenderInit(Terminal *term, int /*update_flag*/) else if (shown_count < orders_per_page) orders_shown[shown_count++] = o; - for (Order *mod = o->modifier_list; mod != nullptr; mod = mod->next) + for (Order *mod = o->modifier_list; mod != NULL; mod = mod->next) { if (offset > 0) --offset; @@ -133,7 +133,7 @@ int OrderEntryZone::RenderInit(Terminal *term, int /*update_flag*/) } // Select Last Order (no modifier) if no orders are already selected - if (term->order == nullptr && thisCheck->current_sub) + if (term->order == NULL && thisCheck->current_sub) term->order = thisCheck->current_sub->LastParentOrder(term->seat); return 0; @@ -144,7 +144,7 @@ RenderResult OrderEntryZone::Render(Terminal *t, int update_flag) FnTrace("OrderEntryZone::Render()"); LayoutZone::Render(t, update_flag); Check *c = t->check; - if (c == nullptr) + if (c == NULL) return RENDER_OKAY; // See if list size has changed @@ -161,7 +161,7 @@ RenderResult OrderEntryZone::Render(Terminal *t, int update_flag) } SubCheck *sc = c->current_sub; - if (sc == nullptr) + if (sc == NULL) return RENDER_OKAY; genericChar str[256]; @@ -186,7 +186,7 @@ RenderResult OrderEntryZone::Render(Terminal *t, int update_flag) if (use_seats) { vt_safe_string::safe_format(str, 256, "%s %s", t->Translate("Seat"), - SeatName(t->seat, nullptr, c->Guests())); + SeatName(t->seat, NULL, c->Guests())); TextC(t, 1, str, col); } else if (subs > 1) @@ -369,14 +369,14 @@ SignalResult OrderEntryZone::Signal(Terminal *term, const genericChar* message) static const genericChar* commands[] = { "cancel", "delete", "consolidate", "final", "next check", "prior check", "next seat", "prior seat", - "takeoutseat", "takeoutattach", nullptr}; + "takeoutseat", "takeoutattach", NULL}; Check *currCheck = term->check; - if (currCheck == nullptr) + if (currCheck == NULL) return SIGNAL_IGNORED; SubCheck *subcheck = currCheck->current_sub; - if (subcheck == nullptr) + if (subcheck == NULL) return SIGNAL_IGNORED; Settings *settings = term->GetSettings(); @@ -396,8 +396,8 @@ SignalResult OrderEntryZone::Signal(Terminal *term, const genericChar* message) case 2: // Consolidate ClearQualifier(term); subcheck->ConsolidateOrders(); - term->order = nullptr; - term->Update(UPDATE_ORDERS, nullptr); + term->order = NULL; + term->Update(UPDATE_ORDERS, NULL); break; case 3: // Final @@ -463,7 +463,7 @@ SignalResult OrderEntryZone::Signal(Terminal *term, const genericChar* message) count = 1; term->order->count = static_cast(count); subcheck->FigureTotals(settings); - term->Update(UPDATE_ORDERS, nullptr); + term->Update(UPDATE_ORDERS, NULL); return SIGNAL_OKAY; } @@ -504,7 +504,7 @@ SignalResult OrderEntryZone::Keyboard(Terminal *t, int my_key, int /*state*/) SignalResult OrderEntryZone::Touch(Terminal *t, int tx, int ty) { FnTrace("OrderEntryZone::Touch()"); - if (t->check == nullptr) + if (t->check == NULL) return SIGNAL_IGNORED; LayoutZone::Touch(t, tx, ty); @@ -531,7 +531,7 @@ SignalResult OrderEntryZone::Touch(Terminal *t, int tx, int ty) if (t->order != orders_shown[line]) { t->order = orders_shown[line]; - t->Update(UPDATE_ORDERS, nullptr); + t->Update(UPDATE_ORDERS, NULL); return SIGNAL_OKAY; } return SIGNAL_IGNORED; @@ -605,7 +605,7 @@ int OrderEntryZone::CancelOrders(Terminal *t) { FnTrace("OrderEntryZone::CancelOrders()"); Check *c = t->check; - if (c == nullptr) + if (c == NULL) return 1; // Error -- No current check Settings *s = t->GetSettings(); @@ -613,9 +613,9 @@ int OrderEntryZone::CancelOrders(Terminal *t) t->qualifier = QUALIFIER_NONE; c->CancelOrders(s); - t->order = nullptr; - t->Update(UPDATE_ORDERS, nullptr); - t->UpdateOtherTerms(UPDATE_CHECKS, nullptr); + t->order = NULL; + t->Update(UPDATE_ORDERS, NULL); + t->UpdateOtherTerms(UPDATE_CHECKS, NULL); // For SelfOrder terminals, navigate back to appropriate starting page after canceling // Only Customer user should go to page -2, regular employees go to page -1 @@ -623,7 +623,7 @@ int OrderEntryZone::CancelOrders(Terminal *t) { // For Customer user, destroy the check completely to prevent it from staying open // Regular employees keep their checks for later modification - if (t->user != nullptr && t->user->system_name.Value() != nullptr && + if (t->user != NULL && t->user->system_name.Value() != NULL && strcmp(t->user->system_name.Value(), "Customer") == 0) { // Customer canceled - destroy the check completely @@ -635,8 +635,8 @@ int OrderEntryZone::CancelOrders(Terminal *t) } // Clear the check reference and go back to appropriate starting page - t->check = nullptr; - t->order = nullptr; + t->check = NULL; + t->order = NULL; t->seat = 0; t->guests = 0; @@ -653,11 +653,11 @@ int OrderEntryZone::AddQualifier(Terminal *t, int qualifier_type) { FnTrace("OrderEntryZone::AddQualifier()"); Check *c = t->check; - if (c == nullptr) + if (c == NULL) return 1; SubCheck *sc = c->current_sub; - if (sc == nullptr || sc->status != CHECK_OPEN) + if (sc == NULL || sc->status != CHECK_OPEN) return 1; MergeQualifier(t->qualifier, qualifier_type); @@ -671,11 +671,11 @@ int OrderEntryZone::DeleteOrder(Terminal *term, int is_void) FnTrace("OrderEntryZone::DeleteOrder()"); Check *thisCheck = term->check; - if (thisCheck == nullptr || term->order == nullptr) + if (thisCheck == NULL || term->order == NULL) return 1; SubCheck *sc = thisCheck->current_sub; - if (sc == nullptr) + if (sc == NULL) return 1; int jump = 0; @@ -717,7 +717,7 @@ int OrderEntryZone::DeleteOrder(Terminal *term, int is_void) fprintf(stderr, "ERROR: Modifier deletion safety limit reached (%d), possible infinite loop prevented\n", MAX_MODIFIERS); } - term->Update(UPDATE_ORDERS, nullptr); + term->Update(UPDATE_ORDERS, NULL); term->RunScript(term->order->script.Value(), JUMP_NONE, 0); } else @@ -738,7 +738,7 @@ int OrderEntryZone::DeleteOrder(Terminal *term, int is_void) if (term->order->next && term->order->next->seat == term->order->seat) term->order = term->order->next; else - term->order = nullptr; // next order isn'term on same seat + term->order = NULL; // next order isn'term on same seat } sc->Remove(o); delete o; @@ -748,7 +748,7 @@ int OrderEntryZone::DeleteOrder(Terminal *term, int is_void) if (jump && jump != term->page->id) term->Jump(JUMP_NORMAL, jump); else - term->Update(UPDATE_ORDERS, nullptr); + term->Update(UPDATE_ORDERS, NULL); return 0; } @@ -760,11 +760,11 @@ int OrderEntryZone::CompOrder(Terminal *term, int reason) Employee *employee = term->user; Settings *currSettings = term->GetSettings(); - if (thisCheck == nullptr || employee == nullptr || !employee->CanCompOrder(currSettings)) + if (thisCheck == NULL || employee == NULL || !employee->CanCompOrder(currSettings)) return 1; SubCheck *thisSubCheck = thisCheck->current_sub; - if (thisSubCheck == nullptr) + if (thisSubCheck == NULL) return 1; if (reason < 0) @@ -792,7 +792,7 @@ int OrderEntryZone::CompOrder(Terminal *term, int reason) // Does its current location cause unintended duplication? thisSubCheck->CompOrder(currSettings, term->order, 1); - term->Update(UPDATE_ORDERS, nullptr); + term->Update(UPDATE_ORDERS, NULL); return 0; } @@ -803,7 +803,7 @@ int OrderEntryZone::VoidOrder(Terminal *term, int reason) Employee *employee = term->user; Settings *currSettings = term->GetSettings(); - if (thisCheck == nullptr || employee == nullptr || !employee->CanCompOrder(currSettings)) + if (thisCheck == NULL || employee == NULL || !employee->CanCompOrder(currSettings)) return 1; if (reason < 0) @@ -836,16 +836,16 @@ int OrderEntryZone::NextCheck(Terminal *t) { FnTrace("OrderEntryZone::NextCheck()"); Check *c = t->check; - if (c == nullptr) + if (c == NULL) return 1; SubCheck *sc = c->current_sub; - if (sc == nullptr) + if (sc == NULL) return 1; if (sc->next) c->current_sub = sc->next; - else if (sc->OrderList() == nullptr || c->GetStatus() != CHECK_OPEN) + else if (sc->OrderList() == NULL || c->GetStatus() != CHECK_OPEN) { c->Update(t->GetSettings()); c->current_sub = c->SubList(); @@ -857,7 +857,7 @@ int OrderEntryZone::NextCheck(Terminal *t) // Select Last Order (no modifier) t->order = c->current_sub->LastParentOrder(t->seat); - t->Update(UPDATE_ORDERS, nullptr); + t->Update(UPDATE_ORDERS, NULL); return 0; } @@ -865,11 +865,11 @@ int OrderEntryZone::PriorCheck(Terminal *t) { FnTrace("OrderEntryZone::PriorCheck()"); Check *c = t->check; - if (c == nullptr) + if (c == NULL) return 1; SubCheck *sc = c->current_sub; - if (sc == nullptr) + if (sc == NULL) return 1; if (sc->fore) @@ -886,7 +886,7 @@ int OrderEntryZone::PriorCheck(Terminal *t) // Select Last Order (no modifier) t->order = c->current_sub->LastParentOrder(t->seat); - t->Update(UPDATE_ORDERS, nullptr); + t->Update(UPDATE_ORDERS, NULL); return 0; } @@ -895,11 +895,11 @@ int OrderEntryZone::ShowSeat(Terminal *t, int seat) FnTrace("OrderEntryZone::ShowSeat()"); Settings *s = t->GetSettings(); Check *c = t->check; - if (c == nullptr || !s->use_seats) + if (c == NULL || !s->use_seats) return 1; SubCheck *sc = c->current_sub; - if (sc == nullptr) + if (sc == NULL) return 1; int guests = c->Guests(); @@ -919,11 +919,11 @@ int OrderEntryZone::ShowSeat(Terminal *t, int seat) sc->ConsolidateOrders(); sc = c->FirstOpenSubCheck(t->seat); - if (sc == nullptr) + if (sc == NULL) return 1; - t->order = nullptr; - t->Update(UPDATE_ORDERS, nullptr); + t->order = NULL; + t->Update(UPDATE_ORDERS, NULL); // Removed SunWest-specific code - no longer needed return 0; @@ -963,11 +963,11 @@ int OrderEntryZone::ClearQualifier(Terminal *t) { FnTrace("OrderEntryZone::ClearQualifier()"); Check *c = t->check; - if (c == nullptr) + if (c == NULL) return 1; SubCheck *sc = c->current_sub; - if (sc == nullptr) + if (sc == NULL) return 1; // attach "on the side" qualifier to the order item if needed @@ -1030,7 +1030,7 @@ SignalResult OrderPageZone::Touch(Terminal *t, int /*tx*/, int /*ty*/) Settings *s = t->GetSettings(); Check *c = t->check; - if (s->use_seats && (c == nullptr || c->CustomerType() == CHECK_RESTAURANT)) + if (s->use_seats && (c == NULL || c->CustomerType() == CHECK_RESTAURANT)) { if (amount > 0) return t->Signal("next seat", group_id); @@ -1050,7 +1050,7 @@ const char* OrderPageZone::TranslateString(Terminal *t) Check *c = t->check; static genericChar str[256]; - if (s->use_seats && (c == nullptr || c->CustomerType() == CHECK_RESTAURANT)) + if (s->use_seats && (c == NULL || c->CustomerType() == CHECK_RESTAURANT)) { if (amount > 0) vt_safe_string::safe_copy(str, 256, GlobalTranslate("Next\\Seat")); @@ -1084,12 +1084,12 @@ int OrderFlowZone::RenderInit(Terminal *t, int /*update_flag*/) // SelfOrder terminals don't require user authentication if (t->type == TERMINAL_SELFORDER) { - active = !(c == nullptr || (t->guests <= 0 && !( c->IsTakeOut() || c->IsFastFood() || c->IsSelfOrder()))); + active = !(c == NULL || (t->guests <= 0 && !( c->IsTakeOut() || c->IsFastFood() || c->IsSelfOrder()))); } else { - active = !(c == nullptr || (t->guests <= 0 && !( c->IsTakeOut() || c->IsFastFood())) || - e == nullptr || !e->CanOrder(s) || + active = !(c == NULL || (t->guests <= 0 && !( c->IsTakeOut() || c->IsFastFood())) || + e == NULL || !e->CanOrder(s) || (!e->IsSupervisor(s) && c->user_owner != e->id)); } } @@ -1174,7 +1174,7 @@ SignalResult OrderFlowZone::Touch(Terminal *t, int /*tx*/, int /*ty*/) { FnTrace("OrderFlowZone::Touch()"); Check *c = t->check; - if (c == nullptr) + if (c == NULL) return SIGNAL_IGNORED; int error = 1; @@ -1254,10 +1254,10 @@ int OrderAddZone::RenderInit(Terminal *t, int /*update_flag*/) return 0; } - if (o == nullptr && thisCheck->current_sub) + if (o == NULL && thisCheck->current_sub) o = thisCheck->current_sub->LastParentOrder(t->seat); - if (o == nullptr) + if (o == NULL) mode = 0; else if (o->allow_increase == 0) mode = 0; @@ -1300,16 +1300,16 @@ SignalResult OrderAddZone::Touch(Terminal *term, int /*tx*/, int /*ty*/) { FnTrace("OrderAddZone::Touch()"); Check *c = term->check; - if (c == nullptr || term->order == nullptr) + if (c == NULL || term->order == NULL) return SIGNAL_IGNORED; SubCheck *sc = c->current_sub; - if (sc == nullptr || sc->status != CHECK_OPEN) + if (sc == NULL || sc->status != CHECK_OPEN) return SIGNAL_IGNORED; Order *order = term->order; Settings *s = term->GetSettings(); - if (order == nullptr) + if (order == NULL) { return SIGNAL_IGNORED; } @@ -1355,7 +1355,7 @@ SignalResult OrderAddZone::Touch(Terminal *term, int /*tx*/, int /*ty*/) mod = mod->next; } sc->Add(thisOrder); - term->order = nullptr; + term->order = NULL; } else { @@ -1378,7 +1378,7 @@ SignalResult OrderAddZone::Touch(Terminal *term, int /*tx*/, int /*ty*/) sc->FigureTotals(s); } - term->Update(UPDATE_ORDERS, nullptr); + term->Update(UPDATE_ORDERS, NULL); return SIGNAL_OKAY; } @@ -1418,10 +1418,10 @@ int OrderDeleteZone::RenderInit(Terminal *t, int update_flag) return 0; } - if (o == nullptr && thisCheck->current_sub) + if (o == NULL && thisCheck->current_sub) o = thisCheck->current_sub->LastParentOrder(t->seat); - if (o == nullptr) + if (o == NULL) mode = 0; else if (o->status & ORDER_FINAL) { @@ -1466,11 +1466,11 @@ SignalResult OrderDeleteZone::Touch(Terminal *term, int tx, int ty) Check *thisCheck = term->check; Employee *thisEmployee = term->user; - if (thisCheck == nullptr || thisEmployee == nullptr || term->order == nullptr) + if (thisCheck == NULL || thisEmployee == NULL || term->order == NULL) return SIGNAL_IGNORED; SubCheck *sc = thisCheck->current_sub; - if (sc == nullptr || sc->status != CHECK_OPEN) + if (sc == NULL || sc->status != CHECK_OPEN) return SIGNAL_IGNORED; Settings *s = term->GetSettings(); @@ -1508,20 +1508,21 @@ int OrderDeleteZone::Update(Terminal *term, int update_message, const genericCha * OrderCommentZone Class ***********************************************************************/ OrderCommentZone::OrderCommentZone() -= default; +{ +} int OrderCommentZone::RenderInit(Terminal *term, int update_flag) { FnTrace("OrderCommentZone::RenderInit()"); Check *c = term->check; - if (c == nullptr) + if (c == NULL) { active = 0; return 0; } SubCheck *sc = c->current_sub; - if (sc == nullptr || sc->status != CHECK_OPEN) + if (sc == NULL || sc->status != CHECK_OPEN) { active = 0; return 0; @@ -1543,11 +1544,11 @@ SignalResult OrderCommentZone::Touch(Terminal *term, int tx, int ty) { FnTrace("OrderCommentZone::Touch()"); Check *c = term->check; - if (c == nullptr) + if (c == NULL) return SIGNAL_IGNORED; SubCheck *sc = c->current_sub; - if (sc == nullptr || sc->status != CHECK_OPEN) + if (sc == NULL || sc->status != CHECK_OPEN) return SIGNAL_IGNORED; // Create dialog for entering comment @@ -1578,7 +1579,7 @@ ItemZone::ItemZone() { jump_type = JUMP_NONE; jump_id = 0; - item = nullptr; + item = NULL; footer = 14; iscopy = 0; addanyway = 0; @@ -1637,7 +1638,7 @@ RenderResult ItemZone::Render(Terminal *t, int update_flag) } } - if (item == nullptr) + if (item == NULL) { RenderZone(t, "", update_flag); return RENDER_OKAY; @@ -1807,7 +1808,7 @@ RenderResult ItemZone::Render(Terminal *t, int update_flag) col = t->TextureTextColor(texture[State(t)]); } - if (t->check != nullptr && + if (t->check != NULL && strcmp(t->Translate(EMPLOYEE_TABLE), t->check->Table()) == 0 && item->cost != item->employee_cost) { @@ -1817,13 +1818,13 @@ RenderResult ItemZone::Render(Terminal *t, int update_flag) else { CouponInfo *coupon = s->FindCouponByItem(item, 1); - if (coupon != nullptr) + if (coupon != NULL) { // If this coupon is only supposed to be applied once, then we // need to verify there isn't already an applicable item on the // subcheck - SubCheck *currsub = nullptr; - if (t->check != nullptr) + SubCheck *currsub = NULL; + if (t->check != NULL) currsub = t->check->current_sub; int count = coupon->Applies(currsub, 1); if ((coupon->flags & TF_APPLY_EACH) || (count < 1)) @@ -1906,7 +1907,7 @@ SignalResult ItemZone::Signal(Terminal *t, const char* message) { FnTrace("ItemZone::Signal()"); SignalResult retval = SIGNAL_IGNORED; - static const genericChar* commands[] = { "addanyway", "addandopentab", nullptr }; + static const genericChar* commands[] = { "addanyway", "addandopentab", NULL }; int idx = CompareList(message, commands); switch (idx) @@ -1940,11 +1941,11 @@ SignalResult ItemZone::Touch(Terminal *t, int tx, int ty) int reduced_price = 0; int coupon_id = -1; - if (c == nullptr || e == nullptr || !e->CanOrder(s) || item == nullptr) + if (c == NULL || e == NULL || !e->CanOrder(s) || item == NULL) return SIGNAL_IGNORED; SubCheck *sc = c->current_sub; - if (sc == nullptr || sc->status != CHECK_OPEN) + if (sc == NULL || sc->status != CHECK_OPEN) return SIGNAL_IGNORED; if (strcmp("Employee", c->Table()) == 0) @@ -1955,7 +1956,7 @@ SignalResult ItemZone::Touch(Terminal *t, int tx, int ty) else { coupon = s->FindCouponByItem(item, 1); - if (coupon != nullptr) + if (coupon != NULL) { int count = coupon->Applies(sc, 1); if ((coupon->flags & TF_APPLY_EACH) || @@ -1970,7 +1971,7 @@ SignalResult ItemZone::Touch(Terminal *t, int tx, int ty) // Create new order Order *o = new Order(s, item, t); - if (o == nullptr) + if (o == NULL) return SIGNAL_IGNORED; o->IsEmployeeMeal(employee); o->IsReduced(reduced); @@ -1982,7 +1983,7 @@ SignalResult ItemZone::Touch(Terminal *t, int tx, int ty) o->count = 100; // If we have a tab, we need to verify we aren't exceeding the tab. - if (addanyway == 0 && t->check != nullptr && t->is_bar_tab) + if (addanyway == 0 && t->check != NULL && t->is_bar_tab) { o->FigureCost(); if ((sc->TabRemain() - o->total_cost) < 0) @@ -2037,9 +2038,9 @@ SignalResult ItemZone::Touch(Terminal *t, int tx, int ty) t->qualifier = QUALIFIER_NONE; } - t->Update(my_update, nullptr); + t->Update(my_update, NULL); t->RunScript(modifier_script.Value(), jump_type, jump_id); - if (t->cdu != nullptr) + if (t->cdu != NULL) { genericChar buffer[STRLONG]; int buflen; @@ -2148,11 +2149,11 @@ SignalResult QualifierZone::Touch(Terminal *t, int tx, int ty) { FnTrace("QualifierZone::Touch()"); Check *c = t->check; - if (qualifier_type <= 0 || c == nullptr) + if (qualifier_type <= 0 || c == NULL) return SIGNAL_IGNORED; SubCheck *sc = c->current_sub; - if (sc == nullptr || sc->status != CHECK_OPEN) + if (sc == NULL || sc->status != CHECK_OPEN) return SIGNAL_IGNORED; if (t->qualifier & qualifier_type) @@ -2160,7 +2161,7 @@ SignalResult QualifierZone::Touch(Terminal *t, int tx, int ty) else MergeQualifier(t->qualifier, qualifier_type); - t->Update(UPDATE_QUALIFIER, nullptr); + t->Update(UPDATE_QUALIFIER, NULL); t->Jump(jump_type, jump_id); return SIGNAL_OKAY; } diff --git a/zone/order_zone.hh b/zone/order_zone.hh index ffbd2fab..1e54e0ee 100644 --- a/zone/order_zone.hh +++ b/zone/order_zone.hh @@ -19,7 +19,7 @@ */ #ifndef _ORDER_ZONE_HH -#define ORDER_ZONE_HH +#define _ORDER_ZONE_HH #include "layout_zone.hh" @@ -50,18 +50,18 @@ public: OrderEntryZone(); // Member Functions - int Type() override { return ZONE_ORDER_ENTRY; } - int RenderInit(Terminal *term, int update_flag) override; - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Keyboard(Terminal *term, int key, int state) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - int Update(Terminal *term, int update_message, const genericChar* value) override; + int Type() { return ZONE_ORDER_ENTRY; } + int RenderInit(Terminal *term, int update_flag); + RenderResult Render(Terminal *term, int update_flag); + SignalResult Signal(Terminal *term, const genericChar* message); + SignalResult Keyboard(Terminal *term, int key, int state); + SignalResult Touch(Terminal *term, int tx, int ty); + int Update(Terminal *term, int update_message, const genericChar* value); int AddQualifier(Terminal *term, int qualifier_type); - Flt *Spacing() override { return &spacing; } + Flt *Spacing() { return &spacing; } Flt SpacingValue(Terminal *term); // returns spacing value - int SetSize(Terminal *term, int width, int height) override; - int SetPosition(Terminal *term, int pos_x, int pos_y) override; + int SetSize(Terminal *term, int width, int height); + int SetPosition(Terminal *term, int pos_x, int pos_y); int CancelOrders(Terminal *term); int DeleteOrder(Terminal *term, int is_void = 0); @@ -87,14 +87,14 @@ public: OrderPageZone(); // Member Functions - int Type() override { return ZONE_ORDER_PAGE; } - int RenderInit(Terminal *term, int update_flag) override; - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - int ZoneStates() override { return 3; } - const genericChar* TranslateString(Terminal *term) override; - - int *Amount() override { return &amount; } + int Type() { return ZONE_ORDER_PAGE; } + int RenderInit(Terminal *term, int update_flag); + RenderResult Render(Terminal *term, int update_flag); + SignalResult Touch(Terminal *term, int tx, int ty); + int ZoneStates() { return 3; } + const genericChar* TranslateString(Terminal *term); + + int *Amount() { return &amount; } }; // class OrderFlowZone @@ -105,12 +105,12 @@ class OrderFlowZone : public PosZone public: // Member Functions - int Type() override { return ZONE_ORDER_FLOW; } - int RenderInit(Terminal *term, int update_flag) override; - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - int Update(Terminal *term, int update_message, const genericChar* value) override; - int ZoneStates() override { return 3; } + int Type() { return ZONE_ORDER_FLOW; } + int RenderInit(Terminal *term, int update_flag); + RenderResult Render(Terminal *term, int update_flag); + SignalResult Touch(Terminal *term, int tx, int ty); + int Update(Terminal *term, int update_message, const genericChar* value); + int ZoneStates() { return 3; } }; // class OrderAddZone @@ -124,12 +124,12 @@ public: OrderAddZone(); // Member Functions - int Type() override { return ZONE_ORDER_ADD; } - int RenderInit(Terminal *term, int update_flag) override; - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - int Update(Terminal *term, int update_message, const genericChar* value) override; - int ZoneStates() override { return 3; } + int Type() { return ZONE_ORDER_ADD; } + int RenderInit(Terminal *term, int update_flag); + RenderResult Render(Terminal *term, int update_flag); + SignalResult Touch(Terminal *term, int tx, int ty); + int Update(Terminal *term, int update_message, const genericChar* value); + int ZoneStates() { return 3; } }; // class OrderDeleteZone @@ -143,12 +143,12 @@ public: OrderDeleteZone(); // Member Functions - int Type() override { return ZONE_ORDER_DELETE; } - int RenderInit(Terminal *term, int update_flag) override; - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - int Update(Terminal *term, int update_message, const genericChar* value) override; - int ZoneStates() override { return 3; } + int Type() { return ZONE_ORDER_DELETE; } + int RenderInit(Terminal *term, int update_flag); + RenderResult Render(Terminal *term, int update_flag); + SignalResult Touch(Terminal *term, int tx, int ty); + int Update(Terminal *term, int update_message, const genericChar* value); + int ZoneStates() { return 3; } }; // class OrderCommentZone @@ -160,12 +160,12 @@ public: OrderCommentZone(); // Member Functions - int Type() override { return ZONE_ORDER_COMMENT; } - int RenderInit(Terminal *term, int update_flag) override; - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - int Update(Terminal *term, int update_message, const genericChar* value) override; - int ZoneStates() override { return 3; } + int Type() { return ZONE_ORDER_COMMENT; } + int RenderInit(Terminal *term, int update_flag); + RenderResult Render(Terminal *term, int update_flag); + SignalResult Touch(Terminal *term, int tx, int ty); + int Update(Terminal *term, int update_message, const genericChar* value); + int ZoneStates() { return 3; } }; // class OrderDisplayZone @@ -177,11 +177,11 @@ public: OrderDisplayZone(); // Member Functions - int Type() override { return ZONE_ORDER_DISPLAY; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - SignalResult Keyboard(Terminal *term, int key, int state) override; - int ZoneStates() override { return 1; } + int Type() { return ZONE_ORDER_DISPLAY; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Touch(Terminal *term, int tx, int ty); + SignalResult Keyboard(Terminal *term, int key, int state); + int ZoneStates() { return 1; } }; // class ItemZone @@ -199,20 +199,20 @@ public: ItemZone(); // Member Functions - int Type() override { return ZONE_ITEM; } - std::unique_ptr Copy() override; - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const char* message) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; + int Type() { return ZONE_ITEM; } + std::unique_ptr Copy(); + RenderResult Render(Terminal *term, int update_flag); + SignalResult Signal(Terminal *term, const char* message); + SignalResult Touch(Terminal *term, int tx, int ty); int AddPayment(Terminal *term, int ptype, int pid, int pflags, int pamount); - int Update(Terminal *term, int update_message, const genericChar* value) override; - SalesItem *Item(ItemDB *db) override; - const genericChar* TranslateString(Terminal *term) override { return nullptr; } - - Str *ItemName() override { return &item_name; } - Str *Script() override { return &modifier_script; } - int *JumpType() override { return &jump_type; } - int *JumpID() override { return &jump_id; } + int Update(Terminal *term, int update_message, const genericChar* value); + SalesItem *Item(ItemDB *db); + const genericChar* TranslateString(Terminal *term) { return NULL; } + + Str *ItemName() { return &item_name; } + Str *Script() { return &modifier_script; } + int *JumpType() { return &jump_type; } + int *JumpID() { return &jump_id; } }; // class QualifierZone @@ -229,15 +229,15 @@ public: QualifierZone(); // Member Functions - int Type() override { return ZONE_QUALIFIER; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - int Update(Terminal *term, int update_message, const genericChar* value) override; - const genericChar* TranslateString(Terminal *term) override { return nullptr; } - - int *QualifierType() override { return &qualifier_type; } - int *JumpType() override { return &jump_type; } - int *JumpID() override { return &jump_id; } + int Type() { return ZONE_QUALIFIER; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Touch(Terminal *term, int tx, int ty); + int Update(Terminal *term, int update_message, const genericChar* value); + const genericChar* TranslateString(Terminal *term) { return NULL; } + + int *QualifierType() { return &qualifier_type; } + int *JumpType() { return &jump_type; } + int *JumpID() { return &jump_id; } }; #endif diff --git a/zone/payment_zone.cc b/zone/payment_zone.cc index aee890ed..97a716ed 100644 --- a/zone/payment_zone.cc +++ b/zone/payment_zone.cc @@ -27,7 +27,6 @@ #include "dialog_zone.hh" #include "locale.hh" #include "settings.hh" -#include "main/data/settings_enums.hh" #include "system.hh" #include "credit.hh" #include "archive.hh" @@ -53,7 +52,7 @@ PaymentZone::PaymentZone() FnTrace("PaymentZone::PaymentZone()"); min_size_x = 22; min_size_y = 17; - current_payment = nullptr; + current_payment = NULL; voided = 0; spacing = 2; drawer_open = 0; @@ -73,28 +72,28 @@ RenderResult PaymentZone::Render(Terminal *term, int update_flag) Employee *employee = term->user; Check *currCheck = term->check; - if (employee == nullptr || currCheck == nullptr) + if (employee == NULL || currCheck == NULL) return RENDER_OKAY; Settings *settings = term->GetSettings(); SubCheck *subCheck = &work_sub; - if (currCheck->current_sub == nullptr) + if (currCheck->current_sub == NULL) { currCheck->current_sub = currCheck->FirstOpenSubCheck(); - if (currCheck->current_sub == nullptr) + if (currCheck->current_sub == NULL) return RENDER_OKAY; subCheck->Copy(currCheck->current_sub, settings); - current_payment = nullptr; + current_payment = NULL; amount = 0; } else if (update_flag == RENDER_NEW) { - if (term->credit != nullptr) + if (term->credit != NULL) { delete term->credit; - term->credit = nullptr; + term->credit = NULL; } - current_payment = nullptr; + current_payment = NULL; subCheck->Copy(currCheck->current_sub, settings); amount = 0; if (term->is_bar_tab) @@ -261,7 +260,7 @@ RenderResult PaymentZone::Render(Terminal *term, int update_flag) TextPosR(term, mark + 9, line, term->FormatPrice(total_cost), COLOR_DK_RED); line += min_spacing; - if (term->cdu != nullptr) + if (term->cdu != NULL) { term->cdu->Refresh(-1); // make sure the screen doesn't clear until we're done snprintf(cdustring, STRLONG, "Total %s%s", settings->money_symbol.Value(), @@ -287,7 +286,7 @@ RenderResult PaymentZone::Render(Terminal *term, int update_flag) Flt bg_start; Flt bg_lines; Payment *payment = subCheck->PaymentList(); - while (payment != nullptr) + while (payment != NULL) { has_payments = 1; if (payment->Suppress() == 0) @@ -306,10 +305,10 @@ RenderResult PaymentZone::Render(Terminal *term, int update_flag) { bg_start = line - bg_half; bg_lines = 1; - if (payment->credit != nullptr) + if (payment->credit != NULL) bg_lines = 4; bg_lines += (bg_half * 2); - if (payment->credit != nullptr && + if (payment->credit != NULL && strlen(payment->credit->Name()) > 0) { bg_lines += 1; @@ -326,7 +325,7 @@ RenderResult PaymentZone::Render(Terminal *term, int update_flag) TextR(term, line, term->FormatPrice(payment->value), c1); payment->FigureTotals(0); Credit *cr = payment->credit; - if (cr != nullptr) + if (cr != NULL) { preauth_amount += cr->TotalPreauth(); line += min_spacing; @@ -391,7 +390,7 @@ RenderResult PaymentZone::Render(Terminal *term, int update_flag) TextC(term, line + (min_spacing * 2), term->Translate("To Rebuild"), text); } } - else if (subCheck->OrderList() == nullptr) + else if (subCheck->OrderList() == NULL) TextC(term, line, term->Translate("Check Blank"), COLOR_YELLOW); else if (subCheck->balance <= 0) TextC(term, line, term->Translate("Balance Covered"), COLOR_DK_GREEN); @@ -430,7 +429,7 @@ RenderResult PaymentZone::Render(Terminal *term, int update_flag) } if (subCheck->IsBalanced() == 0) { - if (term->cdu != nullptr) + if (term->cdu != NULL) { snprintf(cdustring, STRLONG, "Due: %s%s", settings->money_symbol.Value(), term->FormatPrice(subCheck->balance)); @@ -453,7 +452,7 @@ RenderResult PaymentZone::Render(Terminal *term, int update_flag) { OpenDrawer(term); } - if (term->cdu != nullptr) + if (term->cdu != NULL) { snprintf(cdustring, STRLONG, "Change %s%s", settings->money_symbol.Value(), term->FormatPrice(change_value)); @@ -474,15 +473,15 @@ SignalResult PaymentZone::Signal(Terminal *term, const genericChar* message) "print ", "backspace", "clear", "nextcheck", "nextcheckforce", "void", "undo", "undoconfirmed", "merchandise", "done", "10", "20", "taxexempt", "settaxexempt ", "ccamountchanged", - "ccrefund", "save", nullptr}; + "ccrefund", "save", NULL}; Employee *employee = term->user; Check *thisCheck = term->check; - GetTextDialog *textdiag = nullptr; - DialogZone *confirm = nullptr; + GetTextDialog *textdiag = NULL; + DialogZone *confirm = NULL; char buffer[STRLONG]; - if (employee == nullptr || thisCheck == nullptr) + if (employee == NULL || thisCheck == NULL) return SIGNAL_IGNORED; Settings *settings = term->GetSettings(); @@ -509,7 +508,7 @@ SignalResult PaymentZone::Signal(Terminal *term, const genericChar* message) { sc->Remove(current_payment); delete current_payment; - current_payment = nullptr; + current_payment = NULL; } else current_payment->tender_id = room; @@ -520,13 +519,13 @@ SignalResult PaymentZone::Signal(Terminal *term, const genericChar* message) } else if (strncmp(message, "swipe ", 6) == 0) { - if (term->dialog != nullptr && term->dialog->Type() == ZONE_DLG_CREDIT) + if (term->dialog != NULL && term->dialog->Type() == ZONE_DLG_CREDIT) { return SIGNAL_IGNORED; } else { - if (term->dialog != nullptr) + if (term->dialog != NULL) { ReportError("PaymentZone Signal Swipe dumping previous dialog!"); snprintf(buffer, STRLONG, " Named: %s\n", term->dialog->name.Value()); @@ -585,7 +584,7 @@ SignalResult PaymentZone::Signal(Terminal *term, const genericChar* message) CloseCheck(term, 2); return SIGNAL_OKAY; case 15: // print - if (strcmp("subcheck", &message[6]) == 0 && sc != nullptr) + if (strcmp("subcheck", &message[6]) == 0 && sc != NULL) { Printer *printer = term->FindPrinter(PRINTER_RECEIPT); if (sc->status == CHECK_OPEN && sc->balance <= 0) @@ -595,12 +594,12 @@ SignalResult PaymentZone::Signal(Terminal *term, const genericChar* message) return SIGNAL_OKAY; } else if (strcmp("credit", &message[6]) == 0 && - current_payment != nullptr && - current_payment->credit != nullptr) + current_payment != NULL && + current_payment->credit != NULL) { Printer *printer = term->FindPrinter(PRINTER_RECEIPT); int pamount = (amount > 0 ? amount : -1); - if (pamount == -1 && sc != nullptr && sc->total_cost > 0) + if (pamount == -1 && sc != NULL && sc->total_cost > 0) pamount = sc->total_cost; current_payment->credit->PrintReceipt(term, RECEIPT_PICK, printer, pamount); return SIGNAL_OKAY; @@ -631,7 +630,7 @@ SignalResult PaymentZone::Signal(Terminal *term, const genericChar* message) NextCheck(term, 1); return SIGNAL_OKAY; case 20: // Void - if (sc && sc->PaymentList() == nullptr) + if (sc && sc->PaymentList() == NULL) { voided = 1 - voided; Draw(term, 0); @@ -650,7 +649,7 @@ SignalResult PaymentZone::Signal(Terminal *term, const genericChar* message) term->OpenDialog(confirm); return SIGNAL_TERMINATE; } - else if (current_payment == nullptr && + else if (current_payment == NULL && sc && sc->HasAuthedCreditCards()) { confirm = new SimpleDialog(term->Translate("You cannot clear all entries with authorized cards.")); @@ -663,27 +662,26 @@ SignalResult PaymentZone::Signal(Terminal *term, const genericChar* message) // now, just prevent undoing with authed credit cards. This should // also be the case for the cancel message, but I haven't figured out // how to do that yet. - /* fallthrough */ case 22: // undoconfirmed - if (current_payment != nullptr) + if (current_payment != NULL) { //FIX->BAK verify this code does not cause other problems! if (current_payment->tender_type == TENDER_CHARGED_TIP) { Payment *currpay = sc->PaymentList(); - while (currpay != nullptr) + while (currpay != NULL) { - if (currpay->credit != nullptr) + if (currpay->credit != NULL) { currpay->credit->Tip(0); - currpay = nullptr; + currpay = NULL; } else currpay = currpay->next; } } sc->Remove(current_payment); - if (current_payment->credit != nullptr) + if (current_payment->credit != NULL) { if (!current_payment->credit->IsVoided() && !current_payment->credit->IsRefunded()) @@ -692,7 +690,7 @@ SignalResult PaymentZone::Signal(Terminal *term, const genericChar* message) } } delete current_payment; - current_payment = nullptr; + current_payment = NULL; sc->FigureTotals(settings); if (sc->IsBalanced()) { @@ -712,7 +710,7 @@ SignalResult PaymentZone::Signal(Terminal *term, const genericChar* message) voided = 0; sc->UndoPayments(term, employee); amount = 0; - current_payment = nullptr; + current_payment = NULL; if (sc->IsBalanced()) term->check_balanced = 1; else @@ -755,7 +753,7 @@ SignalResult PaymentZone::Signal(Terminal *term, const genericChar* message) case 29: // ccamountchanged if (sc) { - if (current_payment != nullptr && current_payment->credit != nullptr) + if (current_payment != NULL && current_payment->credit != NULL) { if (current_payment->credit->IsVoided() || current_payment->credit->IsRefunded()) @@ -763,13 +761,13 @@ SignalResult PaymentZone::Signal(Terminal *term, const genericChar* message) if (current_payment->flags & TF_FINAL) current_payment->flags -= TF_FINAL; Payment *currpay = sc->PaymentList(); - while (currpay != nullptr) + while (currpay != NULL) { if (currpay->tender_type == TENDER_CHARGED_TIP) { sc->Remove(currpay); delete currpay; - currpay = nullptr; + currpay = NULL; } else currpay = currpay->next; @@ -777,7 +775,7 @@ SignalResult PaymentZone::Signal(Terminal *term, const genericChar* message) sc->status = CHECK_OPEN; } } - current_payment = nullptr; + current_payment = NULL; sc->FigureTotals(settings); if (sc->IsBalanced()) term->check_balanced = 1; @@ -788,7 +786,7 @@ SignalResult PaymentZone::Signal(Terminal *term, const genericChar* message) else return SIGNAL_IGNORED; case 30: // ccrefund - AddPayment(term, 0, nullptr); + AddPayment(term, 0, NULL); return SIGNAL_OKAY; case 31: // save SaveCheck(term); @@ -824,22 +822,22 @@ SignalResult PaymentZone::Touch(Terminal *term, int tx, int ty) Flt max_line; int name_len = 0; - if (check == nullptr) + if (check == NULL) return SIGNAL_IGNORED; SubCheck *sc = &work_sub; - if (sc == nullptr) + if (sc == NULL) return SIGNAL_IGNORED; LayoutZone::Touch(term, tx, ty); Flt line = header_size; Flt buffer = ((spacing - 1) / 2); - for (Payment *payment = sc->PaymentList(); payment != nullptr; payment = payment->next) + for (Payment *payment = sc->PaymentList(); payment != NULL; payment = payment->next) { name_len = 0; min_line = line - buffer; - if (payment->credit != nullptr) + if (payment->credit != NULL) { max_line = line + (spacing * 3); if (strlen(payment->credit->Name()) > 0) @@ -854,7 +852,7 @@ SignalResult PaymentZone::Touch(Terminal *term, int tx, int ty) if (selected_y > min_line && selected_y < max_line) { if (current_payment == payment) - current_payment = nullptr; + current_payment = NULL; else current_payment = payment; Draw(term, 0); @@ -862,7 +860,7 @@ SignalResult PaymentZone::Touch(Terminal *term, int tx, int ty) } else { - if (payment->credit != nullptr) + if (payment->credit != NULL) { line += (spacing * 3); if (name_len) @@ -872,7 +870,7 @@ SignalResult PaymentZone::Touch(Terminal *term, int tx, int ty) line += spacing; } } - if (current_payment != nullptr && current_payment->credit != nullptr) + if (current_payment != NULL && current_payment->credit != NULL) { char str[STRLENGTH] = ""; vt_safe_string::safe_concat(str, STRLENGTH, "Would you like to print the receipt for\\"); @@ -939,7 +937,7 @@ int PaymentZone::SaveCheck(Terminal *term) Settings *settings = &(sys->settings); SubCheck *subCheck = &work_sub; - if (employee == nullptr || currCheck == nullptr || currCheck->current_sub == nullptr) + if (employee == NULL || currCheck == NULL || currCheck->current_sub == NULL) return 1; currCheck->current_sub->Copy(subCheck, settings); @@ -967,7 +965,7 @@ int PaymentZone::CloseCheck(Terminal *term, int force) { // do we have any pre-auths left? Payment *currpay = work_sub.PaymentList(); int has_preauths = 0; - while (currpay != nullptr && has_preauths == 0) + while (currpay != NULL && has_preauths == 0) { if (currpay->credit && currpay->credit->IsPreauthed()) has_preauths = 1; @@ -983,10 +981,10 @@ int PaymentZone::CloseCheck(Terminal *term, int force) } } - if (employee == nullptr || currCheck == nullptr || currCheck->current_sub == nullptr) + if (employee == NULL || currCheck == NULL || currCheck->current_sub == NULL) return 1; - if (term->cdu != nullptr) + if (term->cdu != NULL) { term->cdu->Clear(); term->cdu->ShowString(&(term->system_data->cdustrings)); @@ -1024,7 +1022,7 @@ int PaymentZone::CloseCheck(Terminal *term, int force) if (! close_error) { Drawer *drawer = term->FindDrawer(); - if (drawer == nullptr && !currCheck->IsTraining() && + if (drawer == NULL && !currCheck->IsTraining() && !(subCheck->OnlyCredit() == 1 && term->is_bar_tab == 1)) { // Get descriptive reason for drawer unavailability @@ -1125,15 +1123,11 @@ int PaymentZone::CloseCheck(Terminal *term, int force) // Update drawer record drawer_open = 0; Printer *pr = term->FindPrinter(PRINTER_RECEIPT); - if (pr) + if (pr && (settings->receipt_print & RECEIPT_FINALIZE)) { - if (auto receipt_mode = vt::IntToEnum(settings->receipt_print)) { - if (*receipt_mode == ReceiptPrintType::OnFinalize || *receipt_mode == ReceiptPrintType::OnBoth) { - if (settings->cash_receipt || subCheck->OnlyCredit() == 0) - { - subCheck->PrintReceipt(term, currCheck, pr, drawer, open_drawer); - } - } + if (settings->cash_receipt || subCheck->OnlyCredit() == 0) + { + subCheck->PrintReceipt(term, currCheck, pr, drawer, open_drawer); } } } @@ -1158,14 +1152,14 @@ int PaymentZone::CloseCheck(Terminal *term, int force) // Find next open subcheck in check SubCheck *nextsub = currCheck->NextOpenSubCheck(); - if (nextsub != nullptr) + if (nextsub != NULL) { if (nextsub->IsBalanced()) term->check_balanced = 1; else term->check_balanced = 0; work_sub.Copy(nextsub, settings); - current_payment = nullptr; + current_payment = NULL; term->Draw(1); return 0; } @@ -1174,7 +1168,7 @@ int PaymentZone::CloseCheck(Terminal *term, int force) } else { - if (rebuild == 0 && currCheck->archive == nullptr) + if (rebuild == 0 && currCheck->archive == NULL) { // Move check to end of list sys->Remove(currCheck); @@ -1195,14 +1189,14 @@ int PaymentZone::DoneWithCheck(Terminal *term, int store_check) { FnTrace("PaymentZone::DoneWithCheck()"); Check *currCheck = term->check; - if (currCheck == nullptr) + if (currCheck == NULL) return 1; Settings *settings = term->GetSettings(); if (store_check) { term->StoreCheck(0); - term->UpdateOtherTerms(UPDATE_CHECKS, nullptr); + term->UpdateOtherTerms(UPDATE_CHECKS, NULL); } // Check if payment was made through Server Bank drawer by Customer user on SelfOrder terminal @@ -1256,16 +1250,16 @@ int PaymentZone::AddPayment(Terminal *term, int ptype, int pid, int pflags, int Employee *employee = term->user; Check *currCheck = term->check; Settings *settings = term->GetSettings(); - SubCheck *subCheck = nullptr; + SubCheck *subCheck = NULL; - if (employee == nullptr || currCheck == nullptr) + if (employee == NULL || currCheck == NULL) return 1; subCheck = &work_sub; if (subCheck->status != CHECK_OPEN) return 1; - if (subCheck->OrderList() == nullptr && term->is_bar_tab == 0) + if (subCheck->OrderList() == NULL && term->is_bar_tab == 0) { amount = 0; Draw(term, 0); @@ -1297,7 +1291,7 @@ int PaymentZone::AddPayment(Terminal *term, int ptype, int pid, int pflags, int } Drawer *drawer = term->FindDrawer(); - if (drawer == nullptr && !currCheck->IsTraining() && + if (drawer == NULL && !currCheck->IsTraining() && !(subCheck->OnlyCredit() == 1 && term->is_bar_tab == 1)) { // Get descriptive reason for drawer unavailability @@ -1390,7 +1384,7 @@ int PaymentZone::AddPayment(Terminal *term, int ptype, int pid, int pflags, int pflags |= TF_IS_TAB; Payment *paymnt = subCheck->NewPayment(ptype, pid, pflags, pamount); - if (paymnt == nullptr) + if (paymnt == NULL) return 1; if (paymnt->tender_type == TENDER_CREDIT_CARD || @@ -1398,7 +1392,7 @@ int PaymentZone::AddPayment(Terminal *term, int ptype, int pid, int pflags, int { paymnt->credit = term->credit; paymnt->credit->check_id = currCheck->serial_number; - term->credit = nullptr; + term->credit = NULL; } amount = 0; @@ -1412,8 +1406,8 @@ int PaymentZone::AddPayment(Terminal *term, int ptype, int pid, int pflags, int term->check_balanced = 0; term->Draw(1); - current_payment = nullptr; - paymnt = nullptr; + current_payment = NULL; + paymnt = NULL; if (ptype == TENDER_CASH) OpenDrawer(term); @@ -1438,15 +1432,15 @@ int PaymentZone::AddPayment(Terminal *term, int ptype, const genericChar* swipe_ { FnTrace("PaymentZone::AddPayment(credit card)"); int retval = 0; - CreditCardDialog *ccd = nullptr; - SimpleDialog *sd = nullptr; + CreditCardDialog *ccd = NULL; + SimpleDialog *sd = NULL; Settings *settings = term->GetSettings(); Payment *currpay = work_sub.PaymentList(); int count = 0; char str[STRLENGTH]; char str1[STRLENGTH]; - if (work_sub.status == CHECK_CLOSED && current_payment == nullptr) + if (work_sub.status == CHECK_CLOSED && current_payment == NULL) { sd = new SimpleDialog(term->Translate("You cannot add a charge card to a closed check.")); sd->Button("Okay"); @@ -1454,9 +1448,9 @@ int PaymentZone::AddPayment(Terminal *term, int ptype, const genericChar* swipe_ } else { - if (term->credit != nullptr) + if (term->credit != NULL) ReportError("Possibly losing a credit card in PaymentZone::AddPayment()"); - term->credit = nullptr; + term->credit = NULL; int len = (swipe_value != nullptr) ? static_cast(strlen(swipe_value)) : 0; // Arbitrary. We'll assume there will never be more than 99 credit // cards added to a ticket. Really, len == 1 should be a valid @@ -1467,9 +1461,9 @@ int PaymentZone::AddPayment(Terminal *term, int ptype, const genericChar* swipe_ { count = atoi(swipe_value); currpay = work_sub.PaymentList(); - while (currpay != nullptr && count > 0) + while (currpay != NULL && count > 0) { - if (currpay->credit != nullptr) + if (currpay->credit != NULL) count -= 1; if (count == 0) { @@ -1481,16 +1475,16 @@ int PaymentZone::AddPayment(Terminal *term, int ptype, const genericChar* swipe_ } } else if (len == 0 && - current_payment != nullptr && - current_payment->credit != nullptr) + current_payment != NULL && + current_payment->credit != NULL) { term->credit = current_payment->credit; } else if (len == 0) { - while (currpay != nullptr) + while (currpay != NULL) { - if (currpay->credit != nullptr) + if (currpay->credit != NULL) count += 1; currpay = currpay->next; } @@ -1500,9 +1494,9 @@ int PaymentZone::AddPayment(Terminal *term, int ptype, const genericChar* swipe_ sd->Button("New Card", "swipe newcard"); currpay = work_sub.PaymentList(); count = 0; - while (currpay != nullptr) + while (currpay != NULL) { - if (currpay->credit != nullptr) + if (currpay->credit != NULL) { count += 1; snprintf(str, STRLENGTH, "%s\\%s", @@ -1520,17 +1514,17 @@ int PaymentZone::AddPayment(Terminal *term, int ptype, const genericChar* swipe_ } } - if (term->check->current_sub != nullptr) + if (term->check->current_sub != NULL) term->check->current_sub->FigureTotals(term->GetSettings()); - if (amount == 0 && term->credit != nullptr) + if (amount == 0 && term->credit != NULL) { if (term->credit->IsPreauthed() && settings->cc_bar_mode == 1 && - term->check->current_sub != nullptr) + term->check->current_sub != NULL) { term->auth_amount = term->check->current_sub->balance; } - else if (term->check->current_sub != nullptr && term->check->current_sub->TabRemain() > 0) + else if (term->check->current_sub != NULL && term->check->current_sub->TabRemain() > 0) term->auth_amount = term->check->current_sub->balance; else term->auth_amount = term->credit->Total(1); @@ -1541,10 +1535,10 @@ int PaymentZone::AddPayment(Terminal *term, int ptype, const genericChar* swipe_ term->auth_amount = amount; term->void_amount = amount; } - if (strlen(swipe_value) > 2 && strcmp(swipe_value, "newcard") != 0) + if (strlen(swipe_value) > 2 && strcmp(swipe_value, "newcard")) ccd = new CreditCardDialog(term, &work_sub, swipe_value); else - ccd = new CreditCardDialog(term, &work_sub, nullptr); + ccd = new CreditCardDialog(term, &work_sub, NULL); retval = term->OpenDialog(ccd); } @@ -1556,15 +1550,15 @@ int PaymentZone::NextCheck(Terminal *term, int force) FnTrace("PaymentZone::NextCheck()"); Check *check = term->check; - if (check == nullptr) + if (check == NULL) return 1; SubCheck *sc = check->current_sub; - if (sc == nullptr) + if (sc == NULL) return 1; SubCheck *sc_next = sc->next; - if (sc_next == nullptr) + if (sc_next == NULL) sc_next = check->SubList(); if (sc == sc_next) return 1; @@ -1597,7 +1591,7 @@ int PaymentZone::Merchandise(Terminal *term, SubCheck *sc) { FnTrace("PaymentZone::Merchandise()"); - if (sc == nullptr) + if (sc == NULL) return 1; int price = amount; @@ -1623,7 +1617,7 @@ int PaymentZone::OpenDrawer(Terminal *term) FnTrace("PaymentZone::OpenDrawer()"); int retval = 1; Drawer *drawer = term->FindDrawer(); - if (drawer == nullptr) + if (drawer == NULL) return retval; if (drawer_open == 0) @@ -1662,7 +1656,7 @@ int TenderZone::RenderInit(Terminal *term, int update_flag) active = (settings->DiscountCount(ALL_MEDIA, ACTIVE_MEDIA) > 0); break; case TENDER_COMP: active = (settings->CompCount(ALL_MEDIA, ACTIVE_MEDIA) > 0); - if (employee == nullptr || !employee->CanCompOrder(settings)) + if (employee == NULL || !employee->CanCompOrder(settings)) active = 0; break; case TENDER_CHARGE_CARD: @@ -1687,9 +1681,9 @@ SignalResult TenderZone::Touch(Terminal *term, int tx, int ty) char str[256]; Settings *settings = term->GetSettings(); int count = 0; - Drawer *drawer = nullptr; + Drawer *drawer = NULL; - if (employee == nullptr) + if (employee == NULL) return SIGNAL_IGNORED; switch (tender_type) @@ -1712,7 +1706,7 @@ SignalResult TenderZone::Touch(Terminal *term, int tx, int ty) break; case TENDER_EMPLOYEE_MEAL: { - MealInfo *mi = settings->MealList(), *ptr = nullptr; + MealInfo *mi = settings->MealList(), *ptr = NULL; while (mi) { if (!(mi->flags & TF_MANAGER) || employee->IsManager(settings)) @@ -1751,7 +1745,7 @@ SignalResult TenderZone::Touch(Terminal *term, int tx, int ty) case TENDER_CHARGE_CARD: { drawer = term->FindDrawer(); - if (drawer == nullptr && term->is_bar_tab == 0) + if (drawer == NULL && term->is_bar_tab == 0) { // Get descriptive reason for drawer unavailability Settings *sett = term->GetSettings(); // Renamed to avoid shadowing outer 'settings' diff --git a/zone/payment_zone.hh b/zone/payment_zone.hh index 84ca9f43..74fb44d2 100644 --- a/zone/payment_zone.hh +++ b/zone/payment_zone.hh @@ -19,7 +19,7 @@ */ #ifndef _PAYMENT_ZONE_HH -#define PAYMENT_ZONE_HH +#define _PAYMENT_ZONE_HH #include "layout_zone.hh" #include "check.hh" @@ -44,16 +44,16 @@ public: PaymentZone(); // Memeber Functions - int Type() override { return ZONE_PAYMENT_ENTRY; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Keyboard(Terminal *term, int key, int state) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - int Update(Terminal *term, int update_message, const genericChar* value) override; + int Type() { return ZONE_PAYMENT_ENTRY; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Signal(Terminal *term, const genericChar* message); + SignalResult Keyboard(Terminal *term, int key, int state); + SignalResult Touch(Terminal *term, int tx, int ty); + int Update(Terminal *term, int update_message, const genericChar* value); int AddPayment(Terminal *term, int type, int id, int amount, int flags); int AddPayment(Terminal *term, int type, const genericChar* swipe_value); - Flt *Spacing() override { return &spacing; } + Flt *Spacing() { return &spacing; } int RenderPaymentEntry(Terminal *term); int DrawPaymentEntry(Terminal *term); @@ -75,13 +75,13 @@ public: TenderZone(); // Member Functions - int Type() override { return ZONE_TENDER; } - int RenderInit(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - int ZoneStates() override { return 3; } + int Type() { return ZONE_TENDER; } + int RenderInit(Terminal *term, int update_flag); + SignalResult Touch(Terminal *term, int tx, int ty); + int ZoneStates() { return 3; } - int *TenderType() override { return &tender_type; } - int *TenderAmount() override { return &amount; } + int *TenderType() { return &tender_type; } + int *TenderAmount() { return &amount; } }; #endif diff --git a/zone/payout_zone.cc b/zone/payout_zone.cc index 48b13c5b..9f720cc3 100644 --- a/zone/payout_zone.cc +++ b/zone/payout_zone.cc @@ -55,9 +55,9 @@ PayoutZone::PayoutZone() amount = 0; user_id = 0; page = 0; - archive = nullptr; - tip_db = nullptr; - report = nullptr; + archive = NULL; + tip_db = NULL; + report = NULL; } // Destructor @@ -77,12 +77,12 @@ RenderResult PayoutZone::Render(Terminal *term, int update_flag) if (update_flag == RENDER_NEW) { sys->tip_db.Update(sys); - archive = nullptr; + archive = NULL; } if (report) { delete report; - report = nullptr; + report = NULL; } if (archive) tip_db = &(archive->tip_db); @@ -92,10 +92,10 @@ RenderResult PayoutZone::Render(Terminal *term, int update_flag) payout = -1; } - if (tip_db == nullptr) + if (tip_db == NULL) return RENDER_OKAY; - if (report == nullptr) + if (report == NULL) { report = new Report; tip_db->ListReport(term, term->user, report); @@ -137,7 +137,7 @@ RenderResult PayoutZone::Render(Terminal *term, int update_flag) timevar = archive->fore->end_time; term->TimeDate(t1, timevar, TD0); } - else if (archive == nullptr && sys->ArchiveListEnd()) + else if (archive == NULL && sys->ArchiveListEnd()) { timevar = sys->ArchiveListEnd()->end_time; term->TimeDate(t1, timevar, TD0); @@ -161,7 +161,7 @@ RenderResult PayoutZone::Render(Terminal *term, int update_flag) SignalResult PayoutZone::Signal(Terminal *term, const genericChar* message) { static const genericChar* commands[] = { - "payout", "next", "prior", "print", "localprint", "reportprint", nullptr}; + "payout", "next", "prior", "print", "localprint", "reportprint", NULL}; if (payout >= 0) { @@ -177,7 +177,7 @@ SignalResult PayoutZone::Signal(Terminal *term, const genericChar* message) PayoutTips(term); return SIGNAL_OKAY; case 1: // Next - if (archive == nullptr) + if (archive == NULL) break; archive = archive->next; Draw(term, 1); @@ -185,7 +185,7 @@ SignalResult PayoutZone::Signal(Terminal *term, const genericChar* message) case 2: // Prior if (archive) { - if (archive->fore == nullptr) + if (archive->fore == NULL) return SIGNAL_IGNORED; archive = archive->fore; } @@ -209,7 +209,7 @@ SignalResult PayoutZone::Signal(Terminal *term, const genericChar* message) SignalResult PayoutZone::Touch(Terminal *term, int tx, int ty) { FnTrace("PayoutZone::Touch()"); - if (report == nullptr) + if (report == NULL) return SIGNAL_IGNORED; int new_page = page; @@ -219,7 +219,7 @@ SignalResult PayoutZone::Touch(Terminal *term, int tx, int ty) --new_page; else if (line == -2) // footer ++new_page; - else if (archive == nullptr) + else if (archive == NULL) { selected = line; Draw(term, 0); @@ -242,21 +242,21 @@ SignalResult PayoutZone::Touch(Terminal *term, int tx, int ty) int PayoutZone::PayoutTips(Terminal *term) { Employee *e = term->user; - if (e == nullptr || e->training || tip_db == nullptr || report == nullptr) + if (e == NULL || e->training || tip_db == NULL || report == NULL) return 1; System *sys = term->system_data; Settings *s = &(sys->settings); - TipEntry *te = nullptr; + TipEntry *te = NULL; if (e->IsSupervisor(s)) - te = tip_db->FindByRecord(selected, nullptr); + te = tip_db->FindByRecord(selected, NULL); else te = tip_db->FindByRecord(selected, e); - if (te == nullptr) + if (te == NULL) return 1; Drawer *d = term->FindDrawer(); - if (d == nullptr) + if (d == NULL) return 1; amount = te->amount; @@ -274,7 +274,7 @@ int PayoutZone::PayoutTips(Terminal *term) Draw(term, 0); Printer *p = term->FindPrinter(PRINTER_RECEIPT); - if (p == nullptr) + if (p == NULL) return 0; Report r; @@ -291,12 +291,12 @@ int PayoutZone::Print(Terminal *term, int print_mode) return 0; Employee *e = term->user; - if (e == nullptr || tip_db == nullptr) + if (e == NULL || tip_db == NULL) return 1; Printer *p1 = term->FindPrinter(PRINTER_RECEIPT); Printer *p2 = term->FindPrinter(PRINTER_REPORT); - if (p1 == nullptr && p2 == nullptr) + if (p1 == NULL && p2 == NULL) return 1; if (print_mode == RP_ASK) @@ -308,10 +308,10 @@ int PayoutZone::Print(Terminal *term, int print_mode) } Printer *p = p1; - if ((print_mode == RP_PRINT_REPORT && p2) || p1 == nullptr) + if ((print_mode == RP_PRINT_REPORT && p2) || p1 == NULL) p = p2; - if (p == nullptr) + if (p == NULL) return 1; Report r; @@ -348,7 +348,7 @@ RenderResult EndDayZone::Render(Terminal *term, int update_flag) int min_day_hrs = min_day_secs / 60 / 60; int line = 0; - if (a == nullptr) + if (a == NULL) { TextC(term, ++line, term->Translate("This is the first business day")); flag3 = 0; @@ -405,11 +405,11 @@ RenderResult EndDayZone::Render(Terminal *term, int update_flag) SignalResult EndDayZone::Signal(Terminal *term, const genericChar* message) { - SimpleDialog *d = nullptr; + SimpleDialog *d = NULL; char buffer[STRLENGTH]; SignalResult retval = SIGNAL_IGNORED; static const genericChar* commands[] = {"end", "force end", "enddaydone", - "enddayfailed", "cceodnosettle", nullptr}; + "enddayfailed", "cceodnosettle", NULL}; const std::string msg(message); int idx = CompareList(message, commands); @@ -433,7 +433,7 @@ SignalResult EndDayZone::Signal(Terminal *term, const genericChar* message) else if (flag5) d = new SimpleDialog(ERR_CC_EXCEPT); - if (d != nullptr) + if (d != NULL) { d->font = FONT_TIMES_24B; d->color[0] = COLOR_RED; diff --git a/zone/payout_zone.hh b/zone/payout_zone.hh index bebc6c4f..f8a3b062 100644 --- a/zone/payout_zone.hh +++ b/zone/payout_zone.hh @@ -19,7 +19,7 @@ */ #ifndef _PAYOUT_ZONE_HH -#define PAYOUT_ZONE_HH +#define _PAYOUT_ZONE_HH #include "layout_zone.hh" @@ -46,15 +46,15 @@ public: // Constructor PayoutZone(); // Destructor - ~PayoutZone() override; + ~PayoutZone(); // Member Functions - int Type() override { return ZONE_PAYOUT; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; + int Type() { return ZONE_PAYOUT; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Signal(Terminal *term, const genericChar* message); + SignalResult Touch(Terminal *term, int tx, int ty); - Flt *Spacing() override { return &spacing; } + Flt *Spacing() { return &spacing; } int PayoutTips(Terminal *term); int Print(Terminal *term, int mode); @@ -73,10 +73,10 @@ public: EndDayZone(); // Member Functions - int Type() override { return ZONE_END_DAY; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - int Update(Terminal *term, int update_message, const genericChar* value) override; + int Type() { return ZONE_END_DAY; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Signal(Terminal *term, const genericChar* message); + int Update(Terminal *term, int update_message, const genericChar* value); int EndOfDay(Terminal *term, int force = 0); }; diff --git a/zone/phrase_zone.cc b/zone/phrase_zone.cc index 985d055e..e2ffbbf8 100644 --- a/zone/phrase_zone.cc +++ b/zone/phrase_zone.cc @@ -35,7 +35,7 @@ static const genericChar* PageName[] = { "Days of Week", "Abrv. Days of Week", "Months", "Abrv. Months", "General", "Greetings", "Statements", "Commands", "Errors", "Meal Period Index Names", "Jobs", "Families 1", "Families 2", - "Card Terms","Card Expressions 1", "Card Expressions 2", nullptr }; + "Card Terms","Card Expressions 1", "Card Expressions 2", NULL }; /**** PhraseZone Class ****/ @@ -117,7 +117,7 @@ int PhraseZone::SaveRecord(Terminal *t, int record, int write_file) if (record == 11 || record == 12) { t->SendTranslations(FamilyName); - t->system_data->phrases_changed = time(nullptr); + t->system_data->phrases_changed = time(NULL); } return 0; diff --git a/zone/phrase_zone.hh b/zone/phrase_zone.hh index d6813729..e2ec8f63 100644 --- a/zone/phrase_zone.hh +++ b/zone/phrase_zone.hh @@ -19,7 +19,7 @@ */ #ifndef _PHRASE_ZONE_HH -#define PHRASE_ZONE_HH +#define _PHRASE_ZONE_HH #include "form_zone.hh" @@ -32,12 +32,12 @@ public: PhraseZone(); // Member Functions - int Type() override { return ZONE_PHRASE; } - RenderResult Render(Terminal *t, int update_flag) override; + int Type() { return ZONE_PHRASE; } + RenderResult Render(Terminal *t, int update_flag); - int LoadRecord(Terminal *t, int record) override; - int SaveRecord(Terminal *t, int record, int write_file) override; - int RecordCount(Terminal *t) override; + int LoadRecord(Terminal *t, int record); + int SaveRecord(Terminal *t, int record, int write_file); + int RecordCount(Terminal *t); }; #endif diff --git a/zone/pos_zone.cc b/zone/pos_zone.cc index 4e30633d..da91386e 100644 --- a/zone/pos_zone.cc +++ b/zone/pos_zone.cc @@ -136,7 +136,7 @@ int ConvertAppear(int appear, Uchar &f, Uchar &t) Zone *NewPosZone(int type) { - Zone *pNewZone = nullptr; + Zone *pNewZone = NULL; switch (type) { // General Zone Types @@ -386,7 +386,7 @@ Zone *NewPosZone(int type) break; } - if (pNewZone == nullptr) + if (pNewZone == NULL) { char str[64]; vt_safe_string::safe_format(str, 64, "Creation of PosZone object type %d failed", type); @@ -399,7 +399,7 @@ Zone *NewPosZone(int type) Page *NewPosPage() { PosPage *p = new PosPage; - if (p == nullptr) + if (p == NULL) ReportError("Creation of PosPage object failed"); return p; @@ -419,11 +419,11 @@ std::unique_ptr PosZone::Copy() int PosZone::CanSelect(Terminal *t) { - if (page == nullptr) + if (page == NULL) return 1; Employee *e = t->user; - if (e == nullptr) + if (e == NULL) return 0; if (page->id < 0 && !e->CanEditSystem() && Type() != ZONE_ORDER_ENTRY && Type() != ZONE_TENDER) @@ -433,11 +433,11 @@ int PosZone::CanSelect(Terminal *t) int PosZone::CanEdit(Terminal *t) { - if (page == nullptr) + if (page == NULL) return 1; Employee *e = t->user; - if (e == nullptr) + if (e == NULL) return 0; if (page->id < 0 && !e->CanEditSystem() && Type() != ZONE_ORDER_ENTRY && Type() != ZONE_TENDER) @@ -448,7 +448,7 @@ int PosZone::CanEdit(Terminal *t) int PosZone::CanCopy(Terminal *t) { Employee *e = t->user; - if (e == nullptr) + if (e == NULL) return 0; if (page->id < 0 && !e->CanEditSystem() && Type() != ZONE_ORDER_ENTRY && Type() != ZONE_TENDER) @@ -689,7 +689,7 @@ std::unique_ptr PosPage::Copy() p->default_color[i] = default_color[i]; } - for (Zone *z = ZoneList(); z != nullptr; z = z->next) + for (Zone *z = ZoneList(); z != NULL; z = z->next) { FILE *debugCopy = fopen("/tmp/viewtouch_debug.log", "a"); if (debugCopy) { @@ -832,7 +832,7 @@ int PosPage::Read(InputDataFile &infile, int version) infile.Read(z_type); Zone *z = NewPosZone(z_type); - if (z == nullptr) + if (z == NULL) { vt_safe_string::safe_format(str, 256, "Error in creating touch zone type %d", type); ReportError(str); @@ -881,7 +881,7 @@ int PosPage::Write(OutputDataFile &df, int version) // Write all touch zones error += df.Write(ZoneCount(), 1); - for (Zone *z = ZoneList(); z != nullptr; z = z->next) + for (Zone *z = ZoneList(); z != NULL; z = z->next) { error += df.Write(z->Type()); error += z->Write(df, version); diff --git a/zone/pos_zone.hh b/zone/pos_zone.hh index 1c502046..7e2ab76b 100644 --- a/zone/pos_zone.hh +++ b/zone/pos_zone.hh @@ -18,8 +18,8 @@ * Definition of zone types & other zone data */ -#ifndef POS_ZONE_HH -#define POS_ZONE_HH +#ifndef _POS_ZONE_HH +#define _POS_ZONE_HH #include "zone.hh" @@ -27,94 +27,92 @@ /**** Definitions ****/ #define ZONE_VERSION 29 -// Zone Types (converted from macros to enum constants) -enum ZoneType : std::uint8_t { - ZONE_UNDEFINED = 0, // type not defined - ZONE_STANDARD = 1, // button with message & jump - ZONE_ITEM = 2, // order menu item - ZONE_CONDITIONAL = 3, // work if conditions are met - ZONE_TENDER = 4, // tender payment type button - ZONE_TABLE = 5, // table status/selection - ZONE_COMMENT = 6, // only seen by superuser - ZONE_QUALIFIER = 7, // qualifier: no, extra, lite - ZONE_TOGGLE = 8, // button with toggleing text/message - ZONE_SIMPLE = 9, // button with only jump - ZONE_SWITCH = 10, // settings selection button +// Zone Types +#define ZONE_UNDEFINED 0 // type not defined +#define ZONE_STANDARD 1 // button with message & jump +#define ZONE_ITEM 2 // order menu item +#define ZONE_CONDITIONAL 3 // work if conditions are met +#define ZONE_TENDER 4 // tender payment type button +#define ZONE_TABLE 5 // table status/selection +#define ZONE_COMMENT 6 // only seen by superuser +#define ZONE_QUALIFIER 7 // qualifier: no, extra, lite +#define ZONE_TOGGLE 8 // button with toggleing text/message +#define ZONE_SIMPLE 9 // button with only jump +#define ZONE_SWITCH 10 // settings selection button - ZONE_LOGIN = 20, // takes user id for login - ZONE_COMMAND = 21, // system command/status - ZONE_GUEST_COUNT = 23, // enter the number of guests - ZONE_LOGOUT = 24, // user logout stuff - ZONE_CHECK_LIST = 31, // show open checks - ZONE_ORDER_ENTRY = 30, // show current menu order - ZONE_ORDER_PAGE = 51, // page change on order entry window - ZONE_ORDER_FLOW = 64, // order start/index/continue - ZONE_ORDER_ADD = 83, // increase order button on order entry page - ZONE_ORDER_DELETE = 84, // delete/rebuild button on order entry page - ZONE_ORDER_DISPLAY = 85, // kitchen work order display - ZONE_ORDER_COMMENT = 104, // add comment button on order entry page - ZONE_PAYMENT_ENTRY = 32, // show/allow payments for check - ZONE_USER_EDIT = 33, // show/edit users - ZONE_SETTINGS = 34, // edit general system variables - ZONE_TAX_SETTINGS = 35, // tax and royalty settings - ZONE_DEVELOPER = 36, // developer application settings - ZONE_TENDER_SET = 37, // tender selection & settings - ZONE_TAX_SET = 38, // tax specifications - ZONE_MONEY_SET = 39, // currency specifications - ZONE_CC_SETTINGS = 40, // credit/charge card settings - ZONE_CC_MSG_SETTINGS = 41, // credit/charge card messages - ZONE_REPORT = 50, // super report zone - ZONE_SCHEDULE = 52, // employee scheduling - ZONE_PRINT_TARGET = 53, // family printer destinations - ZONE_SPLIT_CHECK = 54, // check splitting zone - ZONE_DRAWER_MANAGE = 55, // Drawer pulling/balancing - ZONE_HARDWARE = 56, // terminal & printer setup/settings/status - ZONE_TIME_SETTINGS = 57, // store hours/shifts - ZONE_TABLE_ASSIGN = 58, // transfer tables/checks between servers - ZONE_CHECK_DISPLAY = 59, // display multiple checks on the screen - ZONE_KILL_SYSTEM = 61, // system termination - ZONE_PAYOUT = 62, // cash payout system - ZONE_DRAWER_ASSIGN = 63, // drawer assignment - ZONE_SEARCH = 66, // search for word though records - ZONE_SPLIT_KITCHEN = 67, // split kitchen terminal assignment - ZONE_END_DAY = 68, // end of day management - ZONE_READ = 69, // reading & displaying text files - ZONE_JOB_SECURITY = 70, // job secuity settings - ZONE_INVENTORY = 71, // raw product inventory - ZONE_RECIPE = 72, // recipes using raw products - ZONE_VENDOR = 73, // raw product suppliers - ZONE_LABOR = 74, // labor management - ZONE_ITEM_LIST = 75, // list all sales items - ZONE_INVOICE = 76, // invoice entry/listing - ZONE_PHRASE = 77, // phrase translation/replacement - ZONE_ITEM_TARGET = 78, // item printer target - ZONE_RECEIPT_SET = 79, // printed receipt settings - ZONE_MERCHANT = 80, // merchant info for credit authorize - ZONE_LICENSE = 81, // viewtouch pos license setup - ZONE_ACCOUNT = 82, // chart of accounts list/edit - ZONE_CHART = 86, // spreadsheet like data display - ZONE_VIDEO_TARGET = 87, // for Kitchen Video, which food types get displayed - ZONE_EXPENSE = 88, // paying expense from revenue - ZONE_STATUS_BUTTON = 89, // for error messages and other things - ZONE_CDU = 90, // CDU string entry and modification - ZONE_RECEIPTS = 91, // Strings for receipt headers and footers - ZONE_CUSTOMER_INFO = 92, // For editing customer info (name, address, et al) - ZONE_CHECK_EDIT = 93, // For editing check info like Delivery Date. - ZONE_CREDITCARD_LIST = 94, // For managing exceptions, refunds, and voids - ZONE_EXPIRE_MSG = 95, // For setting the expiration message - ZONE_REVENUE_GROUPS = 96, // Revenue group settings for menu families - ZONE_IMAGE_BUTTON = 97, // button with user-selectable image - ZONE_CALCULATION_SETTINGS = 110, // calculation settings (multiply, add/subtract) - ZONE_ITEM_NORMAL = 98, // menu item button - ZONE_ITEM_MODIFIER = 99, // modifier button - ZONE_ITEM_METHOD = 100, // non-tracking modifier button - ZONE_ITEM_SUBSTITUTE = 101, // menu item + substitute button - ZONE_ITEM_POUND = 102, // priced by weight button - ZONE_ITEM_ADMISSION = 103, // event admission button - ZONE_INDEX_TAB = 108, // index tab button (only on Index pages, inherited by Menu Item pages) - ZONE_LANGUAGE_BUTTON = 109, // language selection button - ZONE_CLEAR_SYSTEM = 107 // clear system with countdown -}; +#define ZONE_LOGIN 20 // takes user id for login +#define ZONE_COMMAND 21 // system command/status +#define ZONE_GUEST_COUNT 23 // enter the number of guests +#define ZONE_LOGOUT 24 // user logout stuff +#define ZONE_CHECK_LIST 31 // show open checks +#define ZONE_ORDER_ENTRY 30 // show current menu order +#define ZONE_ORDER_PAGE 51 // page change on order entry window +#define ZONE_ORDER_FLOW 64 // order start/index/continue +#define ZONE_ORDER_ADD 83 // increase order button on order entry page +#define ZONE_ORDER_DELETE 84 // delete/rebuild button on order entry page +#define ZONE_ORDER_DISPLAY 85 // kitchen work order display +#define ZONE_ORDER_COMMENT 104 // add comment button on order entry page +#define ZONE_PAYMENT_ENTRY 32 // show/allow payments for check +#define ZONE_USER_EDIT 33 // show/edit users +#define ZONE_SETTINGS 34 // edit general system variables +#define ZONE_TAX_SETTINGS 35 // tax and royalty settings +#define ZONE_DEVELOPER 36 // developer application settings +#define ZONE_TENDER_SET 37 // tender selection & settings +#define ZONE_TAX_SET 38 // tax specifications +#define ZONE_MONEY_SET 39 // currency specifications +#define ZONE_CC_SETTINGS 40 // credit/charge card settings +#define ZONE_CC_MSG_SETTINGS 41 // credit/charge card messages +#define ZONE_REPORT 50 // super report zone +#define ZONE_SCHEDULE 52 // employee scheduling +#define ZONE_PRINT_TARGET 53 // family printer destinations +#define ZONE_SPLIT_CHECK 54 // check splitting zone +#define ZONE_DRAWER_MANAGE 55 // Drawer pulling/balancing +#define ZONE_HARDWARE 56 // terminal & printer setup/settings/status +#define ZONE_TIME_SETTINGS 57 // store hours/shifts +#define ZONE_TABLE_ASSIGN 58 // transfer tables/checks between servers +#define ZONE_CHECK_DISPLAY 59 // display multiple checks on the screen +#define ZONE_KILL_SYSTEM 61 // system termination +#define ZONE_PAYOUT 62 // cash payout system +#define ZONE_DRAWER_ASSIGN 63 // drawer assignment +#define ZONE_SEARCH 66 // search for word though records +#define ZONE_SPLIT_KITCHEN 67 // split kitchen terminal assignment +#define ZONE_END_DAY 68 // end of day management +#define ZONE_READ 69 // reading & displaying text files +#define ZONE_JOB_SECURITY 70 // job secuity settings +#define ZONE_INVENTORY 71 // raw product inventory +#define ZONE_RECIPE 72 // recipes using raw products +#define ZONE_VENDOR 73 // raw product suppliers +#define ZONE_LABOR 74 // labor management +#define ZONE_ITEM_LIST 75 // list all sales items +#define ZONE_INVOICE 76 // invoice entry/listing +#define ZONE_PHRASE 77 // phrase translation/replacement +#define ZONE_ITEM_TARGET 78 // item printer target +#define ZONE_RECEIPT_SET 79 // printed receipt settings +#define ZONE_MERCHANT 80 // merchant info for credit authorize +#define ZONE_LICENSE 81 // viewtouch pos license setup +#define ZONE_ACCOUNT 82 // chart of accounts list/edit +#define ZONE_CHART 86 // spreadsheet like data display +#define ZONE_VIDEO_TARGET 87 // for Kitchen Video, which food types get displayed +#define ZONE_EXPENSE 88 // paying expense from revenue +#define ZONE_STATUS_BUTTON 89 // for error messages and other things +#define ZONE_CDU 90 // CDU string entry and modification +#define ZONE_RECEIPTS 91 // Strings for receipt headers and footers +#define ZONE_CUSTOMER_INFO 92 // For editing customer info (name, address, et al) +#define ZONE_CHECK_EDIT 93 // For editing check info like Delivery Date. +#define ZONE_CREDITCARD_LIST 94 // For managing exceptions, refunds, and voids +#define ZONE_EXPIRE_MSG 95 // For setting the expiration message +#define ZONE_REVENUE_GROUPS 96 // Revenue group settings for menu families +#define ZONE_IMAGE_BUTTON 97 // button with user-selectable image +#define ZONE_CALCULATION_SETTINGS 110 // calculation settings (multiply, add/subtract) +#define ZONE_ITEM_NORMAL 98 // menu item button +#define ZONE_ITEM_MODIFIER 99 // modifier button +#define ZONE_ITEM_METHOD 100 // non-tracking modifier button +#define ZONE_ITEM_SUBSTITUTE 101 // menu item + substitute button +#define ZONE_ITEM_POUND 102 // priced by weight button +#define ZONE_ITEM_ADMISSION 103 // event admission button +#define ZONE_INDEX_TAB 108 // index tab button (only on Index pages, inherited by Menu Item pages) +#define ZONE_LANGUAGE_BUTTON 109 // language selection button +#define ZONE_CLEAR_SYSTEM 107 // clear system with countdown /**** Types ****/ class PosZone : public Zone @@ -124,16 +122,16 @@ class PosZone : public Zone public: // Member Functions - int Type() override { return ZONE_UNDEFINED; } - std::unique_ptr Copy() override; + virtual int Type() { return ZONE_UNDEFINED; } + virtual std::unique_ptr Copy(); - int CanSelect(Terminal *t) override; - int CanEdit(Terminal *t) override; - int CanCopy(Terminal *t) override; - int SetSize(Terminal *t, int width, int height) override; - int SetPosition(Terminal *t, int pos_x, int pos_y) override; - int Read(InputDataFile &df, int version) override; - int Write(OutputDataFile &df, int version) override; + virtual int CanSelect(Terminal *t); + virtual int CanEdit(Terminal *t); + virtual int CanCopy(Terminal *t); + virtual int SetSize(Terminal *t, int width, int height); + virtual int SetPosition(Terminal *t, int pos_x, int pos_y); + virtual int Read(InputDataFile &df, int version); + virtual int Write(OutputDataFile &df, int version); Str *ImagePath() { return &image_path; } }; @@ -142,9 +140,9 @@ class PosPage : public Page { public: // Member Functions - std::unique_ptr Copy() override; - int Read(InputDataFile &df, int version) override; - int Write(OutputDataFile &df, int version) override; + virtual std::unique_ptr Copy(); + virtual int Read(InputDataFile &df, int version); + virtual int Write(OutputDataFile &df, int version); }; diff --git a/zone/printer_zone.cc b/zone/printer_zone.cc index 63cd7a16..74a720ef 100644 --- a/zone/printer_zone.cc +++ b/zone/printer_zone.cc @@ -127,7 +127,7 @@ class TermObj : public ZoneObject // Member Functions bool IsValid(Terminal *t); - int Render(Terminal *t) override; + int Render(Terminal *t); }; // Constructor @@ -186,8 +186,8 @@ class KitchenObj : public ZoneObject KitchenObj(Control *db, int no); // Member Functions - int Layout(Terminal *t, int lx, int ly, int lw, int lh) override; - int Render(Terminal *t) override; + int Layout(Terminal *t, int lx, int ly, int lw, int lh); + int Render(Terminal *t); }; // Constructor @@ -195,7 +195,7 @@ KitchenObj::KitchenObj(Control *db, int no) { number = no; - for (Terminal *t = db->TermList(); t != nullptr; t = t->next) + for (Terminal *t = db->TermList(); t != NULL; t = t->next) if (t->kitchen == no) terms.Add(new TermObj(t)); } @@ -257,7 +257,7 @@ int KitchenObj::Render(Terminal *t) // Member Functions RenderResult SplitKitchenZone::Render(Terminal *t, int update_flag) { - RenderZone(t, nullptr, update_flag); + RenderZone(t, NULL, update_flag); if (update_flag) { kitchens.Purge(); @@ -274,7 +274,7 @@ RenderResult SplitKitchenZone::Render(Terminal *t, int update_flag) SignalResult SplitKitchenZone::Signal(Terminal *t, const genericChar* message) { - static const genericChar* commands[] = {"cancel", nullptr}; + static const genericChar* commands[] = {"cancel", NULL}; int idx = CompareList(message, commands); switch (idx) diff --git a/zone/printer_zone.hh b/zone/printer_zone.hh index 6067831f..9cd308b6 100644 --- a/zone/printer_zone.hh +++ b/zone/printer_zone.hh @@ -19,7 +19,7 @@ */ #ifndef _PRINTER_ZONE_HH -#define PRINTER_ZONE_HH +#define _PRINTER_ZONE_HH #include "form_zone.hh" #include "zone_object.hh" @@ -35,12 +35,12 @@ public: PrintTargetZone(); // Member Functions - int Type() override { return ZONE_PRINT_TARGET; } + int Type() { return ZONE_PRINT_TARGET; } int AddFields(); - RenderResult Render(Terminal *t, int update_flag) override; + RenderResult Render(Terminal *t, int update_flag); - int LoadRecord(Terminal *t, int record) override; - int SaveRecord(Terminal *t, int record, int write_file) override; + int LoadRecord(Terminal *t, int record); + int SaveRecord(Terminal *t, int record, int write_file); }; class SplitKitchenZone : public PosZone @@ -49,11 +49,11 @@ class SplitKitchenZone : public PosZone public: // Member Functions - int Type() override { return ZONE_SPLIT_KITCHEN; } - RenderResult Render(Terminal *t, int update_flag) override; - SignalResult Signal(Terminal *t, const genericChar* message) override; - SignalResult Touch(Terminal *t, int tx, int ty) override; - int ZoneStates() override { return 1; } + int Type() { return ZONE_SPLIT_KITCHEN; } + RenderResult Render(Terminal *t, int update_flag); + SignalResult Signal(Terminal *t, const genericChar* message); + SignalResult Touch(Terminal *t, int tx, int ty); + int ZoneStates() { return 1; } int MoveTerms(Terminal *t, int no); }; @@ -65,11 +65,11 @@ public: ReceiptSetZone(); // Member Functions - int Type() override { return ZONE_RECEIPT_SET; } - RenderResult Render(Terminal *t, int update_flag) override; + int Type() { return ZONE_RECEIPT_SET; } + RenderResult Render(Terminal *t, int update_flag); - int LoadRecord(Terminal *t, int record) override; - int SaveRecord(Terminal *t, int record, int write_file) override; + int LoadRecord(Terminal *t, int record); + int SaveRecord(Terminal *t, int record, int write_file); }; #endif diff --git a/zone/report_zone.cc b/zone/report_zone.cc index 5882af2f..355279f0 100644 --- a/zone/report_zone.cc +++ b/zone/report_zone.cc @@ -48,15 +48,15 @@ ReportZone::ReportZone() min_size_x = 10; min_size_y = 5; report_type = REPORT_SERVER; - report = nullptr; - temp_report = nullptr; + report = NULL; + temp_report = NULL; lines_shown = 0; page = 0; columns = 1; print = RP_PRINT_LOCAL; printer_dest = RP_PRINT_LOCAL; period_view = 0; - period_fiscal = nullptr; + period_fiscal = NULL; spacing = 1; check_disp_num = 0; video_target = PRINTER_DEFAULT; @@ -84,7 +84,7 @@ RenderResult ReportZone::Render(Terminal *term, int update_flag) Report *r = temp_report; // allow no user signin for kitchen display - if (e == nullptr && report_type != REPORT_CHECK) + if (e == NULL && report_type != REPORT_CHECK) return RENDER_OKAY; if (r) @@ -95,14 +95,14 @@ RenderResult ReportZone::Render(Terminal *term, int update_flag) if (report) delete report; report = r; - temp_report = nullptr; + temp_report = NULL; if (printing_to_printer) { Print(term, printer_dest); printing_to_printer = 0; - if (report != nullptr) + if (report != NULL) delete report; - report = nullptr; + report = NULL; temp_report = new Report(); sys->RoyaltyReport(term, day_start, day_end, term->archive, temp_report, this); return RENDER_OKAY; @@ -117,7 +117,7 @@ RenderResult ReportZone::Render(Terminal *term, int update_flag) if (report) { delete report; - report = nullptr; + report = NULL; // page = 0; // <--- REMOVE THIS LINE! } @@ -129,13 +129,13 @@ RenderResult ReportZone::Render(Terminal *term, int update_flag) period_view = s->default_report_period; page = 0; // <--- Only reset page on NEW - if (term->server == nullptr && s->drawer_mode == DRAWER_SERVER) + if (term->server == NULL && s->drawer_mode == DRAWER_SERVER) term->server = e; // printf("ReportZone::Render() drawer_mode == DRAWER_SERVER\n"); // period_fiscal = &s->sales_start; // period_view = SP_DAY; - period_fiscal = nullptr; + period_fiscal = NULL; period_view = s->default_report_period; if (report_type == REPORT_SALES) { @@ -143,7 +143,7 @@ RenderResult ReportZone::Render(Terminal *term, int update_flag) period_view = SP_DAY; // period_view = s->sales_period; period_fiscal = &s->sales_start; - term->server = nullptr; // sales report defaults to all users + term->server = NULL; // sales report defaults to all users } else if (report_type == REPORT_BALANCE && s->report_start_midnight == 0) @@ -169,13 +169,13 @@ RenderResult ReportZone::Render(Terminal *term, int update_flag) { // printf("ReportZone::Render() report_type == REPORT_ROYALTY\n"); period_view = SP_MONTH; - period_fiscal = nullptr; + period_fiscal = NULL; } else if (report_type == REPORT_AUDITING) { // printf("ReportZone::Render() report_type == REPORT_AUDITING\n"); period_view = SP_DAY; - period_fiscal = nullptr; + period_fiscal = NULL; } } @@ -220,8 +220,8 @@ RenderResult ReportZone::Render(Terminal *term, int update_flag) drawer_list = a->DrawerList(); } - Drawer *d = nullptr; - if (a == nullptr) + Drawer *d = NULL; + if (a == NULL) { if (term->server) d = drawer_list->FindByOwner(term->server, DRAWER_OPEN); @@ -233,7 +233,7 @@ RenderResult ReportZone::Render(Terminal *term, int update_flag) switch (report_type) { case REPORT_DRAWER: - if (term->server == nullptr) + if (term->server == NULL) sys->DrawerSummaryReport(term, drawer_list, check_list, temp_report); else if (d) d->MakeReport(term, check_list, temp_report); @@ -261,7 +261,7 @@ RenderResult ReportZone::Render(Terminal *term, int update_flag) break; case REPORT_DEPOSIT: if (period_view != SP_NONE) - sys->DepositReport(term, day_start, day_end, nullptr, temp_report); + sys->DepositReport(term, day_start, day_end, NULL, temp_report); else sys->DepositReport(term, day_start, day_end, term->archive, temp_report); break; @@ -281,7 +281,7 @@ RenderResult ReportZone::Render(Terminal *term, int update_flag) sys->CustomerDetailReport(term, e, temp_report); break; case REPORT_EXPENSES: - sys->ExpenseReport(term, day_start, day_end, nullptr, temp_report, this); + sys->ExpenseReport(term, day_start, day_end, NULL, temp_report, this); break; case REPORT_ROYALTY: sys->RoyaltyReport(term, day_start, day_end, term->archive, temp_report, this); @@ -299,7 +299,7 @@ RenderResult ReportZone::Render(Terminal *term, int update_flag) if (temp_report && temp_report->is_complete) { report = temp_report; - temp_report = nullptr; + temp_report = NULL; } } @@ -343,7 +343,7 @@ RenderResult ReportZone::DisplayCheckReport(Terminal *term, Report *disp_report) { // This is only for the Kitchen Video reports. Check *disp_check = GetDisplayCheck(term); - if (disp_check != nullptr) + if (disp_check != NULL) { // Check if this specific video target has marked their portion as made int made_for_target = 0; @@ -411,7 +411,7 @@ int ReportZone::IsKitchenCheck(Terminal *term, Check *check) // I don't like huge conditionals ("if (a && b || (c || d)...)"), // so I'm going to break it out into an if-elsif block instead. - if (check == nullptr) + if (check == NULL) retval = 0; else if (check->GetStatus() == CHECK_VOIDED) retval = 0; @@ -512,10 +512,10 @@ int ReportZone::ShowCheck(Terminal *term, Check *check) int vtarget; Order *order; SubCheck *scheck = check->SubList(); - while (!show && (scheck != nullptr)) + while (!show && (scheck != NULL)) { order = scheck->OrderList(); - while (!show && (order != nullptr)) + while (!show && (order != NULL)) { vtarget = order->VideoTarget(settings); if (vtarget == video_target) @@ -533,7 +533,7 @@ int ReportZone::ShowCheck(Terminal *term, Check *check) Check *ReportZone::NextCheck(Check *check, int sort_order) { FnTrace("ReportZone::NextCheck()"); - Check *retcheck = nullptr; + Check *retcheck = NULL; if (sort_order == CHECK_ORDER_OLDNEW) retcheck = check->next; else @@ -549,8 +549,8 @@ Check *ReportZone::NextCheck(Check *check, int sort_order) Check *ReportZone::GetDisplayCheck(Terminal *term) { FnTrace("ReportZone::GetDisplayCheck()"); - Check *checklist = nullptr; - Check *disp_check = nullptr; + Check *checklist = NULL; + Check *disp_check = NULL; int counter = 0; if (term->sortorder == CHECK_ORDER_NEWOLD) @@ -560,7 +560,7 @@ Check *ReportZone::GetDisplayCheck(Terminal *term) if (checklist) { - while ((counter < check_disp_num) && (checklist != nullptr)) + while ((counter < check_disp_num) && (checklist != NULL)) { if (IsKitchenCheck(term, checklist)) { @@ -572,7 +572,7 @@ Check *ReportZone::GetDisplayCheck(Terminal *term) // verify we have a check we want if (!IsKitchenCheck(term, disp_check) || (counter < check_disp_num)) - disp_check = nullptr; + disp_check = NULL; } if (disp_check) @@ -602,10 +602,10 @@ Check *ReportZone::GetCheckByNum(Terminal *term) { FnTrace("ReportZone::GetCheckByNum()"); Check *checkptr = term->system_data->CheckList(); - Check *retcheck = nullptr; + Check *retcheck = NULL; // Steve McConnell would probably hate this: stop when we have no more // checks to look at or when we have a return value - while ((checkptr != nullptr) && (retcheck == nullptr)) + while ((checkptr != NULL) && (retcheck == NULL)) { if (check_disp_num == checkptr->checknum) retcheck = checkptr; @@ -626,12 +626,12 @@ int ReportZone::UndoRecentCheck(Terminal *term) { term->same_signal = 1; Check *currcheck = term->system_data->CheckListEnd(); - Check *lastcheck = nullptr; + Check *lastcheck = NULL; TimeInfo lasttime = term->system_data->start; lasttime.AdjustYears(-1); // Look for the most recent check that was served by THIS video target - while (currcheck != nullptr) + while (currcheck != NULL) { // Check if this check was served by the current video target int served_by_this_target = 0; @@ -659,7 +659,7 @@ int ReportZone::UndoRecentCheck(Terminal *term) currcheck = currcheck->fore; } - if (lastcheck != nullptr) + if (lastcheck != NULL) { // Recall the order for THIS video target only if (video_target == PRINTER_BAR1 || video_target == PRINTER_BAR2) @@ -681,7 +681,7 @@ int ReportZone::UndoRecentCheck(Terminal *term) // Clear the SHOWN flag since we're bringing it back to display lastcheck->flags &= ~CF_SHOWN; // Clear the ORDER_SHOWN status to bring it back to video display - lastcheck->ClearOrderStatus(nullptr, ORDER_SHOWN); + lastcheck->ClearOrderStatus(NULL, ORDER_SHOWN); // Save the changes lastcheck->Save(); @@ -748,17 +748,17 @@ SignalResult ReportZone::Signal(Terminal *t, const genericChar* message) "ccdetailsdone", "ccrefund", "ccvoids", "ccrefunds", "ccexceptions", "ccfinish", "ccfinish2 ", "ccfinish3 ", "ccprocessed", "ccrefundamount ", "ccvoidttid ", - "zero captured tips", "bump", nullptr}; + "zero captured tips", "bump", NULL}; Employee *e = t->user; System *sys = t->system_data; Settings *s = &sys->settings; - TenKeyDialog *tkdialog = nullptr; - CreditCardDialog *ccdialog = nullptr; - GetTextDialog *gtdialog = nullptr; - const char* batchnum = nullptr; + TenKeyDialog *tkdialog = NULL; + CreditCardDialog *ccdialog = NULL; + GetTextDialog *gtdialog = NULL; + const char* batchnum = NULL; - if (e == nullptr) + if (e == NULL) return SIGNAL_IGNORED; int idx = CompareListN(commands, message); @@ -787,7 +787,7 @@ SignalResult ReportZone::Signal(Terminal *t, const genericChar* message) Zone *z = zcur; while (1) { - if (z == nullptr) + if (z == NULL) z = t->page->ZoneList(); // (re)start at top of list else z = z->next; @@ -807,7 +807,7 @@ SignalResult ReportZone::Signal(Terminal *t, const genericChar* message) AdjustPeriod(ref, period_view, 1); if (t->archive) t->archive = t->archive->next; - else if (t->archive == nullptr) + else if (t->archive == NULL) t->archive = sys->ArchiveList(); } Draw(t, 1); @@ -835,7 +835,7 @@ SignalResult ReportZone::Signal(Terminal *t, const genericChar* message) Zone *z = zcur; while (1) { - if (z == nullptr) + if (z == NULL) z = t->page->ZoneListEnd(); // (re)start at end of list else z = z->fore; @@ -855,7 +855,7 @@ SignalResult ReportZone::Signal(Terminal *t, const genericChar* message) AdjustPeriod(ref, period_view, -1); if (t->archive) t->archive = t->archive->fore; - else if (t->archive == nullptr) + else if (t->archive == NULL) t->archive = sys->ArchiveListEnd(); } Draw(t, 1); @@ -955,7 +955,7 @@ SignalResult ReportZone::Signal(Terminal *t, const genericChar* message) if (strlen(&message[10]) > 0) batchnum = &message[10]; else - batchnum = nullptr; + batchnum = NULL; if (t->CC_Settle(batchnum) >= 0) { sys->non_eod_settle = 0; @@ -1020,7 +1020,7 @@ SignalResult ReportZone::Signal(Terminal *t, const genericChar* message) t->OpenDialog(gtdialog); return SIGNAL_OKAY; case 30: // ccfinish2 - if (t->credit == nullptr) + if (t->credit == NULL) { t->credit = new Credit(); if (t->GetSettings()->authorize_method == CCAUTH_MAINSTREET) @@ -1032,17 +1032,17 @@ SignalResult ReportZone::Signal(Terminal *t, const genericChar* message) } return SIGNAL_OKAY; case 31: // ccfinish3 - if (t->credit != nullptr) + if (t->credit != NULL) { t->credit->Amount(atoi(&message[10])); t->CC_GetFinalApproval(); } return SIGNAL_OKAY; case 32: // ccprocessed - if (t->credit != nullptr && t->credit->IsRefunded(1) == 0) + if (t->credit != NULL && t->credit->IsRefunded(1) == 0) { sys->cc_exception_db->Add(t, t->credit); - t->credit = nullptr; + t->credit = NULL; sys->cc_finish = sys->cc_exception_db->CreditListEnd(); sys->cc_report_type = CC_REPORT_FINISH; Draw(t, 1); @@ -1050,7 +1050,7 @@ SignalResult ReportZone::Signal(Terminal *t, const genericChar* message) return SIGNAL_OKAY; case 33: // ccrefundamount // got refund amount for Credit Card Report. - t->credit = nullptr; + t->credit = NULL; t->auth_amount = atoi(&message[15]); t->auth_action = AUTH_REFUND; t->auth_message = REFUND_MSG; @@ -1077,7 +1077,7 @@ SignalResult ReportZone::Signal(Terminal *t, const genericChar* message) default: if (strncmp(message, "search ", 7) == 0) { - e = sys->user_db.NameSearch(&message[7], nullptr); + e = sys->user_db.NameSearch(&message[7], NULL); if (e) { t->server = e; @@ -1104,7 +1104,7 @@ SignalResult ReportZone::Signal(Terminal *t, const genericChar* message) SignalResult ReportZone::Touch(Terminal *term, int tx, int ty) { FnTrace("ReportZone::Touch()"); - if (report == nullptr) + if (report == NULL) return SIGNAL_IGNORED; int new_page = page; @@ -1157,7 +1157,7 @@ SignalResult ReportZone::Touch(Terminal *term, int tx, int ty) SignalResult ReportZone::Mouse(Terminal *term, int action, int mx, int my) { FnTrace("ReportZone::Mouse()"); - if (!(action & MOUSE_PRESS) || report == nullptr) + if (!(action & MOUSE_PRESS) || report == NULL) return SIGNAL_IGNORED; int new_page = page; @@ -1265,7 +1265,7 @@ SignalResult ReportZone::ToggleCheckReport(Terminal *term) reportcheck->flags |= CF_KITCHEN_SERVED; } reportcheck->flags |= CF_SHOWN; - reportcheck->SetOrderStatus(nullptr, ORDER_SHOWN); + reportcheck->SetOrderStatus(NULL, ORDER_SHOWN); } update = 1; reportcheck->Save(); @@ -1281,30 +1281,34 @@ SignalResult ReportZone::ToggleCheckReport(Terminal *term) SignalResult ReportZone::Keyboard(Terminal *t, int my_key, int state) { FnTrace("ReportZone::Keyboard()"); - if (report == nullptr) + if (report == NULL) return SIGNAL_IGNORED; // automatically accept check number (in ascii) as keyboard shortcut to bump if (my_key == check_disp_num + '0') return ToggleCheckReport(t); - int delta = 0; - if (my_key == 16) // page up - delta = -1; - else if (my_key == 14) // page down - delta = 1; - else if (my_key == 118 && debug_mode) // 'v' - { - TenKeyDialog *tk = new TenKeyDialog(GlobalTranslate("Enter TTID"), "ccvoidttid", 0); - t->OpenDialog(tk); - return SIGNAL_TERMINATE; - } - else + int new_page = page; + switch (my_key) { + case 16: // page up + --new_page; + break; + case 14: // page down + ++new_page; + break; + case 118: // v + if (debug_mode) + { + TenKeyDialog *tk = new TenKeyDialog(GlobalTranslate("Enter TTID"), "ccvoidttid", 0); + t->OpenDialog(tk); + return SIGNAL_TERMINATE; + } + break; + default: return SIGNAL_IGNORED; } - int new_page = page + delta; int max_page = report->max_pages; if (new_page >= max_page) new_page = 0; @@ -1339,7 +1343,7 @@ int ReportZone::Update(Terminal *t, int update_message, const genericChar* value } Report *r = report; - if (r == nullptr) + if (r == NULL) return 0; if ((update_message & r->update_flag) && r->is_complete) @@ -1380,12 +1384,12 @@ int ReportZone::Print(Terminal *t, int print_mode) return 0; Employee *e = t->user; - if (e == nullptr || report == nullptr) + if (e == NULL || report == NULL) return 1; Printer *p1 = t->FindPrinter(PRINTER_RECEIPT); Printer *p2 = t->FindPrinter(PRINTER_REPORT); - if (p1 == nullptr && p2 == nullptr) + if (p1 == NULL && p2 == NULL) return 1; // If we have RP_ASK and there are two different printers, ask. @@ -1401,25 +1405,25 @@ int ReportZone::Print(Terminal *t, int print_mode) printer_dest = print_mode; Printer *p = p1; - if ((print_mode == RP_PRINT_REPORT && p2) || p1 == nullptr) + if ((print_mode == RP_PRINT_REPORT && p2) || p1 == NULL) p = p2; - if (p == nullptr) + if (p == NULL) return 1; if (report_type == REPORT_ROYALTY && printing_to_printer == 0) { System *sys = t->system_data; printing_to_printer = 1; - if (report != nullptr) + if (report != NULL) { delete report; - report = nullptr; + report = NULL; } - if (temp_report != nullptr) + if (temp_report != NULL) { delete temp_report; - temp_report = nullptr; + temp_report = NULL; } temp_report = new Report; temp_report->max_width = p->MaxWidth(); @@ -1531,15 +1535,19 @@ SignalResult ReadZone::Touch(Terminal *t, int tx, int ty) SignalResult ReadZone::Keyboard(Terminal *t, int my_key, int state) { FnTrace("ReadZone::Keyboard()"); - int delta = 0; - if (my_key == 16) // page up - delta = -1; - else if (my_key == 14) // page down - delta = 1; - else + int new_page = page; + switch (my_key) + { + case 16: // page up + --new_page; + break; + case 14: // page down + ++new_page; + break; + default: return SIGNAL_IGNORED; + } - int new_page = page + delta; int max_page = report.max_pages; if (new_page >= max_page) new_page = 0; diff --git a/zone/report_zone.hh b/zone/report_zone.hh index b2ae10a1..ff98cdb7 100644 --- a/zone/report_zone.hh +++ b/zone/report_zone.hh @@ -18,8 +18,8 @@ * Definition of report information display zone */ -#ifndef REPORT_ZONE_HH -#define REPORT_ZONE_HH +#ifndef _REPORT_ZONE_HH +#define _REPORT_ZONE_HH #include "layout_zone.hh" #include "report.hh" @@ -57,12 +57,12 @@ public: // Constructor ReportZone(); // Destructor - ~ReportZone() override; + ~ReportZone(); // Member Functions - int Type() override { return ZONE_REPORT; } - RenderResult Render(Terminal *t, int update_flag) override; - int ZoneStates() override { return 2; } + int Type() { return ZONE_REPORT; } + RenderResult Render(Terminal *t, int update_flag); + int ZoneStates() { return 2; } RenderResult DisplayCheckReport(Terminal *term, Report *sel_report); int IsKitchenCheck(Terminal *term, Check *check); int ShowCheck(Terminal *term, Check *check); @@ -70,19 +70,19 @@ public: Check *NextCheck(Check *check, int sort_order); Check *GetDisplayCheck(Terminal *term); Check *GetCheckByNum(Terminal *term); - SignalResult Signal(Terminal *t, const genericChar* message) override; - SignalResult Touch(Terminal *t, int tx, int ty) override; - SignalResult Mouse(Terminal *t, int action, int mx, int my) override; + SignalResult Signal(Terminal *t, const genericChar* message); + SignalResult Touch(Terminal *t, int tx, int ty); + SignalResult Mouse(Terminal *t, int action, int mx, int my); SignalResult ToggleCheckReport(Terminal *term); - SignalResult Keyboard(Terminal *t, int key, int state) override; - int Update(Terminal *t, int update_message, const genericChar* value) override; - int State(Terminal *term) override; - int *ReportType() override { return &report_type; } - int *CheckDisplayNum() override { return &check_disp_num; } - int *VideoTarget() override { return &video_target; } - int *ReportPrint() override { return &print; } - Flt *Spacing() override { return &spacing; } - int *Columns() override { return &columns; } + SignalResult Keyboard(Terminal *t, int key, int state); + int Update(Terminal *t, int update_message, const genericChar* value); + int State(Terminal *term); + int *ReportType() { return &report_type; } + int *CheckDisplayNum() { return &check_disp_num; } + int *VideoTarget() { return &video_target; } + int *ReportPrint() { return &print; } + Flt *Spacing() { return &spacing; } + int *Columns() { return &columns; } int Page(int new_page) { int old_page = page; page = new_page; return old_page; } int BlinkState() { return blink_state; } @@ -107,13 +107,13 @@ public: ReadZone(); // Member Functions - int Type() override { return ZONE_READ; } - RenderResult Render(Terminal *t, int update_flag) override; - SignalResult Signal(Terminal *t, const genericChar* message) override; - SignalResult Touch(Terminal *t, int tx, int ty) override; - SignalResult Keyboard(Terminal *t, int key, int state) override; + int Type() { return ZONE_READ; } + RenderResult Render(Terminal *t, int update_flag); + SignalResult Signal(Terminal *t, const genericChar* message); + SignalResult Touch(Terminal *t, int tx, int ty); + SignalResult Keyboard(Terminal *t, int key, int state); - Str *FileName() override { return &filename; } + Str *FileName() { return &filename; } }; #endif diff --git a/zone/report_zone_quickbooks.cc b/zone/report_zone_quickbooks.cc index 825264e9..76334f2f 100644 --- a/zone/report_zone_quickbooks.cc +++ b/zone/report_zone_quickbooks.cc @@ -9,14 +9,14 @@ SignalResult ReportZone::QuickBooksExport(Terminal *term) { FnTrace("ReportZone::QuickBooksExport()"); Employee *e = term->user; - if (e == nullptr) + if (e == NULL) return SIGNAL_IGNORED; // Create QuickBooks CSV printer using settings path Settings *settings = term->GetSettings(); PrinterQuickBooksCSV *qb_printer = new PrinterQuickBooksCSV("", 0, settings->quickbooks_export_path.Value(), TARGET_QUICKBOOKS_CSV); - if (qb_printer == nullptr) + if (qb_printer == NULL) { // Use printf for error message since Terminal doesn't have Error method printf("Failed to create QuickBooks export printer\n"); diff --git a/zone/search_zone.cc b/zone/search_zone.cc index d4d8b405..9a26df96 100644 --- a/zone/search_zone.cc +++ b/zone/search_zone.cc @@ -62,7 +62,7 @@ SignalResult SearchZone::Signal(Terminal *term, const genericChar* message) { FnTrace("SearchZone::Signal()"); static const genericChar* commands[] = - {"nextsearch", "backspace", "clear", nullptr}; + {"nextsearch", "backspace", "clear", NULL}; unsigned int bufflen = strlen(buffer); genericChar tbuff[STRLENGTH]; SignalResult retval = SIGNAL_IGNORED; @@ -141,6 +141,8 @@ SignalResult SearchZone::Keyboard(Terminal *term, int my_key, int state) term->Signal(str, group_id); return SIGNAL_END; case 13: // return + Draw(term, 1); + return SIGNAL_END; case 27: // escape (cancel) Draw(term, 1); return SIGNAL_END; diff --git a/zone/search_zone.hh b/zone/search_zone.hh index 4c1dd834..380d8e8a 100644 --- a/zone/search_zone.hh +++ b/zone/search_zone.hh @@ -18,7 +18,7 @@ */ #ifndef _SEARCH_ZONE_HH -#define SEARCH_ZONE_HH +#define _SEARCH_ZONE_HH #include "layout_zone.hh" @@ -34,13 +34,13 @@ public: SearchZone(); // Member Functions - int Type() override { return ZONE_SEARCH; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - SignalResult Keyboard(Terminal *term, int key, int state) override; - int LoseFocus(Terminal *term, Zone *newfocus) override; - int ZoneStates() override { return 2; } + int Type() { return ZONE_SEARCH; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Signal(Terminal *term, const genericChar* message); + SignalResult Touch(Terminal *term, int tx, int ty); + SignalResult Keyboard(Terminal *term, int key, int state); + int LoseFocus(Terminal *term, Zone *newfocus); + int ZoneStates() { return 2; } }; #endif diff --git a/zone/settings_zone.cc b/zone/settings_zone.cc index f741b69d..a04f77d7 100644 --- a/zone/settings_zone.cc +++ b/zone/settings_zone.cc @@ -50,16 +50,16 @@ * SwitchZone Class ********************************************************************/ -static const genericChar* PasswordName[] = {"No", "Managers Only", "Everyone", nullptr}; +static const genericChar* PasswordName[] = {"No", "Managers Only", "Everyone", NULL}; static int PasswordValue[] = {PW_NONE, PW_MANAGERS, PW_ALL, -1}; // octal values for ISO-8859-15: // \244 = Euro ("€") // \243 = British pound ("£") // " " = no symbol -static const genericChar* MoneySymbolName[] = { "$", "\244", "\243", " ", nullptr }; +static const genericChar* MoneySymbolName[] = { "$", "\244", "\243", " ", NULL }; -static const genericChar* ButtonTextPosName[] = { "Over Image", "Above Image", "Below Image", nullptr }; +static const genericChar* ButtonTextPosName[] = { "Over Image", "Above Image", "Below Image", NULL }; static int ButtonTextPosValue[] = { 0, 1, 2, -1 }; namespace { @@ -138,19 +138,21 @@ RenderResult SwitchZone::Render(Terminal *term, int update_flag) RenderZone(term, SwitchName[idx], update_flag); Settings *settings = term->GetSettings(); - int col = COLOR_BLUE; + int col = COLOR_BLUE; int onoff = -1; - const char* str = nullptr; + const char* str = NULL; switch (type) { case SWITCH_SEATS: onoff = settings->use_seats; break; case SWITCH_DRAWER_MODE: + // Modern enum-based approach if (auto mode = vt::IntToEnum(settings->drawer_mode)) { str = vt::GetDrawerModeDisplayName(*mode); + vt::Logger::debug("Drawer mode: {}", str); } else { - str = "Unknown"; + str = FindStringByValue(settings->drawer_mode, DrawerModeValue, DrawerModeName); } break; case SWITCH_PASSWORDS: @@ -178,47 +180,34 @@ RenderResult SwitchZone::Render(Terminal *term, int update_flag) str = FindStringByValue(settings->store, StoreValue, StoreName); break; case SWITCH_ROUNDING: - if (auto rounding = vt::IntToEnum(settings->price_rounding)) { - str = vt::GetPriceRoundingDisplayName(*rounding); - } else { - str = "Unknown"; - } + str = FindStringByValue(settings->price_rounding, RoundingValue, RoundingName); break; case SWITCH_RECEIPT_PRINT: - // Enum-based display name (no legacy array fallback) - if (auto receipt_type = vt::IntToEnum(settings->receipt_print)) { + // Modern enum-based approach + if (auto receipt_type = vt::IntToEnum(settings->receipt_print)) { // Renamed to avoid shadowing member 'type' str = vt::GetReceiptPrintDisplayName(*receipt_type); } else { - str = "Unknown"; - } - break; - case SWITCH_DRAWER_PRINT: - if (auto drawer_type = vt::IntToEnum(settings->drawer_print)) { - str = vt::GetDrawerPrintDisplayName(*drawer_type); - } else { - str = "Unknown"; + str = FindStringByValue(settings->receipt_print, ReceiptPrintValue, ReceiptPrintName); } break; case SWITCH_DATE_FORMAT: + // Modern enum-based approach if (auto format = vt::IntToEnum(settings->date_format)) { str = vt::GetDateFormatDisplayName(*format); } else { - str = "Unknown"; + str = FindStringByValue(settings->date_format, DateFormatValue, DateFormatName); } break; case SWITCH_NUMBER_FORMAT: + // Modern enum-based approach if (auto format = vt::IntToEnum(settings->number_format)) { str = vt::GetNumberFormatDisplayName(*format); } else { - str = "Unknown"; + str = FindStringByValue(settings->number_format, NumberFormatValue, NumberFormatName); } break; case SWITCH_MEASUREMENTS: - if (auto measure = vt::IntToEnum(settings->measure_system)) { - str = vt::GetMeasureSystemDisplayName(*measure); - } else { - str = "Unknown"; - } + str = FindStringByValue(settings->measure_system, MeasureSystemValue, MeasureSystemName); break; case SWITCH_LOCALE: // Show current language @@ -232,10 +221,11 @@ RenderResult SwitchZone::Render(Terminal *term, int update_flag) } break; case SWITCH_TIME_FORMAT: + // Modern enum-based approach if (auto format = vt::IntToEnum(settings->time_format)) { str = vt::GetTimeFormatDisplayName(*format); } else { - str = "Unknown"; + str = FindStringByValue(settings->time_format, TimeFormatValue, TimeFormatName); } break; case SWITCH_AUTHORIZE_METHOD: @@ -271,6 +261,9 @@ RenderResult SwitchZone::Render(Terminal *term, int update_flag) case SWITCH_RECEIPT_ALL_MODS: onoff = settings->receipt_all_modifiers; break; + case SWITCH_DRAWER_PRINT: + str = FindStringByValue(settings->drawer_print, DrawerPrintValue, DrawerPrintName); + break; case SWITCH_BALANCE_AUTO_CPNS: onoff = settings->balance_auto_coupons; break; @@ -290,7 +283,7 @@ RenderResult SwitchZone::Render(Terminal *term, int update_flag) } // For switches that don't have custom text, set On/Off text - if (onoff >= 0 && str == nullptr) + if (onoff >= 0 && str == NULL) { if (onoff == 0) { @@ -367,21 +360,7 @@ SignalResult SwitchZone::Touch(Terminal *term, int /*tx*/, int /*ty*/) settings->use_seats ^= 1; break; case SWITCH_DRAWER_MODE: - { - auto values = vt::GetEnumValues(); - int next_val = settings->drawer_mode; - if (auto current = vt::IntToEnum(settings->drawer_mode)) { - std::size_t idx = 0; - for (std::size_t i = 0; i < values.size(); ++i) { - if (values[i] == *current) { idx = i; break; } - } - idx = (idx + 1) % values.size(); - next_val = static_cast(vt::EnumToInt(values[idx])); - } else if (!values.empty()) { - next_val = static_cast(vt::EnumToInt(values[0])); - } - settings->drawer_mode = next_val; - } + settings->drawer_mode = NextValue(settings->drawer_mode, DrawerModeValue); break; case SWITCH_PASSWORDS: settings->password_mode = NextValue(settings->password_mode, PasswordValue); @@ -408,108 +387,19 @@ SignalResult SwitchZone::Touch(Terminal *term, int /*tx*/, int /*ty*/) settings->store = NextValue(settings->store, StoreValue); break; case SWITCH_ROUNDING: - { - auto values = vt::GetEnumValues(); - int next_val = settings->price_rounding; - if (auto current = vt::IntToEnum(settings->price_rounding)) { - std::size_t idx = 0; - for (std::size_t i = 0; i < values.size(); ++i) { - if (values[i] == *current) { idx = i; break; } - } - idx = (idx + 1) % values.size(); - next_val = static_cast(vt::EnumToInt(values[idx])); - } else { - next_val = static_cast(vt::EnumToInt(values[0])); - } - settings->price_rounding = next_val; - } + settings->price_rounding = NextValue(settings->price_rounding, RoundingValue); break; case SWITCH_RECEIPT_PRINT: - { - auto values = vt::GetEnumValues(); - int next_val = settings->receipt_print; - if (auto current = vt::IntToEnum(settings->receipt_print)) { - // find current index - std::size_t idx = 0; - for (std::size_t i = 0; i < values.size(); ++i) { - if (values[i] == *current) { idx = i; break; } - } - idx = (idx + 1) % values.size(); - next_val = static_cast(vt::EnumToInt(values[idx])); - } else { - // default to first value if invalid - next_val = static_cast(vt::EnumToInt(values[0])); - } - settings->receipt_print = next_val; - } - break; - case SWITCH_DRAWER_PRINT: - { - auto values = vt::GetEnumValues(); - int next_val = settings->drawer_print; - if (auto current = vt::IntToEnum(settings->drawer_print)) { - std::size_t idx = 0; - for (std::size_t i = 0; i < values.size(); ++i) { - if (values[i] == *current) { idx = i; break; } - } - idx = (idx + 1) % values.size(); - next_val = static_cast(vt::EnumToInt(values[idx])); - } else { - next_val = static_cast(vt::EnumToInt(values[0])); - } - settings->drawer_print = next_val; - } + settings->receipt_print = NextValue(settings->receipt_print, ReceiptPrintValue); break; case SWITCH_DATE_FORMAT: - { - auto values = vt::GetEnumValues(); - int next_val = settings->date_format; - if (auto current = vt::IntToEnum(settings->date_format)) { - std::size_t idx = 0; - for (std::size_t i = 0; i < values.size(); ++i) { - if (values[i] == *current) { idx = i; break; } - } - idx = (idx + 1) % values.size(); - next_val = static_cast(vt::EnumToInt(values[idx])); - } else { - next_val = static_cast(vt::EnumToInt(values[0])); - } - settings->date_format = next_val; - } + settings->date_format = NextValue(settings->date_format, DateFormatValue); break; case SWITCH_NUMBER_FORMAT: - { - auto values = vt::GetEnumValues(); - int next_val = settings->number_format; - if (auto current = vt::IntToEnum(settings->number_format)) { - std::size_t idx = 0; - for (std::size_t i = 0; i < values.size(); ++i) { - if (values[i] == *current) { idx = i; break; } - } - idx = (idx + 1) % values.size(); - next_val = static_cast(vt::EnumToInt(values[idx])); - } else { - next_val = static_cast(vt::EnumToInt(values[0])); - } - settings->number_format = next_val; - } + settings->number_format = NextValue(settings->number_format, NumberFormatValue); break; case SWITCH_MEASUREMENTS: - { - auto values = vt::GetEnumValues(); - int next_val = settings->measure_system; - if (auto current = vt::IntToEnum(settings->measure_system)) { - std::size_t idx = 0; - for (std::size_t i = 0; i < values.size(); ++i) { - if (values[i] == *current) { idx = i; break; } - } - idx = (idx + 1) % values.size(); - next_val = static_cast(vt::EnumToInt(values[idx])); - } else { - next_val = static_cast(vt::EnumToInt(values[0])); - } - settings->measure_system = next_val; - } + settings->measure_system = NextValue(settings->measure_system, MeasureSystemValue); break; case SWITCH_LOCALE: // Language switching - cycle between English and Spanish @@ -538,21 +428,7 @@ SignalResult SwitchZone::Touch(Terminal *term, int /*tx*/, int /*ty*/) no_update = 1; // Don't update settings since language is handled separately break; case SWITCH_TIME_FORMAT: - { - auto values = vt::GetEnumValues(); - int next_val = settings->time_format; - if (auto current = vt::IntToEnum(settings->time_format)) { - std::size_t idx = 0; - for (std::size_t i = 0; i < values.size(); ++i) { - if (values[i] == *current) { idx = i; break; } - } - idx = (idx + 1) % values.size(); - next_val = static_cast(vt::EnumToInt(values[idx])); - } else { - next_val = static_cast(vt::EnumToInt(values[0])); - } - settings->time_format = next_val; - } + settings->time_format = NextValue(settings->time_format, TimeFormatValue); break; case SWITCH_AUTHORIZE_METHOD: settings->authorize_method = NextValue(settings->authorize_method, AuthorizeValue); @@ -591,6 +467,9 @@ SignalResult SwitchZone::Touch(Terminal *term, int /*tx*/, int /*ty*/) case SWITCH_RECEIPT_ALL_MODS: settings->receipt_all_modifiers ^= 1; break; + case SWITCH_DRAWER_PRINT: + settings->drawer_print = NextValue(settings->drawer_print, DrawerPrintValue); + break; case SWITCH_BALANCE_AUTO_CPNS: settings->balance_auto_coupons ^= 1; break; @@ -651,7 +530,7 @@ const char* SwitchZone::TranslateString(Terminal * /*term*/) FnTrace("SwitchZone::TranslateString()"); int idx = CompareList(type, SwitchValue); if (idx < 0) - return nullptr; + return NULL; return SwitchName[idx]; } @@ -698,7 +577,7 @@ SettingsZone::SettingsZone() LeftAlign(); AddTextField("Lowest Account Number", 10); SetFlag(FF_ONLYDIGITS); AddTextField("Highest Account Number", 10); SetFlag(FF_ONLYDIGITS); - AddListField("Account for expenses paid from drawers", nullptr); + AddListField("Account for expenses paid from drawers", NULL); // Section 3: Drawer Settings AddNewLine(); @@ -782,7 +661,7 @@ SignalResult SettingsZone::Signal(Terminal *term, const genericChar* message) { FnTrace("SettingsZone::Signal()"); static const genericChar* commands[] = {"section0", "section1", "section2", "section3", - "section4", "section5", "section6", "section7", nullptr}; + "section4", "section5", "section6", "section7", NULL}; SignalResult retval = SIGNAL_OKAY; int draw = 1; int new_section = -1; @@ -861,8 +740,8 @@ RenderResult SettingsZone::Render(Terminal *term, int update_flag) } // Activate fields for current section - FormField *section_start = nullptr; - FormField *section_end = nullptr; + FormField *section_start = NULL; + FormField *section_end = NULL; switch (section) { @@ -896,7 +775,7 @@ RenderResult SettingsZone::Render(Terminal *term, int update_flag) break; case 7: // Kitchen Video Order Alert Settings section_start = kitchen_start; - section_end = nullptr; // Last section + section_end = NULL; // Last section break; } @@ -921,9 +800,9 @@ RenderResult SettingsZone::Render(Terminal *term, int update_flag) } if (update_flag || keep_focus == 0) - keyboard_focus = nullptr; + keyboard_focus = NULL; - FormZone::Render(term, update_flag); + LayoutZone::Render(term, update_flag); if (!no_line) { @@ -937,7 +816,7 @@ RenderResult SettingsZone::Render(Terminal *term, int update_flag) if (records > 0) { LayoutForm(term); - for (FormField *field = FieldList(); field != nullptr; field = field->next) // Renamed 'f' to 'field' to avoid shadowing + for (FormField *field = FieldList(); field != NULL; field = field->next) // Renamed 'f' to 'field' to avoid shadowing { field->selected = (keyboard_focus == field); if (field->active) @@ -982,7 +861,7 @@ int SettingsZone::LoadRecord(Terminal *term, int /*record*/) { FnTrace("SettingsZone::LoadRecord()"); Settings *settings = term->GetSettings(); - FormField *f = nullptr; + FormField *f = NULL; int day_length_hrs = settings->min_day_length / 60 / 60; // Find the start field for current section @@ -1015,7 +894,7 @@ int SettingsZone::LoadRecord(Terminal *term, int /*record*/) { // need to get the list of accounts for this Account *acct = term->system_data->account_db.AccountList(); - while (acct != nullptr) + while (acct != NULL) { f->AddEntry(acct->name.Value(), acct->number); acct = acct->next; @@ -1085,7 +964,7 @@ int SettingsZone::SaveRecord(Terminal *term, int record, int write_file) { FnTrace("SettingsZone::SaveRecord()"); Settings *settings = term->GetSettings(); - FormField *f = nullptr; + FormField *f = NULL; int day_length_hrs = 0; // Find the start field for current section @@ -1476,7 +1355,7 @@ int TaxSettingsZone::SaveRecord(Terminal *term, int record, int write_file) * CCSettingsZone Class ********************************************************************/ -const genericChar* CCNumName[] = { "1234 5678 9012 3456", "xxxx xxxx xxxx 3456", nullptr }; +const genericChar* CCNumName[] = { "1234 5678 9012 3456", "xxxx xxxx xxxx 3456", NULL }; CCSettingsZone::CCSettingsZone() { @@ -1857,8 +1736,8 @@ SignalResult DeveloperZone::Signal(Terminal *term, const genericChar* message) { FnTrace("DeveloperZone::Signal()"); static const genericChar* commands[] = {"clearsystem", "clear system", "clearsystemall", - "clearsystemsome", nullptr}; - SimpleDialog *sd = nullptr; + "clearsystemsome", NULL}; + SimpleDialog *sd = NULL; int idx = CompareList(message, commands); switch (idx) @@ -1979,7 +1858,7 @@ int RevenueGroupsZone::AddFields() FnTrace("RevenueGroupsZone::AddFields()"); int i = 0; - for (i = 0; FamilyName[i] != nullptr; i++) + for (i = 0; FamilyName[i] != NULL; i++) { AddListField(MasterLocale->Translate(FamilyName[i]), SalesGroupName, SalesGroupValue); @@ -2000,7 +1879,7 @@ RenderResult RevenueGroupsZone::Render(Terminal *term, int update_flag) } if (update_flag) - { /* No clear_flag equivalent needed for this zone */ } // No clear_flag equivalent needed for this zone + ; // No clear_flag equivalent needed for this zone form_header = 0; if (name.size() > 0) @@ -2051,9 +1930,9 @@ int RevenueGroupsZone::SaveRecord(Terminal *term, int record, int write_file) #define CP_TYPE_PERCENT 1 #define CP_TYPE_SUBST 2 -static const char* TS_TypeName[] = {"dollar value", "percent of price", nullptr}; +static const char* TS_TypeName[] = {"dollar value", "percent of price", NULL}; static const char* CP_TypeName[] = {"dollar value", "percent of price", - "substitute price", nullptr}; + "substitute price", NULL}; static int CP_TypeValue[] = { CP_TYPE_DOLLAR, CP_TYPE_PERCENT, CP_TYPE_SUBST, -1 }; @@ -2209,7 +2088,7 @@ SignalResult TenderSetZone::Signal(Terminal *term, const genericChar* message) { FnTrace("TenderSetZone::Signal()"); static const genericChar* commands[] = {"section", "clearstart", - "clearend", "clearweekday", nullptr}; + "clearend", "clearweekday", NULL}; SignalResult retval = SIGNAL_OKAY; int draw = 1; @@ -2228,16 +2107,16 @@ SignalResult TenderSetZone::Signal(Terminal *term, const genericChar* message) records = RecordCount(term); break; case 1: // clearstart - coupon_time_start->Set(static_cast(nullptr)); - coupon_time_end->Set(static_cast(nullptr)); - coupon_date_start->Set(static_cast(nullptr)); - coupon_date_end->Set(static_cast(nullptr)); + coupon_time_start->Set((TimeInfo *) NULL); + coupon_time_end->Set((TimeInfo *) NULL); + coupon_date_start->Set((TimeInfo *) NULL); + coupon_date_end->Set((TimeInfo *) NULL); break; case 2: // clearend - coupon_time_start->Set(static_cast(nullptr)); - coupon_time_end->Set(static_cast(nullptr)); - coupon_date_start->Set(static_cast(nullptr)); - coupon_date_end->Set(static_cast(nullptr)); + coupon_time_start->Set((TimeInfo *) NULL); + coupon_time_end->Set((TimeInfo *) NULL); + coupon_date_start->Set((TimeInfo *) NULL); + coupon_date_end->Set((TimeInfo *) NULL); break; case 3: // clearweekday coupon_weekdays->Set(0); @@ -2285,7 +2164,7 @@ int TenderSetZone::LoadRecord(Terminal *term, int record) { record = 0; ds = settings->DiscountList(); - while (ds != nullptr) + while (ds != NULL) { if (display_id == ds->id) break; @@ -2330,7 +2209,7 @@ int TenderSetZone::LoadRecord(Terminal *term, int record) { record = 0; cp = settings->CouponList(); - while (cp != nullptr) + while (cp != NULL) { if (display_id == cp->id) break; @@ -2422,7 +2301,7 @@ int TenderSetZone::LoadRecord(Terminal *term, int record) { record = 0; cc = settings->CreditCardList(); - while (cc != nullptr) + while (cc != NULL) { if (display_id == cc->id) break; @@ -2453,7 +2332,7 @@ int TenderSetZone::LoadRecord(Terminal *term, int record) { record = 0; thisComp = settings->CompList(); - while (thisComp != nullptr) + while (thisComp != NULL) { if (display_id == thisComp->id) break; @@ -2507,7 +2386,7 @@ int TenderSetZone::LoadRecord(Terminal *term, int record) { record = 0; mi = settings->MealList(); - while (mi != nullptr) + while (mi != NULL) { if (display_id == mi->id) break; @@ -2597,7 +2476,7 @@ int TenderSetZone::SaveRecord(Terminal *term, int record, int write_file) { settings->Remove(ds); dslist = settings->DiscountList(); // refresh - if (dslist != nullptr) + if (dslist != NULL) ds->id = settings->MediaFirstID(dslist, 1); else ds->id = 1; @@ -2610,7 +2489,7 @@ int TenderSetZone::SaveRecord(Terminal *term, int record, int write_file) { settings->Remove(ds); dslist = settings->DiscountList(); // refresh - if (dslist != nullptr) + if (dslist != NULL) ds->id = settings->MediaFirstID(dslist, GLOBAL_MEDIA_ID); else ds->id = GLOBAL_MEDIA_ID; @@ -2671,7 +2550,7 @@ int TenderSetZone::SaveRecord(Terminal *term, int record, int write_file) { settings->Remove(cp); cplist = settings->CouponList(); // refresh - if (cplist != nullptr) + if (cplist != NULL) cp->id = settings->MediaFirstID(cplist, 1); else cp->id = 1; @@ -2684,7 +2563,7 @@ int TenderSetZone::SaveRecord(Terminal *term, int record, int write_file) { settings->Remove(cp); cplist = settings->CouponList(); // refresh - if (cplist != nullptr) + if (cplist != NULL) cp->id = settings->MediaFirstID(cplist, GLOBAL_MEDIA_ID); else cp->id = 1; @@ -2715,7 +2594,7 @@ int TenderSetZone::SaveRecord(Terminal *term, int record, int write_file) { settings->Remove(cc); cclist = settings->CreditCardList(); // refresh - if (cclist != nullptr) + if (cclist != NULL) cc->id = settings->MediaFirstID(cclist, 1); else cc->id = 1; @@ -2728,7 +2607,7 @@ int TenderSetZone::SaveRecord(Terminal *term, int record, int write_file) { settings->Remove(cc); cclist = settings->CreditCardList(); // refresh - if (cclist != nullptr) + if (cclist != NULL) cc->id = settings->MediaFirstID(cclist, GLOBAL_MEDIA_ID); else cc->id = GLOBAL_MEDIA_ID; @@ -2772,7 +2651,7 @@ int TenderSetZone::SaveRecord(Terminal *term, int record, int write_file) { settings->Remove(cm); cmlist = settings->CompList(); // refresh - if (cmlist != nullptr) + if (cmlist != NULL) cm->id = settings->MediaFirstID(cmlist, 1); else cm->id = 1; @@ -2785,7 +2664,7 @@ int TenderSetZone::SaveRecord(Terminal *term, int record, int write_file) { settings->Remove(cm); cmlist = settings->CompList(); // refresh - if (cmlist != nullptr) + if (cmlist != NULL) cm->id = settings->MediaFirstID(cmlist, GLOBAL_MEDIA_ID); else cm->id = GLOBAL_MEDIA_ID; @@ -2885,7 +2764,7 @@ int TenderSetZone::KillRecord(Terminal *term, int record) { DiscountInfo *ds = settings->FindDiscountByRecord(record); ds->active = 0; - if (ds->next != nullptr) + if (ds->next != NULL) display_id = ds->next->id; else record_no = -1; @@ -2950,7 +2829,7 @@ int TenderSetZone::UpdateForm(Terminal *term, int record) { FnTrace("TenderSetZone::UpdateForm()"); int retval = 0; - FormField *field = nullptr; + FormField *field = NULL; int is_item_specific = 0; int is_active = 0; static int last_family = -1; @@ -2971,7 +2850,7 @@ int TenderSetZone::UpdateForm(Terminal *term, int record) field = field->next; if (is_item_specific) is_active = 1; - while (field != nullptr && field != creditcard_start) + while (field != NULL && field != creditcard_start) { field->active = is_active; field = field->next; @@ -3052,7 +2931,7 @@ int TenderSetZone::ItemList(FormField *itemfield, int family, int item_id) if (items->ItemsInFamily(family) > 0) { itemfield->AddEntry(ALL_ITEMS_STRING, -1); - while (item != nullptr) + while (item != NULL) { if (item->family == family) { @@ -3324,7 +3203,7 @@ int TimeSettingsZone::SaveRecord(Terminal *term, int record, int write_file) f->Get(settings->wage_week_start); f = f->next; - term->UpdateOtherTerms(UPDATE_MEAL_PERIOD, nullptr); + term->UpdateOtherTerms(UPDATE_MEAL_PERIOD, NULL); if (write_file) settings->Save(); return 0; diff --git a/zone/settings_zone.hh b/zone/settings_zone.hh index fc758448..22665a6d 100644 --- a/zone/settings_zone.hh +++ b/zone/settings_zone.hh @@ -19,7 +19,7 @@ */ #ifndef _SETTINGS_ZONE_H -#define SETTINGS_ZONE_H +#define _SETTINGS_ZONE_H #include "form_zone.hh" @@ -38,13 +38,13 @@ public: SwitchZone(); // Member Functions - int Type() override { return ZONE_SWITCH; } - std::unique_ptr Copy() override; - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - int Update(Terminal *term, int update_message, const genericChar* value) override; - const genericChar* TranslateString(Terminal *term) override; - int *SwitchType() override { return &type; } + int Type() { return ZONE_SWITCH; } + std::unique_ptr Copy(); + RenderResult Render(Terminal *term, int update_flag); + SignalResult Touch(Terminal *term, int tx, int ty); + int Update(Terminal *term, int update_message, const genericChar* value); + const genericChar* TranslateString(Terminal *term); + int *SwitchType() { return &type; } }; @@ -67,12 +67,12 @@ public: SettingsZone(); // Member Functions - int Type() override { return ZONE_SETTINGS; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - int LoadRecord(Terminal *term, int record) override; - int SaveRecord(Terminal *term, int record, int write_file) override; + int Type() { return ZONE_SETTINGS; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Signal(Terminal *term, const genericChar* message); + SignalResult Touch(Terminal *term, int tx, int ty); + int LoadRecord(Terminal *term, int record); + int SaveRecord(Terminal *term, int record, int write_file); }; // Receipt Settings @@ -83,10 +83,10 @@ public: ReceiptSettingsZone(); // Member Functions - int Type() override { return ZONE_RECEIPTS; } - RenderResult Render(Terminal *term, int update_flag) override; - int LoadRecord(Terminal *term, int record) override; - int SaveRecord(Terminal *term, int record, int write_file) override; + int Type() { return ZONE_RECEIPTS; } + RenderResult Render(Terminal *term, int update_flag); + int LoadRecord(Terminal *term, int record); + int SaveRecord(Terminal *term, int record, int write_file); }; // Tax Settings Zone @@ -97,10 +97,10 @@ public: TaxSettingsZone(); // Member Functions - int Type() override { return ZONE_TAX_SETTINGS; } - RenderResult Render(Terminal *term, int update_flag) override; - int LoadRecord(Terminal *term, int record) override; - int SaveRecord(Terminal *term, int record, int write_file) override; + int Type() { return ZONE_TAX_SETTINGS; } + RenderResult Render(Terminal *term, int update_flag); + int LoadRecord(Terminal *term, int record); + int SaveRecord(Terminal *term, int record, int write_file); }; // Credit/Charge Card Settings @@ -118,11 +118,11 @@ public: CCSettingsZone(); // Member Functions - int Type() override { return ZONE_CC_SETTINGS; } - RenderResult Render(Terminal *term, int update_flag) override; - int LoadRecord(Terminal *term, int record) override; - int SaveRecord(Terminal *term, int record, int write_file) override; - int UpdateForm(Terminal *term, int record) override; + int Type() { return ZONE_CC_SETTINGS; } + RenderResult Render(Terminal *term, int update_flag); + int LoadRecord(Terminal *term, int record); + int SaveRecord(Terminal *term, int record, int write_file); + int UpdateForm(Terminal *term, int record); }; // Credit/Charge Card Message Settings @@ -131,10 +131,10 @@ class CCMessageSettingsZone : public FormZone public: CCMessageSettingsZone(); - int Type() override { return ZONE_CC_MSG_SETTINGS; } - RenderResult Render(Terminal *term, int update_flag) override; - int LoadRecord(Terminal *term, int record) override; - int SaveRecord(Terminal *term, int record, int write_file) override; + int Type() { return ZONE_CC_MSG_SETTINGS; } + RenderResult Render(Terminal *term, int update_flag); + int LoadRecord(Terminal *term, int record); + int SaveRecord(Terminal *term, int record, int write_file); }; // Low level application settings @@ -148,12 +148,12 @@ public: DeveloperZone(); // Member Functions - int Type() override { return ZONE_DEVELOPER; } + int Type() { return ZONE_DEVELOPER; } int AddFields(); - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - int LoadRecord(Terminal *term, int record) override; - int SaveRecord(Terminal *term, int record, int write_file) override; + RenderResult Render(Terminal *term, int update_flag); + SignalResult Signal(Terminal *term, const genericChar* message); + int LoadRecord(Terminal *term, int record); + int SaveRecord(Terminal *term, int record, int write_file); }; // Calculation Settings (Multiply, Add/Subtract) @@ -166,11 +166,11 @@ public: CalculationSettingsZone(); // Member Functions - int Type() override { return ZONE_CALCULATION_SETTINGS; } + int Type() { return ZONE_CALCULATION_SETTINGS; } int AddFields(); - RenderResult Render(Terminal *term, int update_flag) override; - int LoadRecord(Terminal *term, int record) override; - int SaveRecord(Terminal *term, int record, int write_file) override; + RenderResult Render(Terminal *term, int update_flag); + int LoadRecord(Terminal *term, int record); + int SaveRecord(Terminal *term, int record, int write_file); }; /* Revenue Groups Settings */ @@ -183,11 +183,11 @@ public: RevenueGroupsZone(); // Member Functions - int Type() override { return ZONE_REVENUE_GROUPS; } + int Type() { return ZONE_REVENUE_GROUPS; } int AddFields(); - RenderResult Render(Terminal *term, int update_flag) override; - int LoadRecord(Terminal *term, int record) override; - int SaveRecord(Terminal *term, int record, int write_file) override; + RenderResult Render(Terminal *term, int update_flag); + int LoadRecord(Terminal *term, int record); + int SaveRecord(Terminal *term, int record, int write_file); }; // Tender Specification & Settings @@ -215,18 +215,18 @@ public: TenderSetZone(); // Member Functions - int Type() override { return ZONE_TENDER_SET; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - Flt *Spacing() override { return &list_spacing; } - - int LoadRecord(Terminal *term, int record) override; - int SaveRecord(Terminal *term, int record, int write_file) override; - int NewRecord(Terminal *term) override; - int KillRecord(Terminal *term, int record) override; - int ListReport(Terminal *term, Report *r) override; - int RecordCount(Terminal *term) override; - int UpdateForm(Terminal *term, int record) override; + int Type() { return ZONE_TENDER_SET; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Signal(Terminal *term, const genericChar* message); + Flt *Spacing() { return &list_spacing; } + + int LoadRecord(Terminal *term, int record); + int SaveRecord(Terminal *term, int record, int write_file); + int NewRecord(Terminal *term); + int KillRecord(Terminal *term, int record); + int ListReport(Terminal *term, Report *r); + int RecordCount(Terminal *term); + int UpdateForm(Terminal *term, int record); int ItemList(FormField *itemfield, int family, int item_id); }; @@ -238,17 +238,17 @@ public: MoneySetZone(); // Member Functions - int Type() override { return ZONE_MONEY_SET; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - Flt *Spacing() override { return &list_spacing; } - - int LoadRecord(Terminal *term, int record) override; - int SaveRecord(Terminal *term, int record, int write_file) override; - int NewRecord(Terminal *term) override; - int KillRecord(Terminal *term, int record) override; - int ListReport(Terminal *term, Report *r) override; - int RecordCount(Terminal *term) override; + int Type() { return ZONE_MONEY_SET; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Signal(Terminal *term, const genericChar* message); + Flt *Spacing() { return &list_spacing; } + + int LoadRecord(Terminal *term, int record); + int SaveRecord(Terminal *term, int record, int write_file); + int NewRecord(Terminal *term); + int KillRecord(Terminal *term, int record); + int ListReport(Terminal *term, Report *r); + int RecordCount(Terminal *term); }; // Tax Definition @@ -259,17 +259,17 @@ public: TaxSetZone(); // Member Functions - int Type() override { return ZONE_TAX_SET; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - Flt *Spacing() override { return &list_spacing; } - - int LoadRecord(Terminal *term, int record) override; - int SaveRecord(Terminal *term, int record, int write_file) override; - int NewRecord(Terminal *term) override; - int KillRecord(Terminal *term, int record) override; - int ListReport(Terminal *term, Report *r) override; - int RecordCount(Terminal *term) override; + int Type() { return ZONE_TAX_SET; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Signal(Terminal *term, const genericChar* message); + Flt *Spacing() { return &list_spacing; } + + int LoadRecord(Terminal *term, int record); + int SaveRecord(Terminal *term, int record, int write_file); + int NewRecord(Terminal *term); + int KillRecord(Terminal *term, int record); + int ListReport(Terminal *term, Report *r); + int RecordCount(Terminal *term); }; // System time settings @@ -285,13 +285,13 @@ public: TimeSettingsZone(); // Member Functions - int Type() override { return ZONE_TIME_SETTINGS; } - RenderResult Render(Terminal *term, int update_flag) override; - int Update(Terminal *term, int update_message, const genericChar* value) override; + int Type() { return ZONE_TIME_SETTINGS; } + RenderResult Render(Terminal *term, int update_flag); + int Update(Terminal *term, int update_message, const genericChar* value); - int LoadRecord(Terminal *term, int record) override; - int SaveRecord(Terminal *term, int record, int write_file) override; - int UpdateForm(Terminal *term, int record) override; + int LoadRecord(Terminal *term, int record); + int SaveRecord(Terminal *term, int record, int write_file); + int UpdateForm(Terminal *term, int record); }; // Expire Message Settings @@ -302,10 +302,10 @@ public: ExpireSettingsZone(); // Member Functions - int Type() override { return ZONE_EXPIRE_MSG; } - RenderResult Render(Terminal *term, int update_flag) override; - int LoadRecord(Terminal *term, int record) override; - int SaveRecord(Terminal *term, int record, int write_file) override; + int Type() { return ZONE_EXPIRE_MSG; } + RenderResult Render(Terminal *term, int update_flag); + int LoadRecord(Terminal *term, int record); + int SaveRecord(Terminal *term, int record, int write_file); }; #endif diff --git a/zone/split_check_zone.cc b/zone/split_check_zone.cc index 74f2b4a1..dc7148a4 100644 --- a/zone/split_check_zone.cc +++ b/zone/split_check_zone.cc @@ -49,7 +49,7 @@ class ItemObj : public ZoneObject ItemObj(int seat_no); // Member Function - int Render(Terminal *t) override; + int Render(Terminal *t); }; // Constructors @@ -74,7 +74,7 @@ ItemObj::ItemObj(Order *o) ItemObj::ItemObj(int seat_no) { - order = nullptr; + order = NULL; seat = seat_no; w = 84; h = 84; @@ -147,8 +147,8 @@ class CheckObj : public ZoneObject CheckObj(SubCheck *sc, int seat_mode = 0); // Member Functions - int Layout(Terminal *t, int lx, int ly, int lw, int lh) override; - int Render(Terminal *t) override; + int Layout(Terminal *t, int lx, int ly, int lw, int lh); + int Render(Terminal *t); void *Data() { return sub; } }; @@ -162,7 +162,7 @@ CheckObj::CheckObj(SubCheck *sc, int seat_mode) active = 0; int i; - if (sc == nullptr) + if (sc == NULL) return; if (seat_mode) @@ -173,7 +173,7 @@ CheckObj::CheckObj(SubCheck *sc, int seat_mode) seat_count[i] = 0; // count orders per seat - for (Order *o = sc->OrderList(); o != nullptr; o = o->next) + for (Order *o = sc->OrderList(); o != NULL; o = o->next) { if (o->seat >= 0 && o->seat < 32) ++seat_count[o->seat]; @@ -188,7 +188,7 @@ CheckObj::CheckObj(SubCheck *sc, int seat_mode) } else { - for (Order *o = sc->OrderList(); o != nullptr; o = o->next) + for (Order *o = sc->OrderList(); o != NULL; o = o->next) { if (o->item_type == ITEM_POUND) { @@ -303,8 +303,8 @@ int CheckObj::Render(Terminal *t) RenderResult SplitCheckZone::Render(Terminal *t, int update_flag) { FnTrace("SplitCheckZone::Render()"); - RenderZone(t, nullptr, update_flag); - if (t->check == nullptr || t->check->SubList() == nullptr) + RenderZone(t, NULL, update_flag); + if (t->check == NULL || t->check->SubList() == NULL) return RENDER_OKAY; Settings *s = t->GetSettings(); @@ -327,10 +327,10 @@ SignalResult SplitCheckZone::Signal(Terminal *t, const genericChar* message) FnTrace("SplitCheckZone::Signal()"); static const genericChar* commands[] = { "change view", "print", "split by seat", "merge", "next", "prior", - "amount ", nullptr}; + "amount ", NULL}; Check *c = t->check; - if (c == nullptr) + if (c == NULL) return SIGNAL_IGNORED; Settings *s = t->GetSettings(); @@ -398,19 +398,19 @@ SignalResult SplitCheckZone::Signal(Terminal *t, const genericChar* message) } break; case 6: // amount - if (from_check != nullptr && to_check != nullptr && item_object != nullptr) + if (from_check != NULL && to_check != NULL && item_object != NULL) { int last = 0; - if (to_check->sub == nullptr) + if (to_check->sub == NULL) { last = 1; to_check->sub = t->check->NewSubCheck(); } amount = atoi(&message[7]); to_check->sub->Add(from_check->sub->RemoveCount(item_object->order, amount)); - from_check = nullptr; - to_check = nullptr; - item_object = nullptr; + from_check = NULL; + to_check = NULL; + item_object = NULL; t->check->Update(s); if (last) start_check = t->check->SubCount(); @@ -428,7 +428,7 @@ SignalResult SplitCheckZone::Signal(Terminal *t, const genericChar* message) SignalResult SplitCheckZone::Touch(Terminal *t, int tx, int ty) { FnTrace("SplitCheckZone::Touch()"); - if (t->check == nullptr) + if (t->check == NULL) return SIGNAL_IGNORED; ZoneObject *zo = checks.Find(tx, ty); @@ -461,17 +461,17 @@ int SplitCheckZone::CreateChecks(Terminal *t) FnTrace("SplitCheckZone::CreateChecks()"); checks.Purge(); Check *check = t->check; - if (check == nullptr || check->SubList() == nullptr) + if (check == NULL || check->SubList() == NULL) return 1; - for (SubCheck *sc = check->SubList(); sc != nullptr; sc = sc->next) + for (SubCheck *sc = check->SubList(); sc != NULL; sc = sc->next) { if (sc->status == CHECK_OPEN) checks.Add(new CheckObj(sc, seat_mode)); } // Add Blank Check - checks.Add(new CheckObj(nullptr)); + checks.Add(new CheckObj(NULL)); return 0; } @@ -506,14 +506,14 @@ int SplitCheckZone::LayoutChecks(Terminal *t) zo->active = 1; int lw; - if (zo->next == nullptr) + if (zo->next == NULL) lw = w - cx - border; else lw = cw; zo->Layout(t, cx, cy, lw, ch); cx += cw; zo = zo->next; - if (zo == nullptr) + if (zo == NULL) break; } return 0; @@ -524,7 +524,7 @@ int SplitCheckZone::MoveItems(Terminal *t, CheckObj *target, int move_amount) FnTrace("SplitCheckZone::MoveItems()"); TenKeyDialog *dialog; - if (target == nullptr) + if (target == NULL) return 1; target->items.SetSelected(0); @@ -543,7 +543,7 @@ int SplitCheckZone::MoveItems(Terminal *t, CheckObj *target, int move_amount) } int last = 0; - if (target->sub == nullptr) + if (target->sub == NULL) { // target is blankcheck area - create new sub check for moved items last = 1; @@ -611,11 +611,11 @@ int SplitCheckZone::PrintReceipts(Terminal *t) { FnTrace("SplitCheckZone::PrintReceipts()"); Check *c = t->check; - if (c == nullptr) + if (c == NULL) return 1; Printer *p = t->FindPrinter(PRINTER_RECEIPT); - for (SubCheck *sc = c->SubList(); sc != nullptr; sc = sc->next) + for (SubCheck *sc = c->SubList(); sc != NULL; sc = sc->next) if (sc->status == CHECK_OPEN) sc->PrintReceipt(t, c, p); return 0; @@ -634,8 +634,8 @@ class PrintTargetObj : public ZoneObject PrintTargetObj(Terminal *t, Check *c, int printer_id); // Member Functions - int Render(Terminal *t) override; - int Layout(Terminal *t, int lx, int ly, int lw, int lh) override; + int Render(Terminal *t); + int Layout(Terminal *t, int lx, int ly, int lw, int lh); }; // Constructors @@ -648,8 +648,8 @@ PrintTargetObj::PrintTargetObj(Terminal *t, Check *c, int printer_id) int pid; Settings *s = t->GetSettings(); - for (SubCheck *sc = c->SubList(); sc != nullptr; sc = sc->next) - for (Order *o = sc->OrderList(); o != nullptr; o = o->next) + for (SubCheck *sc = c->SubList(); sc != NULL; sc = sc->next) + for (Order *o = sc->OrderList(); o != NULL; o = o->next) if (!(o->status & ORDER_SENT)) { pid = o->printer_id; @@ -725,9 +725,9 @@ int PrintTargetObj::Layout(Terminal *t, int lx, int ly, int lw, int lh) RenderResult ItemPrintTargetZone::Render(Terminal *t, int update_flag) { FnTrace("ItemPrintTargetZone::Render()"); - RenderZone(t, nullptr, update_flag); + RenderZone(t, NULL, update_flag); Check *c = t->check; - if (c == nullptr) + if (c == NULL) return RENDER_OKAY; Settings *s = t->GetSettings(); @@ -745,10 +745,8 @@ RenderResult ItemPrintTargetZone::Render(Terminal *t, int update_flag) if (pi->name.size() > 0) pto->name.Set(pi->name); else - pto->name.Set(FindStringByValue(pi->type, - const_cast(PrinterTypeValue.data()), - const_cast(PrinterTypeName.data()), - UnknownStr)); + pto->name.Set(FindStringByValue(pi->type, PrinterTypeValue, + PrinterTypeName, UnknownStr)); if (pto->items.Count() > 0 || pi->type == PRINTER_KITCHEN1) targets.Add(pto); else @@ -786,7 +784,7 @@ RenderResult ItemPrintTargetZone::Render(Terminal *t, int update_flag) SignalResult ItemPrintTargetZone::Signal(Terminal *t, const genericChar* message) { FnTrace("ItemPrintTargetZone::Signal()"); - static const genericChar* commands[] = {"final", "reset", nullptr}; + static const genericChar* commands[] = {"final", "reset", NULL}; int idx = CompareList(message, commands); switch (idx) { @@ -819,7 +817,7 @@ SignalResult ItemPrintTargetZone::Signal(Terminal *t, const genericChar* message SignalResult ItemPrintTargetZone::Touch(Terminal *t, int tx, int ty) { FnTrace("ItemPrintTargetZone::Touch()"); - if (t->check == nullptr) + if (t->check == NULL) return SIGNAL_IGNORED; ZoneObject *zo = empty_targets.Find(tx, ty); @@ -857,7 +855,7 @@ SignalResult ItemPrintTargetZone::Touch(Terminal *t, int tx, int ty) int ItemPrintTargetZone::MoveItems(Terminal *t, PrintTargetObj *target) { FnTrace("ItemPrintTargetZone::MoveItems()"); - if (target == nullptr) + if (target == NULL) return 1; int count = 0; diff --git a/zone/split_check_zone.hh b/zone/split_check_zone.hh index 24c9edc7..5c7e881b 100644 --- a/zone/split_check_zone.hh +++ b/zone/split_check_zone.hh @@ -19,7 +19,7 @@ */ #ifndef _SPLIT_CHECK_HH -#define SPLIT_CHECK_HH +#define _SPLIT_CHECK_HH #include "pos_zone.hh" #include "zone_object.hh" @@ -43,11 +43,11 @@ class SplitCheckZone : public PosZone public: // Member Functions - int Type() override { return ZONE_SPLIT_CHECK; } - RenderResult Render(Terminal *t, int update_flag) override; - SignalResult Signal(Terminal *t, const genericChar* message) override; - SignalResult Touch(Terminal *t, int tx, int ty) override; - int ZoneStates() override { return 1; } + int Type() { return ZONE_SPLIT_CHECK; } + RenderResult Render(Terminal *t, int update_flag); + SignalResult Signal(Terminal *t, const genericChar* message); + SignalResult Touch(Terminal *t, int tx, int ty); + int ZoneStates() { return 1; } int CreateChecks(Terminal *t); int LayoutChecks(Terminal *t); @@ -63,11 +63,11 @@ class ItemPrintTargetZone : public PosZone public: // Member Functions - int Type() override { return ZONE_ITEM_TARGET; } - RenderResult Render(Terminal *t, int update_flag) override; - SignalResult Signal(Terminal *t, const genericChar* message) override; - SignalResult Touch(Terminal *t, int tx, int ty) override; - int ZoneStates() override { return 1; } + int Type() { return ZONE_ITEM_TARGET; } + RenderResult Render(Terminal *t, int update_flag); + SignalResult Signal(Terminal *t, const genericChar* message); + SignalResult Touch(Terminal *t, int tx, int ty); + int ZoneStates() { return 1; } int MoveItems(Terminal *t, PrintTargetObj *target); }; diff --git a/zone/table_zone.cc b/zone/table_zone.cc index fb3cfdff..51236c08 100644 --- a/zone/table_zone.cc +++ b/zone/table_zone.cc @@ -56,17 +56,17 @@ class RoomDialog : public FormZone // Constructor RoomDialog(); // Destructor - ~RoomDialog() override; + ~RoomDialog(); // Member Functions - int RenderInit(Terminal *term, int update_flag) override; - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; + int RenderInit(Terminal *term, int update_flag); + RenderResult Render(Terminal *term, int update_flag); + SignalResult Signal(Terminal *term, const genericChar* message); + SignalResult Touch(Terminal *term, int tx, int ty); - int LoadRecord(Terminal *term, int record) override; - int SaveRecord(Terminal *term, int record, int write_file) override; - int UpdateForm(Terminal *term, int record) override; + int LoadRecord(Terminal *term, int record); + int SaveRecord(Terminal *term, int record, int write_file); + int UpdateForm(Terminal *term, int record); int ParseSwipe(Terminal *term, const genericChar* swipe); }; @@ -137,7 +137,7 @@ RenderResult RoomDialog::Render(Terminal *term, int update_flag) Check *check = term->check; if (check) { - for (SubCheck *sc = check->SubList(); sc != nullptr; sc = sc->next) + for (SubCheck *sc = check->SubList(); sc != NULL; sc = sc->next) { total += sc->total_cost + sc->payment; balance += sc->balance; @@ -181,7 +181,7 @@ SignalResult RoomDialog::Touch(Terminal *term, int tx, int ty) { FnTrace("RoomDialog::Touch()"); Check *check = term->check; - if (check == nullptr) + if (check == NULL) return SIGNAL_TERMINATE; if (checkout->IsPointIn(tx, ty)) @@ -239,7 +239,7 @@ int RoomDialog::LoadRecord(Terminal *term, int /*record*/) { FnTrace("RoomDialog::LoadRecord()"); Check *check = term->check; - if (check == nullptr) + if (check == NULL) return 0; FormField *f = FieldList(); @@ -269,7 +269,7 @@ int RoomDialog::SaveRecord(Terminal *term, int /*record*/, int /*write_file*/) { FnTrace("RoomDialog::SaveRecord()"); Check *check = term->check; - if (check == nullptr) + if (check == NULL) return 0; Str tmp; @@ -419,7 +419,7 @@ int RoomDialog::ParseSwipe(Terminal */*term*/, const genericChar* value) CustomerInfoZone::CustomerInfoZone() { font = FONT_TIMES_24; - customer = nullptr; + customer = NULL; my_update = 1; form_header = 0.65; @@ -444,7 +444,8 @@ CustomerInfoZone::CustomerInfoZone() } CustomerInfoZone::~CustomerInfoZone() -= default; +{ +} int CustomerInfoZone::RenderInit(Terminal *term, int update_flag) { @@ -467,20 +468,20 @@ RenderResult CustomerInfoZone::Render(Terminal *term, int update_flag) if (update_flag || my_update) { - if (customer != nullptr) + if (customer != NULL) customer->Save(); - if (term->customer == nullptr) - customer = nullptr; + if (term->customer == NULL) + customer = NULL; else customer = term->customer; LoadRecord(term, 0); my_update = 0; } - if (customer == nullptr) + if (customer == NULL) fields_active = 0; FormField *field = FieldList(); - while (field != nullptr) + while (field != NULL) { field->active = static_cast(fields_active); field = field->next; @@ -489,7 +490,7 @@ RenderResult CustomerInfoZone::Render(Terminal *term, int update_flag) FormZone::Render(term, update_flag); TextC(term, 0, term->Translate(name.Value()), col); - if (customer == nullptr) + if (customer == NULL) { TextL(term, 3, term->Translate("No customer available"), col); } @@ -502,7 +503,7 @@ SignalResult CustomerInfoZone::Signal(Terminal *term, const genericChar* message FnTrace("CustomerInfoZone::Signal()"); SignalResult retval = SIGNAL_OKAY; static const genericChar* commands[] = { - "next", "prior", "search", "nextsearch ", "new", nullptr}; + "next", "prior", "search", "nextsearch ", "new", NULL}; int idx = CompareListN(commands, message); int draw = 0; int customer_type = CHECK_TAKEOUT; // for new records @@ -512,23 +513,23 @@ SignalResult CustomerInfoZone::Signal(Terminal *term, const genericChar* message switch (idx) { case 0: //next - if (customer != nullptr && customer->next != nullptr) + if (customer != NULL && customer->next != NULL) { - if (customer != nullptr) + if (customer != NULL) SaveRecord(term, 0, 1); customer = customer->next; - if (term != nullptr) + if (term != NULL) term->customer = customer; draw = 1; } break; case 1: //prior - if (customer != nullptr && customer->fore != nullptr) + if (customer != NULL && customer->fore != NULL) { - if (customer != nullptr) + if (customer != NULL) SaveRecord(term, 0, 1); customer = customer->fore; - if (term != nullptr) + if (term != NULL) term->customer = customer; draw = 1; } @@ -546,11 +547,11 @@ SignalResult CustomerInfoZone::Signal(Terminal *term, const genericChar* message draw = 1; break; case 4: // new - if (customer != nullptr) + if (customer != NULL) SaveRecord(term, 0, 1); - if (term != nullptr && term->check != nullptr) + if (term != NULL && term->check != NULL) customer_type = term->check->CustomerType(); - if (term != nullptr) + if (term != NULL) term->customer = NewCustomerInfo(customer_type); keyboard_focus = FieldList(); draw = 1; @@ -560,7 +561,7 @@ SignalResult CustomerInfoZone::Signal(Terminal *term, const genericChar* message break; } - if (draw && term != nullptr) + if (draw && term != NULL) { // Normally we'd only draw our own zone, but we changed the current customer // term knows about, so other zones may be affected. @@ -585,7 +586,7 @@ int CustomerInfoZone::LoseFocus(Terminal *term, Zone */*newfocus*/) FnTrace("CustomerInfoZone::LoseFocus()"); int retval = 0; - keyboard_focus = nullptr; + keyboard_focus = NULL; Draw(term, 0); return retval; @@ -598,7 +599,7 @@ int CustomerInfoZone::LoadRecord(Terminal */*term*/, int /*record*/) FormField *fields = FieldList(); const genericChar* buffer; - if (customer != nullptr) + if (customer != NULL) { buffer = customer->FirstName(); fields->Set(buffer); @@ -659,7 +660,7 @@ int CustomerInfoZone::SaveRecord(Terminal *term, int record, int write_file) FormField *fields = FieldList(); genericChar buffer[STRLONG]; - if (customer != nullptr) + if (customer != NULL) { fields->Get(buffer); customer->FirstName(buffer); @@ -734,7 +735,7 @@ int CustomerInfoZone::RecordCount(Terminal *term) // However, the current record may be the very first record, and it // may still be empty. So we'll make sure the current record still // counts even if no data has yet been entered. - if (retval < 1 && term->customer != nullptr) + if (retval < 1 && term->customer != NULL) retval = 1; return retval; @@ -745,20 +746,20 @@ int CustomerInfoZone::Search(Terminal *term, int record, const genericChar* word FnTrace("CustomerInfoZone::Search()"); int retval = 1; - CustomerInfo *found = nullptr; + CustomerInfo *found = NULL; if (record > -1) { - if (customer != nullptr) + if (customer != NULL) record = customer->CustomerID(); else record = -1; } - found = (term != nullptr && term->system_data != nullptr) ? term->system_data->customer_db.FindByString(word, record) : nullptr; - if (found != nullptr && term != nullptr) + found = (term != NULL && term->system_data != NULL) ? term->system_data->customer_db.FindByString(word, record) : NULL; + if (found != NULL && term != NULL) term->customer = found; - else if (term != nullptr && term->system_data != nullptr) + else if (term != NULL && term->system_data != NULL) term->customer = term->system_data->customer_db.FindBlank(); return retval; @@ -784,7 +785,7 @@ RenderResult CommandZone::Render(Terminal *term, int update_flag) LayoutZone::Render(term, update_flag); Employee *employee = term->user; - if (employee == nullptr) + if (employee == NULL) return RENDER_OKAY; Settings *settings = term->GetSettings(); @@ -844,7 +845,7 @@ SignalResult CommandZone::Signal(Terminal *term, const genericChar* message) FnTrace("CommandZone::Signal()"); static const genericChar* commands[] = { "takeout", "printreceipt", "stack", "move", "more tables", - "tablenext", "tableprior", "faststart", nullptr}; + "tablenext", "tableprior", "faststart", NULL}; int idx = CompareList(message, commands); @@ -862,7 +863,7 @@ SignalResult CommandZone::Signal(Terminal *term, const genericChar* message) if (check) { Printer *p = term->FindPrinter(PRINTER_RECEIPT); - for (SubCheck *sc = check->SubList(); sc != nullptr; sc = sc->next) + for (SubCheck *sc = check->SubList(); sc != NULL; sc = sc->next) { if (sc->status == CHECK_OPEN) sc->PrintReceipt(term, check, p); @@ -879,7 +880,7 @@ SignalResult CommandZone::Signal(Terminal *term, const genericChar* message) if (check) { term->move_check ^= 1; - term->Update(UPDATE_ALL_TABLES, nullptr); + term->Update(UPDATE_ALL_TABLES, NULL); Draw(term, 0); return SIGNAL_OKAY; } @@ -906,7 +907,7 @@ SignalResult CommandZone::Touch(Terminal *term, int tx, int ty) FnTrace("CommandZone::Touch()"); Employee *e = term->user; Settings *s = term->GetSettings(); - if (e == nullptr || !e->IsSupervisor(s)) + if (e == NULL || !e->IsSupervisor(s)) return SIGNAL_IGNORED; term->Jump(JUMP_NORMAL, PAGEID_MANAGER); @@ -942,7 +943,7 @@ SignalResult CommandZone::Keyboard(Terminal *term, int my_key, int state) break; case 13: // enter { - Zone *z = nullptr; + Zone *z = NULL; if (check && len <= 0) z = FindTableZone(term, check->Table()); else @@ -996,7 +997,7 @@ int CommandZone::TakeOut(Terminal *term) return term->QuickMode(CHECK_TAKEOUT); Check *check = term->check; - if (check == nullptr || check->IsTakeOut()) + if (check == NULL || check->IsTakeOut()) return 1; Str tbl(check->Table()); @@ -1015,7 +1016,7 @@ int CommandZone::FastFood(Terminal *term) return term->QuickMode(CHECK_FASTFOOD); Check *check = term->check; - if (check == nullptr || check->IsFastFood()) + if (check == NULL || check->IsFastFood()) return 1; Str tbl(check->Table()); @@ -1030,19 +1031,19 @@ int CommandZone::FastFood(Terminal *term) Zone *CommandZone::FindTableZone(Terminal *term, const genericChar* table) { FnTrace("CommandZone::FindTableZone()"); - if (table == nullptr) - return nullptr; + if (table == NULL) + return NULL; int len = strlen(table); Page *my_page; // pass 1 - for (my_page = term->zone_db->PageList(); my_page != nullptr; my_page = my_page->next) + for (my_page = term->zone_db->PageList(); my_page != NULL; my_page = my_page->next) { if (!my_page->IsTable() || my_page->size > term->size) continue; - for (Zone *z = my_page->ZoneList(); z != nullptr; z = z->next) + for (Zone *z = my_page->ZoneList(); z != NULL; z = z->next) if (z->Type() == ZONE_TABLE && StringCompare(z->name.Value(), table, len) == 0) { @@ -1052,12 +1053,12 @@ Zone *CommandZone::FindTableZone(Terminal *term, const genericChar* table) } // pass 2 - for (my_page = term->zone_db->PageList(); my_page != nullptr; my_page = my_page->next) + for (my_page = term->zone_db->PageList(); my_page != NULL; my_page = my_page->next) { if (!my_page->IsTable() || my_page->size > term->size) continue; - for (Zone *z = my_page->ZoneList(); z != nullptr; z = z->next){ + for (Zone *z = my_page->ZoneList(); z != NULL; z = z->next){ if (z->Type() == ZONE_TABLE && StringCompare(z->name.Value(), table) == 0) { @@ -1066,7 +1067,7 @@ Zone *CommandZone::FindTableZone(Terminal *term, const genericChar* table) } } } - return nullptr; + return NULL; } @@ -1076,7 +1077,7 @@ Zone *CommandZone::FindTableZone(Terminal *term, const genericChar* table) // Constructor TableZone::TableZone() { - check = nullptr; + check = NULL; stack_depth = 0; blink = 0; current = 0; @@ -1147,7 +1148,7 @@ RenderResult TableZone::Render(Terminal *term, int update_flag) // Continue with normal TableZone rendering logic Employee *employee = term->user; - if (employee == nullptr) + if (employee == NULL) return RENDER_OKAY; System *sys = term->system_data; @@ -1158,7 +1159,7 @@ RenderResult TableZone::Render(Terminal *term, int update_flag) if (name.size() > 0) check = sys->FindOpenCheck(name.Value(), employee); else - check = nullptr; + check = NULL; stack_depth = sys->NumberStacked(name.Value(), employee); } @@ -1214,7 +1215,7 @@ RenderResult TableZone::Render(Terminal *term, int update_flag) SignalResult TableZone::Signal(Terminal *term, const genericChar* message) { FnTrace("TableZone::Signal()"); - static const genericChar* commands[] = {"mergetables", nullptr}; + static const genericChar* commands[] = {"mergetables", NULL}; int idx = CompareList(message, commands); switch (idx) @@ -1253,7 +1254,7 @@ SignalResult TableZone::Signal(Terminal *term, const genericChar* message) // Clear move mode and update display term->move_check = 0; - term->UpdateAllTerms(UPDATE_ALL_TABLES | UPDATE_CHECKS, nullptr); + term->UpdateAllTerms(UPDATE_ALL_TABLES | UPDATE_CHECKS, NULL); } return SIGNAL_OKAY; } @@ -1265,7 +1266,7 @@ SignalResult TableZone::Touch(Terminal *term, int tx, int ty) FnTrace("TableZone::Touch()"); Employee *e = term->user; - if (e == nullptr) + if (e == NULL) return SIGNAL_IGNORED; if (term->move_check && term->check) @@ -1291,12 +1292,12 @@ SignalResult TableZone::Touch(Terminal *term, int tx, int ty) // move check to this table & update term->check->Table(name.Value()); term->move_check = 0; - term->UpdateAllTerms(UPDATE_ALL_TABLES | UPDATE_CHECKS, nullptr); + term->UpdateAllTerms(UPDATE_ALL_TABLES | UPDATE_CHECKS, NULL); return SIGNAL_OKAY; } Check *tmp_check = term->check; - if (tmp_check == nullptr || tmp_check != check) + if (tmp_check == NULL || tmp_check != check) { if (check) { @@ -1336,7 +1337,7 @@ int TableZone::Update(Terminal *term, int update_message, const genericChar* val { FnTrace("TableZone::Update()"); Employee *e = term->user; - if (e == nullptr) + if (e == NULL) return 0; System *sys = term->system_data; @@ -1353,7 +1354,7 @@ int TableZone::Update(Terminal *term, int update_message, const genericChar* val ((update_message & UPDATE_TABLE) && (StringCompare(name.Value(), value) == 0))) { Check *tmp_check = sys->FindOpenCheck(name.Value(), e); - if (tmp_check == nullptr && check == nullptr) + if (tmp_check == NULL && check == NULL) return 0; check = tmp_check; stack_depth = sys->NumberStacked(name.Value(), e); @@ -1381,7 +1382,7 @@ RenderResult GuestCountZone::Render(Terminal *term, int update_flag) FnTrace("GuestCountZone::Render()"); LayoutZone::Render(term, update_flag); Check *check = term->check; - if (check == nullptr) + if (check == NULL) return RENDER_OKAY; if (update_flag) @@ -1418,7 +1419,7 @@ SignalResult GuestCountZone::Signal(Terminal *term, const genericChar* message) static const genericChar* commands[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "00", "backspace", "clear", "increase", "decrease", - "done", "ordering", "okay", "cancel", nullptr}; + "done", "ordering", "okay", "cancel", NULL}; Check *check = term->check; int idx = CompareList(message, commands); @@ -1495,7 +1496,7 @@ SignalResult GuestCountZone::Signal(Terminal *term, const genericChar* message) term->guests = count; Draw(term, 0); - term->Update(UPDATE_GUESTS, nullptr); + term->Update(UPDATE_GUESTS, NULL); return SIGNAL_OKAY; } @@ -1540,7 +1541,7 @@ class TableObj : public ZoneObject TableObj(Check *thisCheck); // Member Functions - int Render(Terminal *term) override; + int Render(Terminal *term); int Draw(Terminal *term); }; @@ -1603,8 +1604,8 @@ class ServerTableObj : public ZoneObject ServerTableObj(Terminal *term, Employee *e); // Member Functions - int Render(Terminal *term) override; - int Layout(Terminal *term, int lx, int ly, int lw, int lh) override; + int Render(Terminal *term); + int Layout(Terminal *term, int lx, int ly, int lw, int lh); }; // Constructor @@ -1691,9 +1692,9 @@ int ServerTableObj::Layout(Terminal *term, int lx, int ly, int lw, int lh) RenderResult TableAssignZone::Render(Terminal *term, int update_flag) { FnTrace("TableAssignZone::Render()"); - RenderZone(term, nullptr, update_flag); + RenderZone(term, NULL, update_flag); - if (term->user == nullptr) + if (term->user == NULL) return RENDER_OKAY; System *sys = term->system_data; @@ -1701,7 +1702,7 @@ RenderResult TableAssignZone::Render(Terminal *term, int update_flag) if (update_flag) { servers.Purge(); - for (Employee *e = sys->user_db.UserList(); e != nullptr; e = e->next) + for (Employee *e = sys->user_db.UserList(); e != NULL; e = e->next) if ((sys->labor_db.IsUserOnClock(e) && e->CanOrder(s) && !e->training) || sys->CountOpenChecks(e) > 0) servers.Add(new ServerTableObj(term, e)); @@ -1750,7 +1751,7 @@ int TableAssignZone::MoveTables(Terminal *term, ServerTableObj *sto) // Count selected tables int count = 0; - for (list = servers.List(); list != nullptr; list = list->next) + for (list = servers.List(); list != NULL; list = list->next) count += ((ServerTableObj *)list)->tables.CountSelected(); if (count <= 0) @@ -1760,7 +1761,7 @@ int TableAssignZone::MoveTables(Terminal *term, ServerTableObj *sto) } // Move tables - for (list = servers.List(); list != nullptr; list = list->next) + for (list = servers.List(); list != NULL; list = list->next) { ZoneObject *zoneObj = ((ServerTableObj *)list)->tables.List(); while (zoneObj) @@ -1785,6 +1786,6 @@ int TableAssignZone::MoveTables(Terminal *term, ServerTableObj *sto) } Draw(term, 1); - term->UpdateOtherTerms(UPDATE_ALL_TABLES | UPDATE_CHECKS, nullptr); + term->UpdateOtherTerms(UPDATE_ALL_TABLES | UPDATE_CHECKS, NULL); return 0; } diff --git a/zone/table_zone.hh b/zone/table_zone.hh index 783a4c0d..8971df00 100644 --- a/zone/table_zone.hh +++ b/zone/table_zone.hh @@ -19,7 +19,7 @@ */ #ifndef _TABLE_ZONE_HH -#define TABLE_ZONE_HH +#define _TABLE_ZONE_HH #include "check.hh" #include "customer.hh" @@ -42,21 +42,21 @@ class CustomerInfoZone : public FormZone public: CustomerInfoZone(); - ~CustomerInfoZone() override; + ~CustomerInfoZone(); // Member Functions - int Type() override { return ZONE_CUSTOMER_INFO; } - int RenderInit(Terminal *term, int update_flag) override; - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const genericChar* message) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - int LoseFocus(Terminal *term, Zone *newfocus) override; - - int LoadRecord(Terminal *term, int record) override; - int SaveRecord(Terminal *term, int record, int write_file) override; - int UpdateForm(Terminal *term, int record) override; - int RecordCount(Terminal *term) override; - int Search(Terminal *term, int record, const genericChar* word) override; + int Type() { return ZONE_CUSTOMER_INFO; } + int RenderInit(Terminal *term, int update_flag); + RenderResult Render(Terminal *term, int update_flag); + SignalResult Signal(Terminal *term, const genericChar* message); + SignalResult Touch(Terminal *term, int tx, int ty); + int LoseFocus(Terminal *term, Zone *newfocus); + + int LoadRecord(Terminal *term, int record); + int SaveRecord(Terminal *term, int record, int write_file); + int UpdateForm(Terminal *term, int record); + int RecordCount(Terminal *term); + int Search(Terminal *term, int record, const genericChar* word); }; class CommandZone : public LayoutZone @@ -66,14 +66,14 @@ class CommandZone : public LayoutZone public: CommandZone(); // Member Functions - int Type() override { return ZONE_COMMAND; } - RenderResult Render(Terminal *t, int update_flag) override; - SignalResult Signal(Terminal *t, const genericChar* message) override; - SignalResult Touch(Terminal *t, int tx, int ty) override; - SignalResult Keyboard(Terminal *t, int key, int state) override; - int Update(Terminal *t, int update_message, const genericChar* value) override; - const genericChar* TranslateString(Terminal *t) override; - int ZoneStates() override { return 1; } + int Type() { return ZONE_COMMAND; } + RenderResult Render(Terminal *t, int update_flag); + SignalResult Signal(Terminal *t, const genericChar* message); + SignalResult Touch(Terminal *t, int tx, int ty); + SignalResult Keyboard(Terminal *t, int key, int state); + int Update(Terminal *t, int update_message, const genericChar* value); + const genericChar* TranslateString(Terminal *t); + int ZoneStates() { return 1; } int TakeOut(Terminal *t); int FastFood(Terminal *t); @@ -93,14 +93,14 @@ public: TableZone(); // Member Functions - int Type() override { return ZONE_TABLE; } - std::unique_ptr Copy() override; - RenderResult Render(Terminal *t, int update_flag) override; - SignalResult Signal(Terminal *t, const genericChar* message) override; - SignalResult Touch(Terminal *t, int tx, int ty) override; - int Update(Terminal *t, int update_message, const genericChar* value) override; - int *CustomerType() override { return &customer_type; } - Check *GetCheck() override { return check; } + int Type() { return ZONE_TABLE; } + std::unique_ptr Copy(); + RenderResult Render(Terminal *t, int update_flag); + SignalResult Signal(Terminal *t, const genericChar* message); + SignalResult Touch(Terminal *t, int tx, int ty); + int Update(Terminal *t, int update_message, const genericChar* value); + int *CustomerType() { return &customer_type; } + Check *GetCheck() { return check; } }; class GuestCountZone : public LayoutZone @@ -113,11 +113,11 @@ public: GuestCountZone(); // Member Functions - int Type() override { return ZONE_GUEST_COUNT; } - RenderResult Render(Terminal *t, int update_flag) override; - SignalResult Signal(Terminal *t, const genericChar* message) override; - SignalResult Keyboard(Terminal *t, int key, int state) override; - int Update(Terminal *t, int update_message, const genericChar* value) override; + int Type() { return ZONE_GUEST_COUNT; } + RenderResult Render(Terminal *t, int update_flag); + SignalResult Signal(Terminal *t, const genericChar* message); + SignalResult Keyboard(Terminal *t, int key, int state); + int Update(Terminal *t, int update_message, const genericChar* value); }; class TableAssignZone : public PosZone @@ -126,12 +126,12 @@ class TableAssignZone : public PosZone public: // Member Functions - int Type() override { return ZONE_TABLE_ASSIGN; } - RenderResult Render(Terminal *t, int update_flag) override; - SignalResult Signal(Terminal *t, const genericChar* message) override; - SignalResult Touch(Terminal *t, int tx, int ty) override; - int Update(Terminal *t, int update_message, const genericChar* value) override; - int ZoneStates() override { return 1; } + int Type() { return ZONE_TABLE_ASSIGN; } + RenderResult Render(Terminal *t, int update_flag); + SignalResult Signal(Terminal *t, const genericChar* message); + SignalResult Touch(Terminal *t, int tx, int ty); + int Update(Terminal *t, int update_message, const genericChar* value); + int ZoneStates() { return 1; } int MoveTables(Terminal *t, ServerTableObj *sto); }; diff --git a/zone/user_edit_zone.cc b/zone/user_edit_zone.cc index 1a4e0c3b..a082f8d2 100644 --- a/zone/user_edit_zone.cc +++ b/zone/user_edit_zone.cc @@ -60,7 +60,7 @@ UserEditZone::UserEditZone() AddListField(GlobalTranslate("Job"), JobName, JobValue); AddListField(GlobalTranslate("Pay Rate"), PayRateName, PayRateValue); AddTextField(GlobalTranslate("Amount"), 7); - AddListField(GlobalTranslate("Start Page"), nullptr); + AddListField(GlobalTranslate("Start Page"), NULL); AddTextField(GlobalTranslate("Department"), 8); Color(COLOR_RED); AddButtonField(GlobalTranslate("Remove This Job"), "killjob1"); @@ -73,7 +73,7 @@ UserEditZone::UserEditZone() AddListField(GlobalTranslate("Job"), JobName, JobValue); AddListField(GlobalTranslate("Pay Rate"), PayRateName, PayRateValue); AddTextField(GlobalTranslate("Amount"), 7); - AddListField(GlobalTranslate("Start Page"), nullptr); + AddListField(GlobalTranslate("Start Page"), NULL); AddTextField(GlobalTranslate("Department"), 8); Color(COLOR_RED); AddButtonField(GlobalTranslate("Remove This Job"), "killjob2"); @@ -86,7 +86,7 @@ UserEditZone::UserEditZone() AddListField(GlobalTranslate("Job"), JobName, JobValue); AddListField(GlobalTranslate("Pay Rate"), PayRateName, PayRateValue); AddTextField(GlobalTranslate("Amount"), 7); - AddListField(GlobalTranslate("Start Page"), nullptr); + AddListField(GlobalTranslate("Start Page"), NULL); AddTextField(GlobalTranslate("Department"), 8); Color(COLOR_RED); AddButtonField(GlobalTranslate("Remove This Job"), "killjob3"); @@ -145,7 +145,7 @@ SignalResult UserEditZone::Signal(Terminal *term, const char* message) FnTrace("UserEditZone::Signal()"); static const char* commands[] = { "active", "inactive", "clear password", "remove", "activate", - "addjob", "killjob1", "killjob2", "killjob3", nullptr}; + "addjob", "killjob1", "killjob2", "killjob3", NULL}; int idx = CompareList(message, commands); if (idx < 0) @@ -167,13 +167,13 @@ SignalResult UserEditZone::Signal(Terminal *term, const char* message) return SIGNAL_OKAY; } - if (user == nullptr) + if (user == NULL) return SIGNAL_IGNORED; switch (idx) { case 2: // clear password - if (user != nullptr) + if (user != NULL) { user->password.Clear(); SaveRecord(term, record_no, 0); @@ -182,7 +182,7 @@ SignalResult UserEditZone::Signal(Terminal *term, const char* message) return SIGNAL_OKAY; case 3: // remove - if (user != nullptr && user->active) + if (user != NULL && user->active) { if (user->last_job == 0) { @@ -206,7 +206,7 @@ SignalResult UserEditZone::Signal(Terminal *term, const char* message) term->OpenDialog(d); } } - else if (user != nullptr) + else if (user != NULL) { char str[STRLENGTH]; snprintf(str, STRLENGTH, "Employee '%s' is inactive. What do you want to do?", @@ -238,7 +238,7 @@ SignalResult UserEditZone::Signal(Terminal *term, const char* message) JobInfo *j = new JobInfo; user->Add(j); LoadRecord(term, record_no); - keyboard_focus = nullptr; + keyboard_focus = NULL; Draw(term, 0); } break; @@ -250,7 +250,7 @@ SignalResult UserEditZone::Signal(Terminal *term, const char* message) user->Remove(j); delete j; LoadRecord(term, record_no); - keyboard_focus = nullptr; + keyboard_focus = NULL; Draw(term, 0); } break; @@ -262,7 +262,7 @@ SignalResult UserEditZone::Signal(Terminal *term, const char* message) user->Remove(j); delete j; LoadRecord(term, record_no); - keyboard_focus = nullptr; + keyboard_focus = NULL; Draw(term, 0); } break; @@ -274,7 +274,7 @@ SignalResult UserEditZone::Signal(Terminal *term, const char* message) user->Remove(j); delete j; LoadRecord(term, record_no); - keyboard_focus = nullptr; + keyboard_focus = NULL; Draw(term, 0); } break; @@ -308,7 +308,7 @@ int UserEditZone::AddStartPages(Terminal *term, FormField *field) int last_page = 0; field->ClearEntries(); - for (Page *p = term->zone_db->PageList(); p != nullptr; p = p->next) + for (Page *p = term->zone_db->PageList(); p != NULL; p = p->next) { if (p->IsStartPage() && p->id != last_page) { @@ -329,7 +329,7 @@ int UserEditZone::LoadRecord(Terminal *term, int record) FnTrace("UserEditZone::LoadRecord()"); System *sys = term->system_data; Employee *e = sys->user_db.FindByRecord(term, record, view_active); - if (e == nullptr) + if (e == NULL) return 1; Settings *s = &(sys->settings); @@ -432,7 +432,7 @@ int UserEditZone::SaveRecord(Terminal *term, int record, int write_file) if (f) { f->Get(e->description); f = f->next; } if (f) { f->Get(e->employee_no); f = f->next; } - for (JobInfo *j = e->JobList(); j != nullptr && f != nullptr; j = j->next) + for (JobInfo *j = e->JobList(); j != NULL && f != NULL; j = j->next) { f = f->next; if (f) { f->Get(j->job); f = f->next; } @@ -455,7 +455,7 @@ int UserEditZone::SaveRecord(Terminal *term, int record, int write_file) // Critical fix: Only save if we have a valid employee record - if (write_file && e != nullptr) + if (write_file && e != NULL) term->system_data->user_db.Save(); return 0; } @@ -467,7 +467,7 @@ int UserEditZone::NewRecord(Terminal *term) user = term->system_data->user_db.NewUser(); // Critical fix: Check if NewUser() succeeded - if (user == nullptr) + if (user == NULL) { fprintf(stderr, "ERROR: Failed to create new user record\n"); return 1; // Return error instead of continuing with NULL user @@ -481,11 +481,11 @@ int UserEditZone::NewRecord(Terminal *term) int UserEditZone::KillRecord(Terminal *term, int record) { FnTrace("UserEditZone::KillRecord()"); - if (user == nullptr || term->IsUserOnline(user)) + if (user == NULL || term->IsUserOnline(user)) return 1; term->system_data->user_db.Remove(user); delete user; - user = nullptr; + user = NULL; return 0; } @@ -527,20 +527,20 @@ JobSecurityZone::JobSecurityZone() columns = 11; int i; - for (i = 1; JobName[i] != nullptr; ++i) + for (i = 1; JobName[i] != NULL; ++i) { AddLabel(JobName[i], 17); - AddListField("", MarkName, nullptr, 0, 4); + AddListField("", MarkName, NULL, 0, 4); AddSpace(1); - AddListField("", MarkName, nullptr, 0, 7); - AddListField("", MarkName, nullptr, 0, 7); - AddListField("", MarkName, nullptr, 0, 7); - AddListField("", MarkName, nullptr, 0, 7); - AddListField("", MarkName, nullptr, 0, 7); - AddListField("", MarkName, nullptr, 0, 7); - AddListField("", MarkName, nullptr, 0, 7); - AddListField("", MarkName, nullptr, 0, 7); - AddListField("", MarkName, nullptr, 0, 7); + AddListField("", MarkName, NULL, 0, 7); + AddListField("", MarkName, NULL, 0, 7); + AddListField("", MarkName, NULL, 0, 7); + AddListField("", MarkName, NULL, 0, 7); + AddListField("", MarkName, NULL, 0, 7); + AddListField("", MarkName, NULL, 0, 7); + AddListField("", MarkName, NULL, 0, 7); + AddListField("", MarkName, NULL, 0, 7); + AddListField("", MarkName, NULL, 0, 7); AddNewLine(); } } @@ -587,7 +587,7 @@ int JobSecurityZone::DisablingCategory() int counter = 0; int is_active = 0; // container for the field's value - while (field != nullptr && retval == 0) + while (field != NULL && retval == 0) { // Every 'columns' columns, we have the label. The next // field over is the "active" field for the current job, @@ -605,7 +605,7 @@ int JobSecurityZone::DisablingCategory() retval = ((counter - 1) / columns) + 1; } } - if (field != nullptr) + if (field != NULL) field = field->next; counter += 1; } @@ -620,14 +620,14 @@ int JobSecurityZone::EmployeeIsUsing(Terminal *term, int active_job) { FnTrace("JobSecurityZone::EmployeeIsUsing()"); int retval = 0; - Employee *employee = nullptr; - JobInfo *jobinfo = nullptr; + Employee *employee = NULL; + JobInfo *jobinfo = NULL; employee = MasterSystem->user_db.UserList(); - while (employee != nullptr && retval == 0) + while (employee != NULL && retval == 0) { jobinfo = employee->JobList(); - while (jobinfo != nullptr && retval == 0) + while (jobinfo != NULL && retval == 0) { if (jobinfo->job == active_job) retval = 1; @@ -644,19 +644,19 @@ SignalResult JobSecurityZone::Signal(Terminal *term, const char* message) { FnTrace("JobSecurityZone::Signal()"); SignalResult retval = SIGNAL_IGNORED; - static const genericChar* commands[] = { "jsz_no", "jsz_yes", nullptr}; + static const genericChar* commands[] = { "jsz_no", "jsz_yes", NULL}; int idx = CompareListN(commands, message); switch (idx) { case 0: - last_focus = nullptr; + last_focus = NULL; break; case 1: - if (last_focus != nullptr) + if (last_focus != NULL) { keyboard_focus = last_focus; - last_focus = nullptr; + last_focus = NULL; keyboard_focus->Touch(term, this, keyboard_focus->x + 1, keyboard_focus->y + 1); UpdateForm(term, 0); Draw(term, 0); @@ -675,11 +675,11 @@ SignalResult JobSecurityZone::Touch(Terminal *term, int tx, int ty) FnTrace("JobSecurityZone::Touch()"); int active_cat = 0; int is_used = 0; - SimpleDialog *sdialog = nullptr; + SimpleDialog *sdialog = NULL; if (records <= 0) return SIGNAL_IGNORED; - FormZone::Touch(term, tx, ty); + LayoutZone::Touch(term, tx, ty); // It's bad to disable a job category when there are employee's configured // for that job. We'll allow it, but only after a confirmation. @@ -733,7 +733,7 @@ int JobSecurityZone::LoadRecord(Terminal *term, int record) f = f->next; // Active switch - f->Set(static_cast(a)); f = f->next; + f->Set(a); f = f->next; // tables f->active = a; diff --git a/zone/user_edit_zone.hh b/zone/user_edit_zone.hh index 913d816f..9cfe2a9d 100644 --- a/zone/user_edit_zone.hh +++ b/zone/user_edit_zone.hh @@ -19,7 +19,7 @@ */ #ifndef _USER_EDIT_ZONE_HH -#define USER_EDIT_ZONE_HH +#define _USER_EDIT_ZONE_HH #include "form_zone.hh" @@ -38,21 +38,21 @@ public: UserEditZone(); // Member Functions - int Type() override { return ZONE_USER_EDIT; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const char* message) override; - int Update(Terminal *term, int update_message, const char* value) override; - Flt *Spacing() override { return &list_spacing; } + int Type() { return ZONE_USER_EDIT; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Signal(Terminal *term, const char* message); + int Update(Terminal *term, int update_message, const char* value); + Flt *Spacing() { return &list_spacing; } int AddStartPages(Terminal *term, FormField *field); - int LoadRecord(Terminal *term, int record) override; - int SaveRecord(Terminal *term, int record, int write_file) override; - int NewRecord(Terminal *t) override; - int KillRecord(Terminal *term, int record) override; - int PrintRecord(Terminal *term, int record) override; - int Search(Terminal *term, int record, const char* word) override; - int ListReport(Terminal *term, Report *r) override; - int RecordCount(Terminal *term) override; + int LoadRecord(Terminal *term, int record); + int SaveRecord(Terminal *term, int record, int write_file); + int NewRecord(Terminal *t); + int KillRecord(Terminal *term, int record); + int PrintRecord(Terminal *term, int record); + int Search(Terminal *term, int record, const char* word); + int ListReport(Terminal *term, Report *r); + int RecordCount(Terminal *term); }; // Job Security settings @@ -68,14 +68,14 @@ public: JobSecurityZone(); // Member Functions - int Type() override { return ZONE_JOB_SECURITY; } - RenderResult Render(Terminal *term, int update_flag) override; - SignalResult Signal(Terminal *term, const char* message) override; - SignalResult Touch(Terminal *term, int tx, int ty) override; - SignalResult Mouse(Terminal *term, int action, int mx, int my) override; - int LoadRecord(Terminal *term, int record) override; - int SaveRecord(Terminal *term, int record, int write_file) override; - int UpdateForm(Terminal *term, int record) override; + int Type() { return ZONE_JOB_SECURITY; } + RenderResult Render(Terminal *term, int update_flag); + SignalResult Signal(Terminal *term, const char* message); + SignalResult Touch(Terminal *term, int tx, int ty); + SignalResult Mouse(Terminal *term, int action, int mx, int my); + int LoadRecord(Terminal *term, int record); + int SaveRecord(Terminal *term, int record, int write_file); + int UpdateForm(Terminal *term, int record); }; #endif diff --git a/zone/video_zone.cc b/zone/video_zone.cc index 4fe91b5c..9730cd92 100644 --- a/zone/video_zone.cc +++ b/zone/video_zone.cc @@ -47,7 +47,7 @@ int VideoTargetZone::AddFields() int i = 0; // Ensure we don't go beyond the array bounds and handle NULL entries - while (i < MAX_FAMILIES && FamilyName[i] != nullptr) + while (i < MAX_FAMILIES && FamilyName[i] != NULL) { AddListField(MasterLocale->Translate(FamilyName[i]), PrinterIDName, PrinterIDValue); diff --git a/zone/video_zone.hh b/zone/video_zone.hh index 5d3b8f1f..b7b30ac5 100644 --- a/zone/video_zone.hh +++ b/zone/video_zone.hh @@ -33,10 +33,10 @@ public: VideoTargetZone(); // Member Functions - int Type() override { return ZONE_VIDEO_TARGET; } + int Type() { return ZONE_VIDEO_TARGET; } int AddFields(); - RenderResult Render(Terminal *t, int update_flag) override; + RenderResult Render(Terminal *t, int update_flag); - int LoadRecord(Terminal *t, int record) override; - int SaveRecord(Terminal *t, int record, int write_file) override; + int LoadRecord(Terminal *t, int record); + int SaveRecord(Terminal *t, int record, int write_file); }; diff --git a/zone/zone.cc b/zone/zone.cc index 9aa9bf7a..1c281463 100644 --- a/zone/zone.cc +++ b/zone/zone.cc @@ -19,7 +19,7 @@ #include "safe_string_utils.hh" #include -#include +#include #include #include #include @@ -95,8 +95,8 @@ int Zone::CopyZone(Zone *target) *target->Expression() = *Expression(); // Copy PosZone-specific fields if both are PosZones - auto *srcPos = dynamic_cast(this); - auto *dstPos = dynamic_cast(target); + PosZone *srcPos = dynamic_cast(this); + PosZone *dstPos = dynamic_cast(target); if (srcPos && dstPos) { *dstPos->ImagePath() = *srcPos->ImagePath(); } @@ -404,7 +404,7 @@ int Zone::AlterSize(Terminal *t, int wchange, int hchange, int Zone::AlterPosition(Terminal *t, int xchange, int ychange) { FnTrace("Zone::AlterPosition()"); - if (page == nullptr) + if (page == NULL) return 1; int grid_x = t->grid_x; @@ -501,9 +501,9 @@ int Zone::RenderShadow(Terminal *t) ***********************************************************************/ Page::Page() { - next = nullptr; - fore = nullptr; - parent_page = nullptr; + next = NULL; + fore = NULL; + parent_page = NULL; id = 0; parent_id = 0; image = IMAGE_DEFAULT; @@ -548,9 +548,6 @@ int Page::Init(ZoneDB *zone_db) case SIZE_1920x1200: width = 1920; height = 1200; break; case SIZE_2560x1440: width = 2560; height = 1440; break; case SIZE_2560x1600: width = 2560; height = 1600; break; - default: - // Use default 1024x768 if size is not recognized - width = 1024; height = 768; break; } // FIX - should look up these values instead of having hardcoded values @@ -567,15 +564,12 @@ int Page::Init(ZoneDB *zone_db) case PAGE_LIBRARY: parent_id = 0; break; case PAGE_MODIFIER_KEYBOARD: parent_id = -96; break; case PAGE_INDEX_WITH_TABS: parent_id = -94; break; - default: - // Default to no parent for unrecognized page types - parent_id = 0; break; } if (zone_db) parent_page = zone_db->FindByID(parent_id, size); else - parent_page = nullptr; + parent_page = NULL; // Check for circular parent pointers int count = 0; @@ -586,7 +580,7 @@ int Page::Init(ZoneDB *zone_db) { // loop detected - kill parent pointer parent_id = 0; - parent_page = nullptr; + parent_page = NULL; break; } ++count; @@ -598,7 +592,7 @@ int Page::Init(ZoneDB *zone_db) int Page::Add(Zone *z) { FnTrace("Page::Add()"); - if (z == nullptr) + if (z == NULL) return 1; // Index Tab buttons can only be added to Index pages @@ -627,7 +621,7 @@ int Page::Add(Zone *z) int Page::AddFront(Zone *z) { FnTrace("Page::AddFront()"); - if (z == nullptr) + if (z == NULL) return 1; z->page = this; @@ -649,11 +643,11 @@ int Page::AddFront(Zone *z) int Page::Remove(Zone *z) { FnTrace("Page::Remove()"); - if (z == nullptr) + if (z == NULL) return 1; zone_list.Remove(z); - z->page = nullptr; + z->page = NULL; return 0; } @@ -715,7 +709,7 @@ RenderResult Page::Render(Terminal *term, int update_flag, int no_parent) if ((type == PAGE_ITEM || type == PAGE_ITEM2) && term->zone_db && !no_parent) { Page *indexPage = term->zone_db->FindByType(PAGE_INDEX, index, term->size); - if (indexPage == nullptr) + if (indexPage == NULL) { // Also try PAGE_INDEX_WITH_TABS indexPage = term->zone_db->FindByType(PAGE_INDEX_WITH_TABS, index, term->size); @@ -771,7 +765,7 @@ RenderResult Page::Render(Terminal *term, int update_flag, int no_parent) if ((type == PAGE_ITEM || type == PAGE_ITEM2) && term->zone_db && !no_parent) { Page *indexPage = term->zone_db->FindByType(PAGE_INDEX, index, term->size); - if (indexPage == nullptr) + if (indexPage == NULL) { indexPage = term->zone_db->FindByType(PAGE_INDEX_WITH_TABS, index, term->size); } @@ -850,7 +844,7 @@ RenderResult Page::Render(Terminal *t, int update_flag, if ((type == PAGE_ITEM || type == PAGE_ITEM2) && t->zone_db) { Page *indexPage = t->zone_db->FindByType(PAGE_INDEX, index, t->size); - if (indexPage == nullptr) + if (indexPage == NULL) { indexPage = t->zone_db->FindByType(PAGE_INDEX_WITH_TABS, index, t->size); } @@ -910,7 +904,7 @@ RenderResult Page::Render(Terminal *t, int update_flag, if ((type == PAGE_ITEM || type == PAGE_ITEM2) && t->zone_db) { Page *indexPage = t->zone_db->FindByType(PAGE_INDEX, index, t->size); - if (indexPage == nullptr) + if (indexPage == NULL) { indexPage = t->zone_db->FindByType(PAGE_INDEX_WITH_TABS, index, t->size); } @@ -953,9 +947,9 @@ SignalResult Page::Signal(Terminal *t, const genericChar* message, int group_id) SignalResult res; Page *startpage = t->page; - for (Page *p = this; p != nullptr; p = p->parent_page) + for (Page *p = this; p != NULL; p = p->parent_page) { - for (Zone *z = p->ZoneList(); z != nullptr; z = z->next) + for (Zone *z = p->ZoneList(); z != NULL; z = z->next) { if (z->AcceptSignals() && z->active && @@ -988,9 +982,9 @@ SignalResult Page::Keyboard(Terminal *t, int key, int state) SignalResult sig = SIGNAL_IGNORED; Page *startpage = t->page; - for (Page *p = this; p != nullptr; p = p->parent_page) + for (Page *p = this; p != NULL; p = p->parent_page) { - for (Zone *z = p->ZoneList(); z != nullptr; z = z->next) + for (Zone *z = p->ZoneList(); z != NULL; z = z->next) { if (z->active) { @@ -1037,7 +1031,7 @@ Zone *Page::FindZone(Terminal *t, int x, int y) if ((type == PAGE_ITEM || type == PAGE_ITEM2) && t->zone_db) { Page *indexPage = t->zone_db->FindByType(PAGE_INDEX, index, t->size); - if (indexPage == nullptr) + if (indexPage == NULL) { indexPage = t->zone_db->FindByType(PAGE_INDEX_WITH_TABS, index, t->size); } @@ -1054,7 +1048,7 @@ Zone *Page::FindZone(Terminal *t, int x, int y) } } - return nullptr; + return NULL; } Zone *Page::FindEditZone(Terminal *t, int x, int y) @@ -1081,7 +1075,7 @@ Zone *Page::FindEditZone(Terminal *t, int x, int y) if ((type == PAGE_ITEM || type == PAGE_ITEM2) && t->zone_db) { Page *indexPage = t->zone_db->FindByType(PAGE_INDEX, index, t->size); - if (indexPage == nullptr) + if (indexPage == NULL) { indexPage = t->zone_db->FindByType(PAGE_INDEX_WITH_TABS, index, t->size); } @@ -1098,7 +1092,7 @@ Zone *Page::FindEditZone(Terminal *t, int x, int y) } } - return nullptr; + return NULL; } Zone *Page::FindTranslateZone(Terminal *t, int x, int y) @@ -1124,7 +1118,7 @@ Zone *Page::FindTranslateZone(Terminal *t, int x, int y) if ((type == PAGE_ITEM || type == PAGE_ITEM2) && t->zone_db) { Page *indexPage = t->zone_db->FindByType(PAGE_INDEX, index, t->size); - if (indexPage == nullptr) + if (indexPage == NULL) { indexPage = t->zone_db->FindByType(PAGE_INDEX_WITH_TABS, index, t->size); } @@ -1141,7 +1135,7 @@ Zone *Page::FindTranslateZone(Terminal *t, int x, int y) } } - return nullptr; + return NULL; } int Page::IsZoneOnPage(Zone *z) @@ -1269,7 +1263,7 @@ int ZoneDB::Init() for (int i = 0; sizes[i] != -1; ++i) { Page *page94 = FindByID(-94, sizes[i]); - if (page94 == nullptr) + if (page94 == NULL) { // Create template page -94 for Index with Tabs Page *newPage = NewPosPage(); @@ -1277,7 +1271,7 @@ int ZoneDB::Init() { newPage->id = -94; newPage->type = PAGE_INDEX_WITH_TABS; - newPage->size = static_cast(sizes[i]); + newPage->size = sizes[i]; newPage->name.Set("Index with Tabs Template"); newPage->index = INDEX_GENERAL; newPage->Init(this); @@ -1289,9 +1283,9 @@ int ZoneDB::Init() // Ensure default Index page (page 60) exists for 1920x1080 only // Use page -94 as template if available // Check for exact size match, not just max_size - Page *page60 = nullptr; + Page *page60 = NULL; Page *currPage = page_list.Head(); - while (currPage != nullptr) + while (currPage != NULL) { if (currPage->id == 60 && currPage->size == SIZE_1920x1080) { @@ -1301,12 +1295,12 @@ int ZoneDB::Init() currPage = currPage->next; } - if (page60 == nullptr) + if (page60 == NULL) { // Try to use page -94 as template (check for exact size match) - Page *templatePage = nullptr; + Page *templatePage = NULL; currPage = page_list.Head(); - while (currPage != nullptr) + while (currPage != NULL) { if (currPage->id == -94 && currPage->size == SIZE_1920x1080) { @@ -1316,7 +1310,7 @@ int ZoneDB::Init() currPage = currPage->next; } - if (templatePage != nullptr) + if (templatePage != NULL) { // Copy from template page -94 auto pageCopy = templatePage->Copy(); @@ -1432,7 +1426,7 @@ int ZoneDB::Load(const char* filename) int ZoneDB::Save(const char* filename, int page_class) { FnTrace("ZoneDB::Save()"); - if (filename == nullptr) + if (filename == NULL) return 1; // Count pages to save @@ -1499,14 +1493,14 @@ int ZoneDB::ImportPage(const char* filename) int retval = 0; int pagenum; int idx; - int len = static_cast(strlen(filename)); - Page *newpage = nullptr; + int len = strlen(filename); + Page *newpage = NULL; InputDataFile infile; int version = 0; char str[STRLONG]; int count = 0; - SalesItem *salesitem = nullptr; - SalesItem *olditem = nullptr; + SalesItem *salesitem = NULL; + SalesItem *olditem = NULL; idx = len - 1; while (idx > 0 && filename[idx - 1] != '_') @@ -1526,7 +1520,7 @@ int ZoneDB::ImportPage(const char* filename) return 1; // Error } newpage = NewPosPage(); - if (newpage != nullptr) + if (newpage != NULL) { newpage->Read(infile, version); newpage->id = pagenum; @@ -1539,7 +1533,7 @@ int ZoneDB::ImportPage(const char* filename) salesitem = new SalesItem(); salesitem->Read(infile, SALES_ITEM_VERSION); olditem = MasterSystem->menu.FindByName(salesitem->item_name.Value()); - if (olditem != nullptr) + if (olditem != NULL) MasterSystem->menu.Remove(olditem); MasterSystem->menu.Add(salesitem); count -= 1; @@ -1555,18 +1549,18 @@ int ZoneDB::ImportPages() { FnTrace("ZoneDB::ImportPages()"); char importdir[STRLONG]; - DIR *dir = nullptr; - struct dirent *record = nullptr; - const char* name = nullptr; + DIR *dir = NULL; + struct dirent *record = NULL; + const char* name = NULL; char fullpath[STRLONG]; int count = 0; MasterSystem->FullPath(PAGEIMPORTS_DIR, importdir); dir = opendir(importdir); - if (dir != nullptr) + if (dir != NULL) { record = readdir(dir); - while (record != nullptr) + while (record != NULL) { name = record->d_name; if (strncmp(name, "page_", 5) == 0) @@ -1593,11 +1587,11 @@ int ZoneDB::ExportPage(Page *page) char fullpath[STRLONG]; char filepath[STRLONG]; OutputDataFile outfile; - Zone *zone = nullptr; - SalesItem *salesitem = nullptr; + Zone *zone = NULL; + SalesItem *salesitem = NULL; int count = 0; - if (page == nullptr) + if (page == NULL) return retval; MasterSystem->FullPath(PAGEEXPORTS_DIR, fullpath); @@ -1608,7 +1602,7 @@ int ZoneDB::ExportPage(Page *page) { page->Write(outfile, ZONE_VERSION); zone = page->ZoneList(); - while (zone != nullptr) + while (zone != NULL) { if (zone->ItemName()) count += 1; @@ -1616,12 +1610,12 @@ int ZoneDB::ExportPage(Page *page) } outfile.Write(count); zone = page->ZoneList(); - while (zone != nullptr) + while (zone != NULL) { if (zone->ItemName()) { salesitem = MasterSystem->menu.FindByName(zone->ItemName()->Value()); - if (salesitem != nullptr) + if (salesitem != NULL) salesitem->Write(outfile, SALES_ITEM_VERSION); } zone = zone->next; @@ -1636,7 +1630,7 @@ int ZoneDB::ExportPage(Page *page) int ZoneDB::Add(Page *p) { FnTrace("ZoneDB::Add()"); - if (p == nullptr) + if (p == NULL) return 1; // start at end of list and work backwords @@ -1652,13 +1646,13 @@ int ZoneDB::AddUnique(Page *page) { FnTrace("ZoneDB::AddUnique()"); int retval = 0; - Page *oldpage = nullptr; + Page *oldpage = NULL; int pagenum = page->id; char str[STRLENGTH]; // remove a page if there is already one at this ID (of the same size) oldpage = FindByID(pagenum, page->size); - if (oldpage != nullptr && oldpage->size == page->size) + if (oldpage != NULL && oldpage->size == page->size) { if (Remove(oldpage)) { @@ -1696,11 +1690,11 @@ Page *ZoneDB::FindByID(int id, int max_size) { FnTrace("ZoneDB::FindByID()"); if (id == 0) - return nullptr; + return NULL; - Page *retPage = nullptr; + Page *retPage = NULL; Page *currPage = page_list.Head(); - while ((retPage == nullptr) && (currPage != nullptr)) + while ((retPage == NULL) && (currPage != NULL)) { if (currPage->id == id && currPage->size <= max_size) retPage = currPage; @@ -1724,12 +1718,12 @@ Page *ZoneDB::FindByType(int type, int period, int max_size) return thisPage; } if (thisPage == page_list.Tail()) { - return nullptr; + return NULL; } else { thisPage = thisPage->next; } } - return nullptr; + return NULL; } Page *ZoneDB::FindByTerminal(int term_type, int period, int max_size) @@ -1746,7 +1740,7 @@ Page *ZoneDB::FindByTerminal(int term_type, int period, int max_size) if (type != 0) return FindByType(type, period, max_size); else - return nullptr; + return NULL; } Page *ZoneDB::FirstTablePage(int max_size) @@ -1759,7 +1753,7 @@ Page *ZoneDB::FirstTablePage(int max_size) return p; p = p->next; } - return nullptr; + return NULL; } int ZoneDB::ChangePageID(Page *target, int new_id) @@ -1776,7 +1770,7 @@ int ZoneDB::ChangePageID(Page *target, int new_id) { if (p->parent_id == old_id) p->parent_id = new_id; - for (Zone *z = p->ZoneList(); z != nullptr; z = z->next) + for (Zone *z = p->ZoneList(); z != NULL; z = z->next) z->ChangeJumpID(old_id, new_id); p = p->next; } @@ -1945,7 +1939,7 @@ int ZoneDB::CopyEdit(Terminal *t, int modify_x, int modify_y) RegionInfo r; int count = 0; - Zone *list = nullptr; + Zone *list = NULL; Page *p = page_list.Head(); while (p) { @@ -2013,7 +2007,7 @@ int ZoneDB::CopyEdit(Terminal *t, int modify_x, int modify_y) int ZoneDB::RelocateEdit(Terminal *t) { FnTrace("ZoneDB::RelocateEdit()"); - Zone *list = nullptr; + Zone *list = NULL; Page *p = page_list.Head(); while (p) { @@ -2237,7 +2231,7 @@ int ZoneDB::References(Page *page, int *list, int my_max, int &count) int ZoneDB::PageListReport(Terminal *t, int show_system, Report *r) { FnTrace("ZoneDB::PageListReport()"); - if (r == nullptr) + if (r == NULL) return 1; r->TextC("Page List", PRINT_UNDERLINE); @@ -2274,7 +2268,7 @@ int ZoneDB::ChangeItemName(const char* old_name, const genericChar* new_name) Page *thisPage = page_list.Head(); while (thisPage) { - for (Zone *z = thisPage->ZoneList(); z != nullptr; z = z->next) + for (Zone *z = thisPage->ZoneList(); z != NULL; z = z->next) { if (z->ItemName() && StringCompare(z->ItemName()->Value(), old_name) == 0) @@ -2302,7 +2296,7 @@ int ZoneDB::PrintZoneDB(const char* dest, int brief) int pcount = 0; int zcount = 0; - if (dest != nullptr) + if (dest != NULL) { outfd = open(dest, O_WRONLY | O_CREAT | O_TRUNC, 0644); if (outfd <= 0) @@ -2313,7 +2307,7 @@ int ZoneDB::PrintZoneDB(const char* dest, int brief) outfd = STDOUT_FILENO; } } - while (currPage != nullptr) + while (currPage != NULL) { if (brief == 0) { @@ -2324,7 +2318,7 @@ int ZoneDB::PrintZoneDB(const char* dest, int brief) } currZone = currPage->ZoneList(); pcount += 1; - while (currZone != nullptr) + while (currZone != NULL) { if (brief == 0) { @@ -2359,7 +2353,7 @@ int ZoneDB::ValidateSystemPages() int invalid_count = 0; Page *currPage = page_list.Head(); - while (currPage != nullptr) + while (currPage != NULL) { if (currPage->type == PAGE_SYSTEM && currPage->parent_id > 0) { diff --git a/zone/zone.hh b/zone/zone.hh index 40ac00ae..823a52a4 100644 --- a/zone/zone.hh +++ b/zone/zone.hh @@ -6,8 +6,8 @@ * Functions for managing zones on a view */ -#ifndef ZONE_HH -#define ZONE_HH +#ifndef _ZONE_HH +#define _ZONE_HH #include "utility.hh" #include "list_utility.hh" @@ -35,11 +35,11 @@ #define PAGE_MODIFIER_KEYBOARD 17 // Modifier page with keyboard (parent -96) #define PAGE_INDEX_WITH_TABS 18 // Index with tabs for quick navigation (parent -94) -#define PAGE_ID_SETTLEMENT (-20) // Where the Settlement page is in the list. -#define PAGE_ID_TABSETTLE (-85) // Where the Tab Settlement page is +#define PAGE_ID_SETTLEMENT -20 // Where the Settlement page is in the list. +#define PAGE_ID_TABSETTLE -85 // Where the Tab Settlement page is // Zone Selection Behaviors -enum behaviors : std::uint8_t { +enum behaviors { BEHAVE_NONE , // Zone doesn't change when selected BEHAVE_TOGGLE , // Zone toggles with each selection BEHAVE_BLINK , // Zone depresses then resets itself @@ -150,7 +150,7 @@ public: // Constructor Zone(); // Destructor - ~Zone() override = default; + virtual ~Zone() { } // Member Functions int Draw(Terminal *t, int update_flag); @@ -203,32 +203,32 @@ public: // boolean - can zone be copied/moved/deleted? virtual int ZoneStates() { return 2; } - virtual SalesItem *Item(ItemDB *db) { return nullptr; } + virtual SalesItem *Item(ItemDB *db) { return NULL; } // Interface for zone settings (FIX - should be moved to pos_zone module) - virtual int *Amount() { return nullptr; } // generic amount setting - virtual Str *Expression() { return nullptr; } // enable expression - virtual Str *FileName() { return nullptr; } // filename - virtual Str *ItemName() { return nullptr; } // name in ItemDB - virtual int *JumpType() { return nullptr; } // jump type - virtual int *JumpID() { return nullptr; } // target page id - virtual Str *Message() { return nullptr; } // broadcast message - virtual int *QualifierType() { return nullptr; } // qualifier type - virtual int *ReportType() { return nullptr; } // report type - virtual int *ReportPrint() { return nullptr; } // report print option - virtual Str *Script() { return nullptr; } // page script - virtual Flt *Spacing() { return nullptr; } // line spacing - virtual int *SwitchType() { return nullptr; } // setting switch type - virtual int *TenderType() { return nullptr; } // type of tender - virtual int *TenderAmount() { return nullptr; } // cash amount - virtual int *Columns() { return nullptr; } // columns to display - virtual int *CustomerType() { return nullptr; } // customer transaction type - virtual Check *GetCheck() { return nullptr; } // check belonging to zone - virtual int *CheckDisplayNum() { return nullptr; } // which check to display on kitchen video - virtual int *VideoTarget() { return nullptr; } // which kitchen video target to use - virtual int *DrawerZoneType() { return nullptr; } // pull/balance or drawer select - virtual int *Confirm() { return nullptr; } // for touch,click confirmations - virtual Str *ConfirmMsg() { return nullptr; } // message for confirmation dialogs + virtual int *Amount() { return NULL; } // generic amount setting + virtual Str *Expression() { return NULL; } // enable expression + virtual Str *FileName() { return NULL; } // filename + virtual Str *ItemName() { return NULL; } // name in ItemDB + virtual int *JumpType() { return NULL; } // jump type + virtual int *JumpID() { return NULL; } // target page id + virtual Str *Message() { return NULL; } // broadcast message + virtual int *QualifierType() { return NULL; } // qualifier type + virtual int *ReportType() { return NULL; } // report type + virtual int *ReportPrint() { return NULL; } // report print option + virtual Str *Script() { return NULL; } // page script + virtual Flt *Spacing() { return NULL; } // line spacing + virtual int *SwitchType() { return NULL; } // setting switch type + virtual int *TenderType() { return NULL; } // type of tender + virtual int *TenderAmount() { return NULL; } // cash amount + virtual int *Columns() { return NULL; } // columns to display + virtual int *CustomerType() { return NULL; } // customer transaction type + virtual Check *GetCheck() { return NULL; } // check belonging to zone + virtual int *CheckDisplayNum() { return NULL; } // which check to display on kitchen video + virtual int *VideoTarget() { return NULL; } // which kitchen video target to use + virtual int *DrawerZoneType() { return NULL; } // pull/balance or drawer select + virtual int *Confirm() { return NULL; } // for touch,click confirmations + virtual Str *ConfirmMsg() { return NULL; } // message for confirmation dialogs }; class Page @@ -263,7 +263,7 @@ public: // Constructor Page(); - virtual ~Page() = default; + virtual ~Page() { } // Member Functions Zone *ZoneList() { return zone_list.Head(); } @@ -387,7 +387,7 @@ public: int ChangeItemName(const char* old_name, const genericChar* new_name); int ValidateSystemPages(); // Check for System Pages with invalid parent_id values - int PrintZoneDB(const char* dest = nullptr, int brief = 0); // for debugging only + int PrintZoneDB(const char* dest = NULL, int brief = 0); // for debugging only }; #endif diff --git a/zone/zone_object.cc b/zone/zone_object.cc index 7ea0d720..3db9c47b 100644 --- a/zone/zone_object.cc +++ b/zone/zone_object.cc @@ -30,8 +30,8 @@ // Constructors ZoneObject::ZoneObject() { - fore = nullptr; - next = nullptr; + fore = NULL; + next = NULL; selected = 0; active = 1; font = FONT_DEFAULT; @@ -95,7 +95,7 @@ int ZoneObjectList::Remove(ZoneObject *zo) int ZoneObjectList::CountSelected() { int count = 0; - for (ZoneObject *zo = List(); zo != nullptr; zo = zo->next) + for (ZoneObject *zo = List(); zo != NULL; zo = zo->next) if (zo->selected && zo->active) ++count; return count; @@ -109,15 +109,15 @@ int ZoneObjectList::Purge() ZoneObject *ZoneObjectList::Find(int x, int y) { - for (ZoneObject *zo = List(); zo != nullptr; zo = zo->next) + for (ZoneObject *zo = List(); zo != NULL; zo = zo->next) if (zo->IsPointIn(x, y) && zo->active) return zo; - return nullptr; + return NULL; } int ZoneObjectList::Render(Terminal *t) { - for (ZoneObject *zo = List(); zo != nullptr; zo = zo->next) + for (ZoneObject *zo = List(); zo != NULL; zo = zo->next) if (zo->active && zo->w > 0 && zo->h > 0) zo->Render(t); return 0; @@ -125,14 +125,14 @@ int ZoneObjectList::Render(Terminal *t) int ZoneObjectList::SetActive(int val) { - for (ZoneObject *zo = List(); zo != nullptr; zo = zo->next) + for (ZoneObject *zo = List(); zo != NULL; zo = zo->next) zo->active = val; return 0; } int ZoneObjectList::SetSelected(int val) { - for (ZoneObject *zo = List(); zo != nullptr; zo = zo->next) + for (ZoneObject *zo = List(); zo != NULL; zo = zo->next) zo->selected = val; return 0; } @@ -146,7 +146,7 @@ int ZoneObjectList::LayoutRows(Terminal *t, int x, int y, int w, int h, return 0; // nothing to layout int pos = 0, ly; - for (ZoneObject *zo = List(); zo != nullptr; zo = zo->next) + for (ZoneObject *zo = List(); zo != NULL; zo = zo->next) { ly = y + ((h * pos) / no); zo->Layout(t, x, ly, w, (y + ((h * (pos + 1)) / no)) - ly); @@ -165,7 +165,7 @@ int ZoneObjectList::LayoutColumns(Terminal *t, int x, int y, int w, int h, int i = 0, s, e; int ww = w - (gap * (no - 1)); - for (ZoneObject *zo = List(); zo != nullptr; zo = zo->next) + for (ZoneObject *zo = List(); zo != NULL; zo = zo->next) { s = ((ww * i) / no) + (gap * i); e = ((ww * (i + 1)) / no) + (gap * i); @@ -199,7 +199,7 @@ int ZoneObjectList::LayoutGrid(Terminal *t, int x, int y, int w, int h, // Layout servers left to right, top to bottom r = 0; c = 0; - for (ZoneObject *zo = List(); zo != nullptr; zo = zo->next) + for (ZoneObject *zo = List(); zo != NULL; zo = zo->next) { // FIX - height/width should be calculated each time to remove error zo->Layout(t, x + (c * sw), y + (r * sh), sw, sh); diff --git a/zone/zone_object.hh b/zone/zone_object.hh index 910dbe79..149a27f3 100644 --- a/zone/zone_object.hh +++ b/zone/zone_object.hh @@ -18,8 +18,8 @@ * User Interfact componet objects */ -#ifndef ZONE_OBJECT_HH -#define ZONE_OBJECT_HH +#ifndef _ZONE_OBJECT_HH +#define _ZONE_OBJECT_HH #include "utility.hh" #include "list_utility.hh" @@ -40,7 +40,7 @@ public: // Constructors ZoneObject(); // Destructor - ~ZoneObject() override = default; + virtual ~ZoneObject() { } // Member Functions int Draw(Terminal *t);