/*
 *
 *     Module Name: naftpapp.c
 *	       Version: 1.00
 *   Original Date: 08/23/99	
 *	        Author: Charles Gordon
 *	      Language: Ansi C
 * Compile Options:
 * Compile defines:
 *	     Libraries:
 *    Link Options:
 *
 *    Entry Points: applicationStart(), applicationTcpDown()
 *
 *  Copyrighted (c) by NETsilicon, Inc.  All Rights Reserved.
 *
 * Description.
 * =======================================================================
 * This file implements a NET+ARM FTP server application. This application
 * is used to store and retrieve data from the NET+Works board by using the 
 * "put" and "get" commands from the FTP client.It also support "mkd", "rmd"
 * and "dele" commands from the FTP client.
 *
 *
 * Edit Date/Ver   Edit Description
 * ==============  =======================================================
 * Version	Date		Initials	Change Description
 *  V1.3	6/20/00	jzw		If memory is exhausted, restore memory
 *						pointer to beginning of memory. Thus
 *						the server will be restored to a known
 *						state
 *
 *  LZ  08/08/00    Add "mkd", "rmd" & "dele" support.
 *  LZ  03/26/01    Added code in store_data() to handle different file.
 *                   
 */
 

#include <stdio.h>
#include <ctype.h>


#ifdef PSOS_OS
#include <bsp_api.h>
#include <bspfuncs.h>
#include <sys_conf.h>
#include <psos.h>
#include <pna.h>
#include <drv_intf.h>
#include <prepc.h>
#include <narm_io.h>
#include <fservapi.h>
#include <narmbrd.h>
#include <nacache.h>
#include <naosbrd.h>
#endif
#ifdef NET_OS
#include <sockapi.h>
#include <fservapi.h>
#endif

#include "fileinit.h"
#include "ftpsvrfs.h" 

int ftp_server_app_init()
{
    int rc = -1;

    /* initialize ftp server with number of users */
    if (FSInitialize(5) != NAFTPS_SUCCESS)
    {
        printf("NAFTPAPP: FSInitialize failed\n");
        goto _ret;
    }

    if (FSInstallFileSystem(FS_VOLUME1_DIR) != NAFTPS_SUCCESS)
    {
        printf("NAFTPAPP: FSInstallFileSystem failed\n");
        goto _ret;
    }

    /* start ftp server */
   rc = FSStartServer();

_ret:
    return rc;
}
