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

📄 ncftp.h

📁 ReactOS是一些高手根据Windows XP的内核编写出的类XP。内核实现机理和API函数调用几乎相同。甚至可以兼容XP的程序。喜欢研究系统内核的人可以看一看。
💻 H
📖 第 1 页 / 共 2 页
字号:
/* ncftp.h
 *
 * Copyright (c) 1996-2001 Mike Gleason, NCEMRSoft.
 * All rights reserved.
 *
 */

#ifndef _ncftp_h_
#define _ncftp_h_ 1

#define kLibraryVersion "@(#) LibNcFTP 3.0.6 (April 14, 2001)"

#if defined(WIN32) || defined(_WINDOWS)
#	define longest_int LONGLONG
#	define longest_uint ULONGLONG
#	ifndef HAVE_LONG_LONG
#		define HAVE_LONG_LONG 1
#	endif
#	ifndef SCANF_LONG_LONG
#		define SCANF_LONG_LONG "%I64d"
#	endif
#	ifndef PRINTF_LONG_LONG
#		define PRINTF_LONG_LONG "%I64d"
#	endif
#	ifndef PRINTF_LONG_LONG_I64D
#		define PRINTF_LONG_LONG_I64D 1
#	endif
#	ifndef SCANF_LONG_LONG_I64D
#		define SCANF_LONG_LONG_I64D 1
#	endif
#	ifndef USE_SIO
#		define USE_SIO 1
#	endif
#	ifndef NO_SIGNALS
#		define NO_SIGNALS 1
#	endif
#else
#	include <stdio.h>
#	include <sys/time.h>
#	if !defined(__ultrix) || !defined(XTI)
#		include <sys/socket.h>
#	endif
#	include <netinet/in.h>
#	if 1 /* %config1% -- set by configure script -- do not modify */
#		ifndef USE_SIO
#			define USE_SIO 1
#		endif
#		ifndef NO_SIGNALS
#			define NO_SIGNALS 1
#		endif
#	else
#		ifndef USE_SIO
#			define USE_SIO 0
#		endif
		/* #undef NO_SIGNALS */
#	endif
#endif

#include "ncftp_errno.h"

/* This is used to verify validty of the data passed in.
 * It also specifies the minimum version that is binary-compatibile with
 * this version.  (So this may not necessarily be kLibraryVersion.)
 */
#define kLibraryMagic "LibNcFTP 3.0.6"

#ifndef longest_int
#define longest_int long long
#define longest_uint unsigned long long
#endif

#ifndef forever
#	define forever for ( ; ; )
#endif

typedef void (*FTPSigProc)(int);

typedef struct Line *LinePtr;
typedef struct Line {
	LinePtr prev, next;
	char *line;
} Line;

typedef struct LineList {
	LinePtr first, last;
	int nLines;
} LineList, *LineListPtr;

typedef struct Response {
	LineList msg;
	int codeType;
	int code;
	int printMode;
	int eofOkay;
	int hadEof;
} Response, *ResponsePtr;

#if USE_SIO && !defined(_SReadlineInfo_)
#define _SReadlineInfo_ 1
typedef struct SReadlineInfo {
	char *buf;		/* Pointer to beginning of buffer. */
	char *bufPtr;		/* Pointer to current position in buffer. */
	char *bufLim;		/* Pointer to end of buffer. */
	size_t bufSize;		/* Current size of buffer block. */
	size_t bufSizeMax;	/* Maximum size available for buffer. */
	int malloc;		/* If non-zero, malloc() was used for buf. */
	int fd;			/* File descriptor to use for I/O. */
	int timeoutLen;		/* Timeout to use, in seconds. */
	int requireEOLN;	/* When buffer is full, continue reading and discarding until \n? */
} SReadlineInfo;
#endif

typedef struct FTPLibraryInfo {
	char magic[16];				/* Don't modify this field. */
	int init;				/* Don't modify this field. */
	int socksInit;				/* Don't modify this field. */
	unsigned int defaultPort;		/* Don't modify this field. */
	char ourHostName[64];			/* Don't modify this field. */
	int hresult;				/* Don't modify this field. */
	int htried;				/* Don't modify this field. */
	char defaultAnonPassword[80];		/* You may set this after init. */
} FTPLibraryInfo, *FTPLIPtr;

typedef struct FTPConnectionInfo *FTPCIPtr;
typedef void (*FTPProgressMeterProc)(const FTPCIPtr, int);
typedef void (*FTPLogProc)(const FTPCIPtr, char *);
typedef void (*FTPConnectMessageProc)(const FTPCIPtr, ResponsePtr);
typedef void (*FTPLoginMessageProc)(const FTPCIPtr, ResponsePtr);
typedef void (*FTPRedialStatusProc)(const FTPCIPtr, int, int);
typedef void (*FTPPrintResponseProc)(const FTPCIPtr, ResponsePtr);
typedef int (*FTPFtwProc)(const FTPCIPtr cip, const char *fn, int flag);
typedef void (*FTPGetPassphraseProc)(const FTPCIPtr, LineListPtr pwPrompt, char *pass, size_t dsize);

