# getimlst.src

# $Id: getimlst.src,v 1.1 2002/03/15 01:43:13 rswindell Exp $

# @format.tab-size 8, @format.use-tabs true

###############################################################################
#     Baja module for obtaining Instant Message List from ftp.synchro.net     #
#	        Requires Synchronet v3.00d and Baja v2.30		      #
#			Developed 2001 by Rob Swindell 			      #
###############################################################################

# Add "GETIMLST" as a timed-event in SCFG->External Programs->Timed Events

!include sbbsdefs.inc
!include file_io.inc

# Variables
int sock port
str addr user password 
str local_file

set _ftp_mode FTP_PASV

# Process command line arguments
set addr "ftp.synchro.net"
set user "anonymous"
set password "getimlst@%q"

socket_open sock
if_false
	lprintf "GETIMLST: !socket_open failure socket_error=%d" _socket_error
	goto exit
	end_if

set port 21	# default FTP port
lprintf "GETIMLST: Connecting to %s ... " addr
socket_connect sock addr port 
if_false
	lprintf "GETIMLST: !socket_connect failed socket_error=%d" _socket_error
	goto exit
	end_if
lprintf "GETIMLST: Connected to %s" addr

lprintf "GETIMLST: Logging in as '%s' (PW: '%s')" user password
ftp_login sock user password
if_false
	lprintf "GETIMLST: !ftp_login failed socket_error=%d" _socket_error
	goto exit
	end_if

lprintf "GETIMLST: Logged in successfully"

#################
# Download List #
#################
set str "sbbsimsg.lst"
sprintf local_file "%%k%s" str
lprintf "GETIMLST: Downloading Instant Message system list: %s" str
ftp_get sock str local_file
if_true
	lprintf "GETIMLST: Downloaded %s successfully" str
else
	lprintf "GETIMLST: %s NOT downloaded!" str
	end_if

#################
# Exit routine	#
#################
:exit
lprintf "GETIMLST: Done."

# End of GETIMLST.SRC
