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

📄 main.c

📁 用c写的ftp客户端源代码,可以在UNIX,Windows下编译通过,学习的好代码!
💻 C
字号:
/* dftp: FTP client example * Copyright (c) 1996 by Donald C. Asonye * Email: donald@uh.edu * * main.c. * * This and other files are hereby released	to the public for  * educational purposes.  You may redistribute this and other files * or routines as long as you are not compensated for it, and as  * long as this notice is included with it.  You may not use the  * released source codes in anyway commercial without permission. * * It'd be nice if you share your modifications with me and everyone * else.  I encourage you to make the code better as I am very busy. * * Share your knowledge :) */#include <stdio.h>#include <stdlib.h>#include <string.h>#include <signal.h>#include "enums.h"#include "extfuncs.h"#if ( defined(_WIN32) || defined(WIN32) )#include <windows.h>#include <wincon.h>#include <conio.h> #endifextern int ReadCommand, 	   Connected;/* * interact * this is the main loop of the program.  it checks on keyboard and socket * for input. */void Interact(){int done=0;char command[1024];printf("\nftp>");while(!done) { if( ReadCommand ) {     printf("ftp>");     fflush(stdout); } if( !CheckFds(command) )   continue; switch(CheckCommand(command) ) { case PWD:		DoPWD();      break; case RHELP:      DoRhelp(command);      break; case HELP:      help(command);      break; case GET:      DoGet(command);      break; case PUT:      DoPut(command);      break; case BINARY:      DoBinary();      break; case ASCII:      DoAscii();      break; case CLOSE:	 DoClose();	 break; case OPEN:	 DoOpen(command);	 break; case CD:	DoCD(command);  break; case LS:	DoList(command);	break; case LLS:	DoLLS(command);	break; case LCD:	DoLCD(command);	break; case USER:	DoLogin(command);	break; case SHELL:	DoShellCommand(command);	break; case QUIT:	 done = 1;	 if( Connected )	     DoClose();	 break; default:	if(command[0] == 0 ) ;	else	    printf("Invalid command: %s\n",command);  } }}/* * main  * program's main function */void main(int argc, char *argv[]){	void (*OldSig)(int);   /*    * ignore ctrl-c    */   OldSig=signal(SIGINT,SIG_IGN);   printf("dftp: ftp client example\r\n");   printf("Copyright 1996 (c) Donald C. Asonye\r\n");   printf("Email: donald@uh.edu\r\n");#if (defined(WIN32) || defined(_WIN32) )   /*    * initialize winsock.     */   if( InitWinsock() ) {	   if(argc > 1)		   DoOpen(argv[1]);	   Interact();   }   else {	   printf("Press any key to exit");	   if( !getch() )		   getch();	   printf("\r\n");   }      /*    * cleanup winsock    */   CleanUp();#else   if(argc > 1)     DoOpen(argv[1]);   Interact(); #endif	(void)signal(SIGINT,OldSig);}

⌨️ 快捷键说明

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