Exemplo: Programa de saída de Início de Sessão do Servidor de FTP em código de CL

Este é um exemplo de um programa de saída simples de Início de Sessão do Servidor de FTP na Linguagem de Comandos (CL) do iSeries AS/400. Destina-se ao formato de ponto de saída TCPL0100.

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 o programa, 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.     */
     /*                                                                            */
     /******************************************************************************/
     /*                                                                            */
     /*    Sample FTP server logon exit program.                                   */
     /*    Note:  This program is a sample only and has not undergone any formal   */ 
     /*           review or testing.                                               */ 
     /*                                                                            */
     /*  Additional notes:                                                         */ 
     /*  1. When the FTP server logon exit is called, the FTP server job is        */ 
     /*     running under the QTCP user profile.                                   */ 
     /*  2. For the ANONYMOUS case, users can add logging capability (for          */ 
     /*     example, write the E-mail address entered for the password and         */ 
     /*     the client IP address to a log file).                                  */ 
     /*  3. IBM strongly recommends that you create the exit program in a library  */ 
     /*     with *PUBLIC authority set to *EXCLUDE, and give the exit program      */ 
     /*     itself a *PUBLIC authority of *EXCLUDE.  The FTP server adopts         */ 
     /*     authority when it is necessary to resolve and call the exit program.   */ 
     /*                                                                            */ 
     /******************************************************************************/ 
      TSTLOGCL:   PGM        PARM(&APPIDIN &USRIN &USRLENIN &AUTIN &AUTLENIN + 
                               &IPADDRIN &IPLENIN &RETCDOUT &USRPRFOUT &PASSWDOUT + 
                               &CURLIBOUT); 
 
 
      /* Declare input parameters */ 
                  DCL        VAR(&APPIDIN);   TYPE(*CHAR) LEN(4)  /* Application identifier  */ 
                  DCL        VAR(&USRIN);     TYPE(*CHAR) LEN(999)/* User ID                 */ 
                  DCL        VAR(&USRLENIN);  TYPE(*CHAR) LEN(4)  /* Length of user ID       */ 
                  DCL        VAR(&AUTIN);     TYPE(*CHAR) LEN(999)/* Authentication string   */ 
                  DCL        VAR(&AUTLENIN);  TYPE(*CHAR) LEN(4)  /* Length of auth. string  */ 
                  DCL        VAR(&IPADDRIN);  TYPE(*CHAR) LEN(15) /* Client IP address       */ 
                  DCL        VAR(&IPLENIN);   TYPE(*CHAR) LEN(4)  /* IP address length       */ 
                  DCL        VAR(&RETCDOUT);  TYPE(*CHAR) LEN(4)  /* return code (out)       */ 
                  DCL        VAR(&USRPRFOUT); TYPE(*CHAR) LEN(10) /* user profile (out)      */ 
                  DCL        VAR(&PASSWDOUT); TYPE(*CHAR) LEN(10) /* password (out)          */ 
                  DCL        VAR(&CURLIBOUT); TYPE(*CHAR) LEN(10) /* current library (out)   */ 
 
     /* Declare local copies of parameters (in format usable by CL) */ 
                  DCL        VAR(&APPID);     TYPE(*DEC)  LEN(1 0) 
                  DCL        VAR(&USRLEN); TYPE(*DEC) LEN(5 0) 
                  DCL        VAR(&AUTLEN); TYPE(*DEC) LEN(5 0) 
                  DCL        VAR(&IPLEN); TYPE(*DEC) LEN(5 0) 
 
     /* Assign input parameters to local copies */ 
                  CHGVAR     VAR(&APPID); VALUE(%BINARY(&APPIDIN)); 
                  CHGVAR     VAR(&USRLEN); VALUE(%BINARY(&USRLENIN)); 
                  CHGVAR     VAR(&AUTLEN); VALUE(%BINARY(&AUTLENIN)); 
                  CHGVAR     VAR(&IPLEN); VALUE(%BINARY(&IPLENIN)); 
 
     /* Check for ANONYMOUS user.  Allow for ANONYMOUSA, and so forth as "regular"  */ 
     /* user profile. */ 
                  IF         COND(&USRLEN = 9) THEN(DO) 
                    IF       COND(%SST(&USRIN 1 9) = 'ANONYMOUS') THEN(DO) 
     /* For anonymous user: want to force user profile ANONYMOUS current library to PUBLIC. */ 
                      CHGVAR VAR(%BINARY(&RETCDOUT)); VALUE(6) 
                      CHGVAR VAR(&USRPRFOUT); VALUE('ANONYMOUS ') 
                      CHGVAR VAR(&CURLIBOUT); VALUE('PUBLIC    ') 
                  ENDDO 
     /* Any other user: proceed with normal logon processing. */ 
                  ELSE       CMD(CHGVAR VAR(%BINARY(&RETCDOUT)); VALUE(1)) 
                  ENDDO 
                  ELSE       CMD(CHGVAR VAR(%BINARY(&RETCDOUT)); VALUE(1)) 
 
      END:        ENDPGM 


 

Crie um site grátis Webnode