Exemplo: Programa de saída de Início de Sessão do Servidor de FTP em código RPG de ILE
Este é um exemplo de um programa de saída simples de Início de Sessão do Servidor de FTP em RPG de ILE.
Nota: | Nota: Estes exemplos destinam-se apenas a fins ilustrativos. Não têm funções suficientes para serem executados numa máquina de produção tal como estão. Pode utilizá-los à vontade como ponto de partida ou para copiar secções de código à medida que escreve os seus programas. Assim que escrever os programas, terá de os testar. |
O texto pré-formatado no exemplo seguinte irá ultrapassar os limites da estrutura.
* Module Description *********************************************** * * ******************************************************************** * * * DISCLAIMER: This material contains programming source code * * for your consideration. These examples have not been thoroughly * * tested under all conditions. IBM, therefore, cannot guarantee * * or imply reliability, serviceability, performance or function of * * these programs. All programs contained herein are provided to * * you "AS IS". THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * * FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY DISCLAIMED. * * * * LIMITATION OF LIABILITY: Neither IBM nor the author shall * * be liable for any claims or damages whatsoever, including * * property damage, personal injury, intellectual property * * infringement, loss of profits, or interruption of business, or * * for any special, consequential or incidental damages, however * * caused, whether arising out of breach of warranty, contract, * * tort (including negligence), strict liability, or otherwise. * * * ******************************************************************** * * * PROGRAM FUNCTION * * * * This program demonstrates some of the abilities an FTP Server * * Logon Exit Program can have. * * * ******************************************************************** F/SPACE 3 ******************************************************************** * * * INDICATOR USAGE * * * * IND. DESCRIPTION * * * * LR - CLOSE FILES ON EXIT * * * ******************************************************************** F/EJECT ******************************************************************** * DATA STRUCTURES USED BY THIS PROGRAM * ******************************************************************** * * Define constants * D Anonym C CONST('ANONYMOUS ') D Text1 C CONST('Anonymous (') D Text2 C CONST(') FTP logon') D InvalidNet C CONST('10.') C/EJECT ******************************************************************** * VARIABLE DEFINITIONS AND LISTS USED BY THIS PROGRAM * ******************************************************************** C/SPACE 2 * * Define binary parameters * D APPIDds S 10I 0 D USRLENds S 10I 0 D AUTLENds S 10I 0 D IPLENds S 10I 0 D RETCDds S 10I 0 * * Define parameter list * C *Entry PLIST * Input parameters: C PARM APPIDIN Application ID * possible values: 1 = FTP Server Program C PARM USRIN 999 User ID C PARM USRLENIN Length of User ID C PARM AUTIN 999 Authentication Strg C PARM AUTLENIN Length of Auth. Strg C PARM IPADDRIN 15 Client IP Address C PARM IPLENIN Length of IP Address * Return parameters: C PARM RETCDOUT Return Code (Out) * possible values: 0 = Reject Logon * 1 = Continue Logon * 2 = Continue Logon, * override current * library * 3 = Continue Logon, * override user prf, * password * 4 = Continue Logon, * override user prf, * password, current * library * 5 = Accept logon with * user prf returned * 6 = Accept logon with * user prf returned, * override current * library C PARM USRPRFOUT 10 User Profile (Out) C PARM PASSWDOUT 10 Password (Out) C PARM CURLIBOUT 10 Current Lib. (Out) C/EJECT ******************************************************************** * THE MAIN PROGRAM * ******************************************************************** * * Check for ANONYMOUS user * C USRLENIN SUBST(P) USRIN:1 User 10 C User IFEQ Anonym C MOVEL Anonym USRPRFOUT * * Check if the user entered something as an e-mail address * C AUTLENIN IFGT *ZERO E-mail addr. entered * * Check if the E-mail address is a valid one * C Z-ADD 0 i 3 0 C '@' SCAN AUTIN:1 i Valid E-mail address * contains @ character * C i IFGT 0 Found a '@' C AUTLENIN SUBST(P) AUTIN:1 Email 30 C Z-ADD 5 RETCDOUT Accept Logon * * Log Anonymous FTP Logon to message queue QSYSOPR * (The logging should be done to a secure physical file!!!!!!!) * C Text1 CAT(p) Email:0 Message 43 C Message CAT(p) Text2:0 Message C Message DSPLY 'QSYSOPR' * C ELSE Invalid E-mail addr C Z-ADD 0 RETCDOUT Reject Logon attempt C ENDIF * C ELSE No E-mail address C Z-ADD 0 RETCDOUT Reject Logon attempt C ENDIF * C ELSE * * Any Other User: Proceed with Normal Logon Processing, but the Client address must not belong * to network 10.xxx.xxx.xxx * C SUBST IPADDRIN:1 TheNet 3 C TheNet IFEQ InvalidNet Wrong Net C Z-ADD 0 RETCDOUT Reject Logon attempt C ELSE Right Net C Z-ADD 1 RETCDOUT Continue with Logon C ENDIF * C ENDIF * C EVAL *INLR = *ON C RETURN |