...
| Code Block |
|---|
This module lets users download files from subdirectory DNLDIR on the Worldgroup server computer. Users of this service type in a filename (that they must know somehow), and choose a protocol to download it. ###### init\_\_downloader() This routine registers the downloading module using the description in the GALDNX.MDF file. ###### dnlinp() This routine handles text line input from the user after he selects this download service. Upon entry, the user is prompted for the filename. If he presses enter, he’s returned to the parent menu page without any downloading. If there is no room to download any more files because the user’s tag table is completely full, then the user is notified (ftgsbm() does this) and he’s also returned to the parent menu. Otherwise, the tagspec structure is simply the filename, and it’s copied to the tagspec in the current tag table entry that ftgnew() identified for us. Neither the FTGWLD nor FTGABL flags are set, indicating that these will be single-file non-taggable downloads. The call to ftgsbm() turns control over to the file transfer service and a list of protocols is presented to the user. ###### tshdnl() The TSHVIS exit point declares that all files are visible if they exist. The description for the file will be file \<filename\>. In the TSHBEG exit point the path and protocol names are passed to FTF. There are no TSHEND, TSHSKP, or TSHHUP exit points coded because they only need to return 0 and do nothing else. TSHFIN restores the usrptr-\>state and returns 0, telling FTF to return control to the parent menu. ###### Potential Improvements to Download Example \#1 Here are some of the features left out of this brief example that you should consider if you are using downloads in your application: - - - - - - - - - - - Viewing the contents of compressed files, such as .ZIP filesMultiple-file downloadsChecking for conflicts between the filename and DOS devicesChecking for attempts to download files like DNLLIB\\.\WG.BATFile taggingConcatenated commandsAllowing X to exitTelling the user what files are available in the directorySysop- configurable prompts an .MSG fileSysop-configurable download directoryFull module structure in source code, with commentsAll of these features are included in download example \#2. ###### Downloading Example \#2 /\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* \* \* \* GALDNX2.C \* \* \* \* Copyright (C) 1995 GALACTICOMM, Inc. All Rights Reserved. \* \* \* \* Downloading example. \* \* \* \* - R. Stein 12/6/93 \* \* \* \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/ \#include "gcomm.h" \#include "majorbbs.h" \#include "filexfer.h" \#include "galdnx2.h" ```c ```c STATIC int dnlinp(void); STATIC int fllist(void); STATIC int tshdnl(int tshcod); STATIC void dnlfin(void); int dnlstt; /* Downloading module state number */ static FILE *dnlmb; /* file pointer for GALDNX2.MCV */ char *dnldir; /* DNLDIR download directory */ struct module dnlmodule={ /* module interface block */ "", /* name used to refer to this module */ NULL, /* user logon supplemental routine */ dnlinp, /* input routine if selected */ dfsthn, /* status-input routine if selected */ NULL, /* "injoth" routine for this module */ NULL, /* user logoff supplemental routine */ NULL, /* hangup (lost carrier) routine */ NULL, /* midnight cleanup routine */ NULL, /* delete-account routine */ dnlfin /* finish-up (sys shutdown) routine */ }; void EXPORT init__downloader(void) /* Downloader initialization */ { stzcpy(dnlmodule.descrp,gmdnam("GALDNX2.MDF"),MNMSIZ); dnlstt=register_module(&dnlmodule); dnlmb=opnmsg("GALDNX2.MCV"); dnldir=stgopt(DNLDIR); } STATIC int dnlinp(void) /* Downloader input handler */ { int rc=1; setmbk(dnlmb); if (margc == 1 && sameas(margv[0],"X")) { return(0); } do { bgncnc(); switch (usrptr->substt) { case 0: cncchr(); if (!fllist()) { cncall(); rc=0; } prfmsg(usrptr->substt=FLNAME); break; |
...