typedef struct FTPConnectionInfo {
	char magic[16];				/* Don't modify this field. */
	char host[64];				/* REQUIRED input parameter. */
	char user[64];				/* OPTIONAL input parameter. */
	char pass[64];				/* OPTIONAL input parameter. */
	char acct[64];				/* OPTIONAL input parameter. */
	unsigned int port;			/* OPTIONAL input parameter. */
	unsigned int xferTimeout;		/* OPTIONAL input parameter. */
	unsigned int connTimeout;		/* OPTIONAL input parameter. */
	unsigned int ctrlTimeout;		/* OPTIONAL input parameter. */
	unsigned int abortTimeout;		/* OPTIONAL input parameter. */
	FILE *debugLog;				/* OPTIONAL input parameter. */
	FILE *errLog;				/* OPTIONAL input parameter. */
	FTPLogProc debugLogProc;		/* OPTIONAL input parameter. */
	FTPLogProc errLogProc;			/* OPTIONAL input parameter. */
	FTPLIPtr lip;				/* Do not modify this field. */
	int maxDials;				/* OPTIONAL input parameter. */
	int redialDelay;			/* OPTIONAL input parameter. */
	int dataPortMode;			/* OPTIONAL input parameter. */
	char actualHost[64];			/* Do not modify this field. */
	char ip[32];				/* Do not modify this field. */
	int connected;				/* Do not modify this field. */
	int loggedIn;				/* Do not modify this field. */
	int curTransferType;			/* Do not modify this field. */
	char *startingWorkingDirectory;		/* Use, but do not modify. */
	longest_int startPoint;			/* Do not modify this field. */
	int hasPASV;				/* Do not modify this field. */
	int hasSIZE;				/* Do not modify this field. */
	int hasMDTM;				/* Do not modify this field. */
	int hasREST;				/* Do not modify this field. */
	int hasNLST_d;				/* Do not modify this field. */
	int hasUTIME;				/* Do not modify this field. */
	int hasFEAT;				/* Do not modify this field. */
	int hasMLSD;				/* Do not modify this field. */
	int hasMLST;				/* Do not modify this field. */
	int usedMLS;				/* Do not modify this field. */
	int hasCLNT;				/* Do not modify this field. */
	int hasRETRBUFSIZE;			/* Do not modify this field. */
	int hasRBUFSIZ;				/* Do not modify this field. */
	int hasRBUFSZ;				/* Do not modify this field. */
	int hasSTORBUFSIZE;			/* Do not modify this field. */
	int hasSBUFSIZ;				/* Do not modify this field. */
	int hasSBUFSZ;				/* Do not modify this field. */
	int hasBUFSIZE;				/* Do not modify this field. */
	int mlsFeatures;			/* Do not modify this field. */
	int STATfileParamWorks;			/* Do not modify this field. */
	int NLSTfileParamWorks;			/* Do not modify this field. */
	struct sockaddr_in servCtlAddr;		/* Do not modify this field. */
	struct sockaddr_in servDataAddr;	/* Do not modify this field. */
	struct sockaddr_in ourCtlAddr;		/* Do not modify this field. */
	struct sockaddr_in ourDataAddr;		/* Do not modify this field. */
	int netMode;				/* Do not use or modify. */
	char *buf;				/* Do not modify this field. */
	size_t bufSize;				/* Do not modify this field. */
	FILE *cin;				/* Do not use or modify. */
	FILE *cout;				/* Do not use or modify. */
	int ctrlSocketR;			/* You may use but not modify/close. */
	int ctrlSocketW;			/* You may use but not modify/close. */
	int dataSocket;				/* You may use but not modify/close. */
	int errNo;				/* You may modify this if you want. */
	unsigned short ephemLo;			/* You may modify this if you want. */
	unsigned short ephemHi;			/* You may modify this if you want. */
	int cancelXfer;				/* You may modify this. */
	longest_int bytesTransferred;		/* Do not modify this field. */
	FTPProgressMeterProc progress;		/* You may modify this if you want. */
	int useProgressMeter;			/* Used internally. */
	int leavePass;				/* You may modify this. */
	double sec;				/* Do not modify this field. */
	double secLeft;				/* Do not modify this field. */
	double kBytesPerSec;			/* Do not modify this field. */
	double percentCompleted;		/* Do not modify this field. */
	longest_int expectedSize;		/* Do not modify this field. */
	time_t mdtm;				/* Do not modify this field. */
	time_t nextProgressUpdate;		/* Do not modify this field. */
	const char *rname;			/* Do not modify this field. */
	const char *lname;			/* Do not modify this field. */
	struct timeval t0;			/* Do not modify this field. */
	int stalled;				/* Do not modify this field. */
	int dataTimedOut;			/* Do not modify this field. */
	int eofOkay;				/* Do not use or modify. */
	char lastFTPCmdResultStr[128];		/* You may modify this if you want. */
	LineList lastFTPCmdResultLL;		/* Use, but do not modify. */
	int lastFTPCmdResultNum;		/* You may modify this if you want. */
	char firewallHost[64];			/* You may modify this. */
	char firewallUser[64];			/* You may modify this. */
	char firewallPass[64];			/* You may modify this. */
	unsigned int firewallPort;		/* You may modify this. */
	int firewallType;			/* You may modify this. */
	int require20;				/* You may modify this. */
	int usingTAR;				/* Use, but do not modify. */
	FTPConnectMessageProc onConnectMsgProc; /* You may modify this. */
	FTPRedialStatusProc redialStatusProc;	/* You may modify this. */
	FTPPrintResponseProc printResponseProc; /* You may modify this. */
	FTPLoginMessageProc onLoginMsgProc;	/* You may modify this. */
	size_t ctrlSocketRBufSize;		/* You may modify this. */
	size_t ctrlSocketSBufSize;		/* You may modify this. */
	size_t dataSocketRBufSize;		/* You may modify this. */
	size_t dataSocketSBufSize;		/* You may modify this. */
	int serverType;				/* Do not use or modify. */
	int ietfCompatLevel;			/* Do not use or modify. */
	int numDownloads;			/* Do not use or modify. */
	int numUploads;				/* Do not use or modify. */
	int numListings;			/* Do not use or modify. */
	int doNotGetStartingWorkingDirectory;	/* You may modify this. */
#if USE_SIO
	char srlBuf[768];
	SReadlineInfo ctrlSrl;		/* Do not use or modify. */
#endif
	FTPGetPassphraseProc passphraseProc;	/* You may modify this. */
	int iUser;				/* Scratch integer field you can use. */
	void *pUser;				/* Scratch pointer field you can use. */
	longest_int llUser;			/* Scratch long long field you can use. */
	const char *asciiFilenameExtensions;	/* You may assign this. */
	int reserved[32];			/* Do not use or modify. */
} FTPConnectionInfo;

typedef struct FileInfo *FileInfoPtr, **FileInfoVec;
typedef struct FileInfo {
	FileInfoPtr prev, next;
	char *relname;
	char *rname;
	char *rlinkto;
	char *lname;
	char *plug;	/* permissions, links, user, group */
	int type;
	time_t mdtm;
	longest_int size;
	size_t relnameLen;
} FileInfo;

typedef struct FileInfoList {
	FileInfoPtr first, last;
	FileInfoVec vec;
	size_t maxFileLen;
	size_t maxPlugLen;
	int nFileInfos;
	int sortKey;
	int sortOrder;
} FileInfoList, *FileInfoListPtr;

/* Used with UnMlsT() */
typedef struct MLstItem{
	char fname[512];
	char linkto[512];
	int ftype;
	longest_int fsize;
	time_t ftime;
	int mode;		/* "UNIX.mode" fact */
	int uid;		/* "UNIX.uid" fact */
	int gid;		/* "UNIX.gid" fact */
	char perm[16];		/* "perm" fact */
	char owner[16];		/* "UNIX.owner" fact */
	char group[16];		/* "UNIX.group" fact */
} MLstItem, *MLstItemPtr;

/* Messages we pass to the current progress meter function. */
#define kPrInitMsg			1
#define kPrUpdateMsg			2
#define kPrEndMsg			3

/* Parameter for OpenDataConnection() */
#define kSendPortMode			0
#define kPassiveMode			1
#define kFallBackToSendPortMode		2

/* Parameter for AcceptDataConnection() */
#define kAcceptForWriting		00100
#define kAcceptForReading		00101
#define kNetWriting			kAcceptForWriting
#define kNetReading			kAcceptForReading

/* Value for printMode field of Response structure.
 * Generally, don't worry about this.
 */
#define kResponseNoPrint 00001
#define kResponseNoSave  00002
#define kResponseNoProc  00002

#define kDefaultFTPPort			21

#define kDefaultFTPBufSize		32768

#ifdef USE_SIO
/* This version of the library can handle timeouts without
 * a user-installed signal handler.
 */
#define kDefaultXferTimeout		600
#define kDefaultConnTimeout		30
#define kDefaultCtrlTimeout		135
#define kDefaultAbortTimeout	10
#else
/* The library doesn't use timeouts by default because it would
 * break apps that don't have a SIGALRM handler.
 */
#define kDefaultXferTimeout		(0)	/* No timeout. */
#define kDefaultConnTimeout		(0)	/* No timeout. */
#define kDefaultCtrlTimeout		(0)	/* No timeout. */
#define kDefaultAbortTimeout		10
#endif


/* Suggested timeout values, in seconds, if you use timeouts. */
#define kSuggestedDefaultXferTimeout	(0)	/* No timeout on data blocks. */
#define kSuggestedDefaultConnTimeout	30
#define kSuggestedDefaultCtrlTimeout	135	/* 2*MSL, + slop */
#define kSuggestedAbortTimeout		10

#define kDefaultMaxDials		3
#define kDefaultRedialDelay		20	/* seconds */

#define kDefaultDataPortMode		kSendPortMode

#define kRedialStatusDialing		0

⌨️ 快捷键说明

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