diff --git a/utils/qwknet/qwk.ini b/utils/qwknet/qwk.ini index 8e4fce2..e3dca64 100644 --- a/utils/qwknet/qwk.ini +++ b/utils/qwknet/qwk.ini @@ -1,5 +1,8 @@ [Main] Host = VERT +Ftp server = vert.synchro.net +Ftp user = username +Ftp Password = password Message Path = /home/andrew/MagickaBBS/msgs/dovenet Inbound = /home/andrew/MagickaBBS/qwk/in Outbound = /home/andrew/MagickaBBS/qwk/out diff --git a/utils/qwknet/qwknetftpc.py b/utils/qwknet/qwknetftpc.py new file mode 100644 index 0000000..4828ba5 --- /dev/null +++ b/utils/qwknet/qwknetftpc.py @@ -0,0 +1,50 @@ +from ftplib import FTP +import configparser +import os +import sys + + +def dostuff(config_file): + config = configparser.ConfigParser() + config.read(config_file) + host = config.get("Main", "Ftp Server") + username = config.get("Main", "Ftp User") + password = config.get("Main", "Ftp Password") + + ftp = FTP(host) + ftp.login(username, password) + + repfile = config.get("Main", "Outbound") + "/" + config.get("Main", "Host") + ".REP" + + exists = os.path.isfile(repfile) + + if exists: + file = open(repfile, "rb") + ftp.storbinary("STOR " + config.get("Main", "Host") + ".REP", file) + file.close() + os.remove(repfile) + print("SENT: " + config.get("Main", "Host") + ".REP") + + qwkfile = config.get("Main", "Inbound") + "/" + config.get("Main", "Host") + ".QWK" + with open(qwkfile, 'wb') as file: + def callback(data): + file.write(data) + + try: + ftp.retrbinary("RETR " + config.get("Main", "Host") + ".QWK", callback) + file.close() + print("RETREIVED: " + config.get("Main", "Host") + ".QWK") + except ftplib.error_perm: + file.close() + os.remove(qwkfile) + + + + +if __name__ == "__main__": + + if len(sys.argv) < 2: + print("Usage python qwknetftpc.py config.ini") + exit(1) + + server = dostuff(sys.argv[1]) \ No newline at end of file diff --git a/utils/qwknet/qwkscan.c b/utils/qwknet/qwkscan.c index 0927d2e..1405243 100644 --- a/utils/qwknet/qwkscan.c +++ b/utils/qwknet/qwkscan.c @@ -344,36 +344,40 @@ int main(int argc, char **argv) { fprintf(stderr, "Exporting from base %d... %d exported\n", msgbases[i]->baseno, msgcount); } - snprintf(archive, PATH_MAX, "%s/%s.REP", outbound_path, hostid); + if (qwkidx > 0) { - char *b = buffer; - size_t blen = sizeof buffer; - for (const char *p = pack_cmd; *p != '\0' && blen >= 1; ++p) { - if (*p != '*') { - *b++ = *p; - --blen; - continue; - } - p++; - size_t alen = 0; - if (*p == 'a') { - strncpy(b, archive, blen); - alen = strlen(archive); - } else if (*p == 'f') { - snprintf(b, blen, "%s/%s.MSG", temp_dir, hostid); - alen = strlen(b); - } else if (*p == '*') { - *b++ = '*'; - alen = 1; - } - b += alen; - blen -= alen; - } - *b = '\0'; + snprintf(archive, PATH_MAX, "%s/%s.REP", outbound_path, hostid); - ret = system(buffer); - if (ret == -1 || ret >> 8 == 127) { - return -1; + char *b = buffer; + size_t blen = sizeof buffer; + for (const char *p = pack_cmd; *p != '\0' && blen >= 1; ++p) { + if (*p != '*') { + *b++ = *p; + --blen; + continue; + } + p++; + size_t alen = 0; + if (*p == 'a') { + strncpy(b, archive, blen); + alen = strlen(archive); + } else if (*p == 'f') { + snprintf(b, blen, "%s/%s.MSG", temp_dir, hostid); + alen = strlen(b); + } else if (*p == '*') { + *b++ = '*'; + alen = 1; + } + b += alen; + blen -= alen; + } + *b = '\0'; + + ret = system(buffer); + if (ret == -1 || ret >> 8 == 127) { + fprintf(stderr, "Failed to run archiver!\n"); + return -1; + } } recursive_delete(temp_dir); } \ No newline at end of file