/********************************************************************************* * 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* ChangeLog: 1, Release initial version on "2019年03月14日 11时51分37秒" * ********************************************************************************/ #include #include #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; }