Skip to content
Snippets Groups Projects
Commit 35e31928 authored by rswindell's avatar rswindell
Browse files

Baja Module for performing QWK Networking call-outs via FTP.

parent 7a3a6c4c
No related branches found
No related tags found
No related merge requests found
# qnet-ftp.src
# $Id$
# @format.tab-size 8, @format.use-tabs true
###############################################################################
# Baja module for performing FTP-based QWKnet call-outs #
# Requires Synchronet v3.00d and Baja v2.30 #
# Developed 2001 by Rob Swindell #
###############################################################################
# Usage: *QNET-FTP HUBID ADDRESSS PASSWORD
# Example: *QNET-FTP VERT vert.synchro.net YOURPASS
# You may use the qnet-ftp.bin module INSTEAD of your normal ftp/script
# QWKnet call-out routine (exec/vert.bat). You can do this by changing
#
# SCFG->Networks->QWK->Hubs->VERT->Call-out Command Line to:
#
# *QNET-FTP VERT vert.synchro.net YOURPASS
#
# The asterisk is important! YOURPASS is your QWKnet password here on Vertrauen
.
#
# No modification or recompilation of this module should be necessary.
!include sbbsdefs.inc
!include file_io.inc
# Must be FIRST function call (or module will immediately terminate)
set _online ON_LOCAL
# Variables
int i argc argv sock port
str tmp rep qwk hubid addr user password
str cmdline
set _ftp_mode FTP_PASV
# Process command line arguments
set hubid ""
set addr ""
set password ""
# Display command line
copy cmdline str
lprintf "QNET-FTP: %s" cmdline
set argc 0
:process_args
compare_str ""
if_true
goto end_args
end_if
sprintf tmp "%.1s" str
shift_str 1
compare tmp " "
if_true
add argc 1
goto process_args
end_if
switch argc
case 0
strcat hubid tmp
end_case
case 1
strcat addr tmp
end_case
case 2
strcat password tmp
end_case
default
goto usage
end_switch
goto process_args
:usage
lprintf "QNET-FTP: !INCORRECT USAGE: %s" cmdline
return
:end_args
compare hubid ""
if_true
goto usage
end_if
compare addr ""
if_true
goto usage
end_if
compare password ""
if_true
goto usage
end_if
sprintf rep "%%j%s.rep" hubid
sprintf qwk "%%j%s.qwk" hubid
chkfile qwk
if_true
lprintf "QNET-FTP: %s already exists!" qwk
set i 0
:check_qwk
sprintf qwk "%%j%s.QW%ld" hubid i
chkfile qwk
if_true
lprintf "QNET-FTP: %s already exists!" qwk
add i 1
compare i 10
if_equal
goto exit
end_if
goto check_qwk
end_if
end_if
socket_open sock
if_false
lprintf "QNET-FTP: !socket_open failure socket_error=%d" _socket_error
goto exit
end_if
set port 21 # default FTP port
lprintf "QNET-FTP: Connecting to %s ... " addr
socket_connect sock addr port
crlf
if_false
lprintf "QNET-FTP: !socket_connect failed socket_error=%d" _socket_error
goto exit
end_if
lprintf "QNET-FTP: Connected to %s" addr
set user "%q"
lprintf "QNET-FTP: Logging in as '%s' (PW: '%s')" user password
ftp_login sock user password
if_false
lprintf "QNET-FTP: !ftp_login failed socket_error=%d" _socket_error
goto exit
end_if
lprintf "QNET-FTP: Logged in successfully"
chkfile rep
if_true
###################
# Send REP packet #
###################
lprintf "QNET-FTP: Sending REP packet: %s" rep
sprintf str "%s.rep" hubid
ftp_put sock rep str
if_false
lprintf "QNET-FTP: !ftp_put failed socket_error=%d\r\n" _socket_error
else
lprintf "QNET-FTP: REP packet sent successfully"
end_if
remove_file rep
end_if
#######################
# Download QWK packet #
#######################
sprintf str "%s.qwk" hubid
lprintf "QNET-FTP: Downloading QWK Packet: %s" str
ftp_get sock str qwk
if_true
lprintf "QNET-FTP: Downloaded %s successfully" str
else
lprintf "QNET-FTP: %s NOT downloaded (no new messages?)" str
end_if
#################
# Exit routine #
#################
:exit
lprintf "QNET-FTP: Done."
# End of QNET-FTP.SRC
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment