📄 wzm.h
字号:
/********************* this is wrotten by wzm. the begin time is 20070518-10:20. v1.0 end time is ************************/#ifndef __WZM_DFB_FTP_CPP#define __WZM_DFB_FTP_CPP#include <string>#include <fstream>#include <directfb.h>extern "C"{#include <sys/socket.h> #include <netinet/in.h>#include <arpa/inet.h>#include <signal.h>#include <iconv.h>#include <dirent.h>#include <sys/stat.h>}using namespace std;#define TEMPFILE "/tmp/.wzm"#define DEBUGFILE "/tmp/.debug"#define HELPFILE "/root/Desktop/wzm/help"#define FONTFILE "/root/Desktop/wzm/simkai.ttf"#define MAXNUM 100#define TIMEOUT 3#define MAXTHEAD 1;/*this is for main*/#define QUIT 1#define EXIT QUIT+5#define LIST EXIT+5 //11#define RETR LIST+5#define SCWD RETR+5 //21#define LCWD SCWD+5#define STOR LCWD+5 //31#define DELE STOR+5#define SMKD DELE+5 //41#define SRMD SMKD+5#define RENA SRMD+5 //51#define SIZE RENA+5#define TYPE SIZE+5 //61#define DEBG TYPE+5#define CLER DEBG+5 //71#define HELP CLER+5#define MODE HELP+5 //81#define LMKD MODE+5#define LRMD LMKD+5 //91#define LDEL LRMD+5#define MDTM LDEL+5 //101#define LSIZ MDTM+5#define LMDT LSIZ+5 //111#define ABOR LMDT+5#define LREN ABOR+5 //121/* macro for a safe call to DirectFB functions */#define DFBCHECK(x...) \do { \ DFBResult err = x; \ if (err != DFB_OK) { \ fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \ DirectFBErrorFatal( #x, err ); \ } \} while (0) #define ERR(x...) \do { \ fprintf (stderr, "%s <%i>: ", __FILE__, __LINE__); \ fprintf (stderr, x); \ fprintf (stderr, "\n"); \} while (0)#define WZM_KEY_VALUE(symbol) ( symbol != DIKS_DELETE) \ &&( symbol != DIKS_BACKSPACE)\ &&( symbol != DIKS_TAB) \ &&( symbol != DIKS_ESCAPE) \ &&( symbol != DIKS_CANCEL) /* this is for ftp*/class wsocket{ private: int socket_id; union { struct sockaddr_in sin; struct sockaddr sa; }sa; protected: wsocket(); ~wsocket(); int setAddr( const string &, const int ); int setAddr( const unsigned int * ); int sockConnect(); int sockServer( unsigned int * ); int sockAccept(); int sockName( unsigned int * ); int sockRecv( char * ); int sockSend( const char *, const int & ); int sockClose();};class FtpPI:wsocket{ private: string laststring; ofstream ofs; protected: FtpPI(); ~FtpPI(); string getlast() { return laststring; } int GetAddr( unsigned int * ); void putstring( const char * ); int ConServ( const string & ); int SendCmd( const string &, const string & ); int RecvCmd( const string & ); int ClsServ(); }; class FtpDTP:wsocket{ private: string file; public: int ConnData( const string &, const char * ); int DataServer( unsigned int *, const char * ); int DataAccept(); int SendData( const char & ); int RecvData( const char & ); int ClosData();};extern "C"{ void *pSendData( void * ); void *pRecvData( void * );} class FtpInterface:FtpPI{ private: char type; char mode; char file[MAXNUM]; int num; pid_t pid; public: string GetInfo() { return getlast(); } friend void *pSendData( void * ); friend void *pRecvData( void * ); int PasvDTP( FtpDTP &, const char * ); int PortDTP( FtpDTP &, const char * ); int LogInServ( const char *, const char *, const char * ); int List( const char * ); int GetFile( const char * ); int Cwd( const char * ); int PutFile( char * ); int DeleFile( const char * ); int Mkd( const char * ); int Rmd( const char * ); int ReName( char * ); int Size( const char *, char * ); int SwitchType( char & ); int SwitchMode( char & ); int Mdtm( const char *, char * ); int Abort();};/*this is for dfb*/class IDisplay{ public: virtual int AcceptCmd( const string &, char *, const bool & ) = 0; virtual int DrawFile( const char *, int, const bool & ) = 0; virtual int DrawDir( string & ) = 0; virtual int DrawInfo( const int & ) = 0;};class DFBDisplay: virtual public IDisplay{ private: IDirectFB *dfb; IDirectFBDisplayLayer *layer; IDirectFBFont *font_normal; IDirectFBEventBuffer *events; IDirectFBWindow *windowr; IDirectFBWindow *windowd; IDirectFBWindow *windowu; IDirectFBWindow *windowl; IDirectFBSurface *surfacer; IDirectFBSurface *surfaced; IDirectFBSurface *surfaceu; IDirectFBSurface *surfacel; DFBWindowID lid; int linewidth, fontheigh,winheight; int nums,lines,page; int lnums,llines,lpage; char *buf, type[4]; bool flag,next,lnext,fileflg; string strs[20],lstrs[20]; string tmpfile,prompt,serdir; void ExeLine(); int DrawLine( const char *, const int &, const bool & ); int DrawCmd( const char * ); int EvtUnicode( DFBWindowEvent &, int &, const bool & ); int EvtSpecial( DFBWindowEvent & ); int EvtCousor( DFBWindowEvent & ); void EvtWheel( DFBWindowEvent & ); int EvtFunction( DFBWindowEvent & ); int InputEvent( const bool & ); void cleartail( char * ); int GB2312ToUTF8( char * ); void Exchange( const bool & ); public: DFBDisplay( int argc, char *argv[] ); ~DFBDisplay(); virtual int AcceptCmd( const string &, char *, const bool & ); virtual int DrawFile( const char *, int, const bool & ); virtual int DrawDir( string & ); virtual int DrawInfo( const int & );};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -