Example #1
0
/*
 * Function: ftpp_ui_config_reset_ftp_server(FTP_SERVER_PROTO_CONF *ServerConf,
 *                                  char first)
 *
 * Purpose: This function resets a ftp server construct.
 *
 * Arguments: ServerConf    => pointer to the FTP_SERVER_PROTO_CONF structure
 *            first         => indicator whether this is a new conf
 *
 * Returns: int => return code indicating error or success
 *
 */
int ftpp_ui_config_reset_ftp_server(FTP_SERVER_PROTO_CONF *ServerConf,
                                    char first)
{
    int iRet = FTPP_SUCCESS;

    if (first == 0)
    {
        ftp_cmd_lookup_cleanup(&ServerConf->cmd_lookup);
    }
    if (ServerConf->serverAddr)
    {
        free(ServerConf->serverAddr);
    }

    memset(ServerConf, 0x00, sizeof(FTP_SERVER_PROTO_CONF));

    ServerConf->proto_ports.port_count = 1;
    ServerConf->proto_ports.ports[21] = 1;

    ftp_cmd_lookup_init(&ServerConf->cmd_lookup);

    ServerConf->def_max_param_len = FTPP_UI_CONFIG_FTP_DEF_CMD_PARAM_MAX;
    ServerConf->max_cmd_len = MAX_CMD;

    return iRet;
}
/*
 * Function: ftpp_ui_config_reset_ftp_server(FTP_SERVER_PROTO_CONF *ServerConf,
 *                                  int first)
 *
 * Purpose: This function resets a ftp server construct.
 *
 * Arguments: ServerConf    => pointer to the FTP_SERVER_PROTO_CONF structure
 *            first         => indicator whether this is a new conf
 *
 * Returns: int => return code indicating error or success
 *
 */
int ftpp_ui_config_reset_ftp_server(FTP_SERVER_PROTO_CONF *ServerConf,
                                    int first)
{
    int iRet;
    FTP_CMD_CONF *NextFTPCmd = NULL;

    if (!first)
    {
        do
        {
            NextFTPCmd = ftp_cmd_lookup_first(ServerConf->cmd_lookup, &iRet);

            if (NextFTPCmd)
            {
                ftpp_ui_config_reset_ftp_cmd(NextFTPCmd);
                free(NextFTPCmd);
            }

            NextFTPCmd = ftp_cmd_lookup_next(ServerConf->cmd_lookup, &iRet);
        }
        while ((NextFTPCmd != NULL) && (iRet == FTPP_SUCCESS));

        ftp_cmd_lookup_cleanup(&ServerConf->cmd_lookup);
    }

    memset(ServerConf, 0x00, sizeof(FTP_SERVER_PROTO_CONF));

    ServerConf->proto_ports.port_count = 1;
    ServerConf->proto_ports.ports[21] = 1;

    ftp_cmd_lookup_init(&ServerConf->cmd_lookup);

    ServerConf->def_max_param_len = FTPP_UI_CONFIG_FTP_DEF_CMD_PARAM_MAX;

    return FTPP_SUCCESS;
}