• 大小: 65KB
    文件类型: .gz
    金币: 1
    下载: 0 次
    发布日期: 2021-06-15
  • 语言: 数据库
  • 标签: ftplib-4.0  

资源简介

ftplib is a set of routines that implement the FTP protocol. They allow applications to create and access remote files through function calls instead of needing to fork and exec an interactive ftp client program. ftplib has been built and tested on Linux (X86), Mac OS-X and OpenVMS (AXP). Coming soon: I am working on a version that uses autotools. This should be release shortly.

资源截图

代码片段和文件信息

/***************************************************************************/
/*    */
/* ftplib.c - callable ftp access routines    */
/* Copyright (C) 1996-2001 2013 Thomas Pfau tfpfau@gmail.com    */
/* 1407 Thomas Ave North Brunswick NJ 08902    */
/*    */
/* This library is free software.  You can redistribute it and/or    */
/* modify it under the terms of the Artistic License 2.0.    */
/*     */
/* This library is distributed in the hope that it will be useful    */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of    */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    */
/* Artistic License 2.0 for more details.    */
/*     */
/* See the file LICENSE or     */
/* http://www.perlfoundation.org/artistic_license_2_0    */
/*     */
/***************************************************************************/

#if defined(__unix__) || defined(__VMS)
#include 
#endif
#if defined(_WIN32)
#include 
#endif
#include 
#include 
#include 
#include 
#include 
#if defined(__unix__)
#include 
#include 
#include 
#include 
#include 
#include 
#elif defined(VMS)
#include 
#include 
#include 
#include 
#include 
#elif defined(_WIN32)
#include 
#endif
#if defined(__APPLE__)
#undef _REENTRANT
#endif

#define BUILDING_LIBRARY
#include “ftplib.h“

#if defined(__UINT64_MAX) && !defined(PRIu64)
#if ULONG_MAX == __UINT32_MAX
#define PRIu64 “llu“
#else
#define PRIu64 “lu“
#endif
#endif

#if defined(_WIN32)
#define SETSOCKOPT_OPTVAL_TYPE (const char *)
#else
#define SETSOCKOPT_OPTVAL_TYPE (void *)
#endif

#define FTPLIB_BUFSIZ 8192
#define RESPONSE_BUFSIZ 1024
#define TMP_BUFSIZ 1024
#define ACCEPT_TIMEOUT 30

#define FTPLIB_CONTROL 0
#define FTPLIB_READ 1
#define FTPLIB_WRITE 2

#if !defined FTPLIB_DEFMODE
#define FTPLIB_DEFMODE FTPLIB_PASSIVE
#endif

struct NetBuf {
    char *cput*cget;
    int handle;
    int cavailcleft;
    char *buf;
    int dir;
    netbuf *ctrl;
    netbuf *data;    
    int cmode;
    struct timeval idletime;
    FtpCallback idlecb;
    void *idlearg;
    unsigned long int xfered;
    unsigned long int cbbytes;
    unsigned long int xfered1;
    char response[RESPONSE_BUFSIZ];
};

static char *version =
    “ftplib Release 4.0 07-Jun-2013 copyright 1996-2003 2013 Thomas Pfau“;

GLOBALDEF int ftplib_debug = 0;

#if defined(__unix__) || defined(VMS)
int net_read(int fd char *buf size_t len)
{
    while ( 1 )
    {
int c = read(fd buf len);
if ( c == -1 )
{
    if ( errno != EINTR && errno != EAGAIN )
return -1;
}
else
{
    return c;
}
    }
}

int net_write(int fd const char *buf size_t len)
{
    int done = 0;
    while ( len > 0 )
    {
int c = write( fd buf len );
if ( c == -1 )
{
    if ( errno != EINTR && errno != EA

评论

共有 条评论

相关资源