⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ftpconnect.c

📁 linux下ftp的库源码
💻 C
字号:
static char rcsid[] = "$Id: FtpConnect.c,v 5.0 1995/12/10 10:28:38 orel Exp $";/*	$Log: FtpConnect.c,v $ * Revision 5.0  1995/12/10  10:28:38  orel * LIBFTP Version 5.0 (Distributed revision) * * Revision 4.1  1995/09/09  09:49:42  orel *  Change type String to FtpString for clean conflicting with * X11's type string which is pointer to character only. * Thanks for MIT for this good name of type. * * Revision 4.1  1995/09/09  09:49:42  orel *  Change type String to FtpString for clean conflicting with * X11's type string which is pointer to character only. * Thanks for MIT for this good name of type. * * Revision 4.0  1995/07/11  07:00:26  orel * Libftp Version 4.0 * * Revision 3.1  1995/06/20  15:53:50  orel * *** empty log message *** * * Revision 3.0  1995/03/20  05:26:07  orel * *** empty log message *** * * Revision 2.5  1995/03/05  15:02:26  orel * / * * Revision 2.5  1995/03/05  15:02:26  orel * / * * Revision 2.4  1995/02/26  16:46:50  orel * *** empty log message *** * * Revision 2.3  1995/02/18  15:42:53  orel * modify for recurive mget * * Revision 2.3  1995/02/18  15:42:53  orel * modify for recurive mget * * Revision 2.2  1995/02/04  10:00:21  orel * *** empty log message *** * * Revision 2.2  1995/02/04  10:00:21  orel * *** empty log message *** * * Revision 2.1  1995/02/04  09:01:40  orel * add rcsid * * Revision 2.1  1995/02/04  09:01:40  orel * add rcsid **//*		      Library for ftpd clients.(libftp)			Copyright by Oleg Orel			 All rights reserved.			This  library is desined  for  free,  non-commercial  software  creation. It is changeable and can be improved. The author would greatly appreciate any  advises, new  components  and  patches  of  the  existing  programs.Commercial  usage is  also  possible  with  participation of it's author.*/#include "FtpLibrary.h"STATUS FtpConnect(FTP **con,char * hostname){  struct sockaddr_in unit;  register struct hostent *host;  register int new_socket;  FtpString S1;  STATUS x;    *con = FtpCreateObject();    if ((host=FtpGetHost(hostname))==NULL)    return EXIT((*con),QUIT);    strcpy((*con) -> title,host -> h_name); /* Default title for FtpLog */    unit.sin_family = host -> h_addrtype; /* AF_INET */    bcopy(host-> h_addr_list[0],(char *)&unit.sin_addr,host->h_length);  if ( ( new_socket = socket ( unit.sin_family , SOCK_STREAM , 0)) < 0)    return EXIT((*con),QUIT);  unit.sin_port = htons((*con)->port);    while ( connect ( new_socket , (struct sockaddr*) &unit , sizeof unit ) < 0 )    {      host -> h_addr_list ++;      if (host -> h_addr_list[0]==NULL) {	close(new_socket);	return EXIT((*con),QUIT);      }      bcopy(host -> h_addr_list[0],(char *)&unit,host->h_length);      close(new_socket);      if ( ( new_socket = socket ( unit.sin_family , SOCK_STREAM , 0)) < 0)	{	  close(new_socket);	  return EXIT((*con),QUIT);	}    }    FTPCMD(*con) = fdopen(new_socket,"r+");  if ( (x=FtpGetMessage(*con,S1)) == QUIT )    return EXIT((*con),QUIT);  if ( ! FtpGood(x,120,220,EOF))    {      close(new_socket);      return EXIT((*con),-x);    }  if ( (*con)->mode != 'A' )    {      FtpString x;      sprintf (x,"TYPE %c",(*con)->mode);      FtpSendMessage(*con,x);      FtpGetMessage(*con,x);    }  return EXIT((*con),x);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -