guowenxue
2019-06-26 0aa3153f05fe8cd51d76fd5dee9011a7d2296b7d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*********************************************************************************
 *      Copyright:  (C) 2019 LingYun IoT System Studio
 *                  All rights reserved.
 *
 *       Filename:  test.c
 *    Description:  This file i
 *                 
 *        Version:  1.0.0(2019年03月14日)
 *         Author:  Guo Wenxue <guowenxue@gmail.com>
 *      ChangeLog:  1, Release initial version on "2019年03月14日 11时51分37秒"
 *                 
 ********************************************************************************/
#include <stdio.h>
#include <unistd.h>
#include "ftplib.h"
 
 
int main (int argc, char *argv[])
{
    netbuf      *conn = NULL;
    const char  *host = "master.iot-yun.com:21";
    const char  *user = "raspberry";
    const char  *pass = "raspberry@pi";
    const char  *file = "ftplib.c";
    int          mode = 'I';  /* IMAGE, 'A' for ASCII */
    
    if ( !FtpConnect(host,&conn) )
    {
        printf("Unable to connect to node %s\n%s",host,ftplib_lastresp);
        return -1;
    }
 
    if( !FtpLogin(user,pass,conn) )
    {
        printf("Login failure\n%s",FtpLastResponse(conn));
        return -2;
    }
    printf("FTP login on ok\n");
 
 
    if( !FtpPut(file, file, mode, conn) )
    {
        printf("Upload file failure: %s",FtpLastResponse(conn));
        return -3;
    }
    printf("FTP upload file ok\n");
 
    if (conn)
        FtpClose(conn);
 
    return 0;