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

📄 vwftc01.cc

📁 http协议下的文件传输程序
💻 CC
📖 第 1 页 / 共 2 页
字号:
                        }                else if (strcmp(pstrdir,".") != 0)                {                                     if (strcmp(strRdir,"/") != 0) strcat(strRdir,"/");                        strcat(strRdir,pstrdir);                }        }        textremote->Clear();        textremote->TextInsert(strRdir);        remotedir();        //OnMenuItem5Activate(this);        return true;}//asks user before closingvoidVwftc01Form::OnShow(VDKForm* sender){        getcwd(strLdir,sizeof(strLdir));        localdir();        entryremotefile->SetText("localhost");        entrylocalfile->SetText("ftp");        return;}//signal response methodboolVwftc01Form::OnlocallistClickColumn(VDKObject* sender){        return true;}//signal response methodboolVwftc01Form::OnlocallistSelectRow(VDKObject* sender){        int           iRow;        char       *pstrifdir;        char       *pstrdir;        textlocal->Clear();        iaSelections = locallist->Selections();        iRow = iaSelections[0];        //sprintf(strtmp,"%d    ,%d \n", iaSelections[0] , iaSelections.size());        //textlocal->TextInsert(strtmp);        //sprintf(strtmp,"%s    ,%s \n", (char *)locallist->Tuples[iRow][0], (char *)locallist->Tuples[iRow][1]);        pstrifdir = (char *)locallist->Tuples[iRow][0];        pstrdir = (char *)locallist->Tuples[iRow][1];                if (*pstrifdir == '/')        {                if (strcmp(pstrdir,"..") == 0)                        for (int iLoop = strlen(strLdir) - 1; iLoop >= 0; iLoop--)                        {                                if (strLdir[iLoop] == '/')                                {                                        strLdir[iLoop] = '\0';                                        if (iLoop == 0) strcpy(strLdir,"/");                                        break;                                       }                        }                else if (strcmp(pstrdir,".") != 0)                {                                     if (strcmp(strLdir,"/") != 0) strcat(strLdir,"/");                        strcat(strLdir,pstrdir);                }        }        textlocal->TextInsert(strLdir);        localdir();        //OnMenuItemtryActivate(this);        return true;}//signal response methodboolVwftc01Form::OnlocallistRealize(VDKObject* sender){        return true;}//signal response methodboolVwftc01Form::OnMenuItem5Activate(VDKObject* sender){        textlocal ->Clear();        //textlocal->TextInsert(pvtFTC->ShowInfo());        //textlocal->TextInsert(strtmp);        return true;}//signal response methodboolVwftc01Form::OnbuttonconnectClick(VDKObject* sender){        guchar      *puch;        phostent = gethostbyname(entryremotefile->GetText());        puch = (guchar *)(phostent->h_addr);        sprintf(strhost,"%u.%u.%u.%u",*puch,*(puch+1),*(puch+2),*(puch+3));        //entrylocalfile->SetText(strhost);        pstrUserName = entrylocalfile->GetText();         strcpy(strRdir,"/");        textremote->Clear();        textremote->TextInsert(strRdir);        //remotedir();        char    strbuf00[256];        char    strbuf01[256];        char    strbuf02[256];        char    strbuf03[256];        int       istrstart;        int       istrlen;        tuTmp.resize(10);        iDirs = 0;        iFiles = 0;        tlDir.flush();        tlFile.flush();        int    iLoop = 0;                for (iLoop = 0;  iLoop <= iRemoteListMaxRow; iLoop++)                       remotelist->RemoveRow(0);        int     ierror;        strcpy(hostp,strhost);        strcpy(portp,"80");        sock = socket(AF_INET, SOCK_STREAM, 0);        soin.sin_family = AF_INET;        soin.sin_addr.s_addr = inet_addr(hostp);        soin.sin_port = htons(atoi(portp));        ierror = connect(sock, (struct sockaddr *)&soin, sizeof(soin));        sprintf(strtmp,"%d",ierror);        sprintf(strbuf,"%8d%s:%s",100,"web","123456");        sprintf(strbuf,"%8d%s:%s",100,"ftp","123456");        sprintf(strbuf,"%8d%s:%s",100,"mail","123456");        sprintf(strbuf,"%8d%s:%s",100,pstrUserName,"123456");        istrlens=strlen(strbuf);        sprintf(buffer,"POST /perl/login.cgi HTTP/1.1\r\nHost: 127.0.0.1\r\nContent-Length: %d\r\n\r\n%s",istrlens,strbuf);        write(sock,  buffer,strlen(buffer));        int             iRows;        ifstream      ifsock(sock);        iRows = 0;        while (1)        {                ifsock.getline(buffer,1024,'\n');                if (ifsock.good() == 0) break;                //int n = read(sock, buffer, sizeof(buffer));                buffer[1024] = '\0';                istrlen = strlen(buffer);                for (iLoop =0;  iLoop < istrlen; iLoop++)                {                        if (buffer[iLoop] == ',')                        {                                buffer[iLoop] = '\0';                                strcpy(strbuf00,buffer);                                break;                        }                }                istrstart = iLoop+1;                for (iLoop = istrstart;  iLoop < istrlen; iLoop++)                {                        if (buffer[iLoop] == ',')                        {                                buffer[iLoop] = '\0';                                strcpy(strbuf01,&buffer[istrstart]);                                break;                        }                }                istrstart = iLoop+1;                for (iLoop = istrstart;  iLoop < istrlen; iLoop++)                {                        if (buffer[iLoop] == ',')                        {                                buffer[iLoop] = '\0';                                strcpy(strbuf02,&buffer[istrstart]);                                break;                        }                }                strcpy(strbuf03,&buffer[iLoop + 1]);                tuTmp[0] = strbuf00;                tuTmp[1] = strbuf01;                tuTmp[2] = strbuf02;                tuTmp[3] = strbuf03;                                if (strcmp(tuTmp[0],"/") == 0)                {                        tlDir.add(tuTmp);                        iDirs++;                }                else                {                        tlFile.add(tuTmp);                        iFiles++;                }        }        iRemoteListMaxRow = iDirs+iFiles;        close(sock);        for (iLoop = 0; iLoop < iDirs; iLoop++)        {                tuTmp = tlDir[iLoop];                ptuTmp = &tlDir[iLoop];                for (iLoop01 = iLoop; iLoop01 < iDirs; iLoop01++)                {                        if (strcmp(tuTmp[1],tlDir[iLoop01][1]) > 0)                        {                                ptuTmp = &tlDir[iLoop01];                                tuTmp = tlDir[iLoop01];                        }                }                *ptuTmp = tlDir[iLoop];                tlDir[iLoop] = tuTmp;        }        for (iLoop = 0; iLoop < iFiles; iLoop++)        {                tuTmp = tlFile[iLoop];                ptuTmp = &tlFile[iLoop];                for (iLoop01 = iLoop; iLoop01 < iFiles; iLoop01++)                {                        if (strcmp(tuTmp[1],tlFile[iLoop01][1]) > 0)                        {                                ptuTmp = &tlFile[iLoop01];                                tuTmp = tlFile[iLoop01];                        }                }                *ptuTmp = tlFile[iLoop];                tlFile[iLoop] = tuTmp;        }        for (iLoop = 0; iLoop < iDirs; iLoop++)        {                remotelist->AddRow(address[0].items);                remotelist->UpdateCell(iLoop,0,tlDir[iLoop][0]);                remotelist->UpdateCell(iLoop,1,tlDir[iLoop][1]);                remotelist->UpdateCell(iLoop,2,tlDir[iLoop][2]);                remotelist->UpdateCell(iLoop,3,tlDir[iLoop][3]);        }        for (iLoop = 0; iLoop < iFiles; iLoop++)        {                remotelist->AddRow(address[0].items);                remotelist->UpdateCell(iLoop+iDirs,0,tlFile[iLoop][0]);                remotelist->UpdateCell(iLoop+iDirs,1,tlFile[iLoop][1]);                remotelist->UpdateCell(iLoop+iDirs,2,tlFile[iLoop][2]);                remotelist->UpdateCell(iLoop+iDirs,3,tlFile[iLoop][3]);        }        return true;}//signal response methodboolVwftc01Form::OnbuttonuploadClick(VDKObject* sender){        textlocal->Clear();        //struct dirent   **namelist;        int         iLoop,iRow,iRows;        iaSelections = locallist->Selections();        iRows = iaSelections.size();        vastrLists.resize(iRows);        for (iLoop = 0;  iLoop < iRows; iLoop++)        {                iRow = iaSelections[iLoop];                vastrLists[iLoop] = locallist->Tuples[iRow][1];                if (strcmp("/",locallist->Tuples[iRow][0]) == 0)  vastrLists[iLoop] += "/";        }        pvtFTC = new CvtFTC();        pvtFTC->Setup("localhost","upload",strLdir, strRdir, &vastrLists);        pvtFTC->Start();        timer->Start();        //textlocal->TextInsert(pvtFTC->ShowInfo());        return true;}//signal response methodboolVwftc01Form::OnbuttonopenfileClick(VDKObject* sender){        FileStringArray selections;        VDKFileDialog  *child = new VDKFileDialog(this,&selections,"File Open dialog");        child->Filter = "*";        child->ShowModal();        strcpy(strpath,(char*) selections[0]);        fhpost.open(strpath,ios::in|ios::binary|ios::nocreate);        iups=0;        strcpy(strboundary,"######=========0123456789ABCDEF=======######");        istrlens=strlen(strpath);        for (int i=istrlens-1;i>=0;i--)        {                if (strpath[i]=='/')                {                        strcpy(strfilename,&strpath[i+1]);                        break;                }        }        entrylocalfile->SetText(strpath);                isigs = 0;        textlocal->Clear();        //timer->Stop();        return true;}//signal response methodboolVwftc01Form::OnMenuItemtryActivate(VDKObject* sender){        struct dirent   **namelist;        int         n, iLoop,iLoop01,iRow,iRows;        iaSelections = locallist->Selections();        iRows = iaSelections.size();        vastrSendPath.resize(iRows);        for (iLoop = 0;  iLoop < iRows; iLoop++)        {                iRow = iaSelections[iLoop];                vastrSendPath[iLoop] = strLdir;                vastrSendPath[iLoop] += "/";                vastrSendPath[iLoop] += locallist->Tuples[iRow][1];        }        textlocal->Clear();                vaastrSendFileName.resize(iRows);        int   iSendFileNameArraySize;        for (iLoop = 0; iLoop < iRows; iLoop++)        {                iSendFileNameArraySize = 0;                n = scandir((char*)vastrSendPath[iLoop], &namelist, 0, alphasort);                if (n < 0)                        perror("scandir");                else                 {                        for (iLoop01 = 0; iLoop01 < n; iLoop01++)                         {                                sprintf(strpath,"%s/%s",(char*)vastrSendPath[iLoop],namelist[iLoop01]->d_name);                                stat(strpath, &mystat);                                if (S_ISDIR(mystat.st_mode) == 0)                                {                                        iSendFileNameArraySize++;                                          vaastrSendFileName[iLoop].resize(iSendFileNameArraySize);                                        vaastrSendFileName[iLoop][iSendFileNameArraySize-1] = strpath;                                }                        }                }       }                 for (iLoop = 0; iLoop < vaastrSendFileName.size(); iLoop++)        {                for (iLoop01 = 0; iLoop01 < vaastrSendFileName[iLoop].size(); iLoop01++)                 {                        textlocal->TextInsert(vaastrSendFileName[iLoop][iLoop01]);                        textlocal->TextInsert("\n");                }       }                 pvtDlUl = new CvtDlUl();        pvtDlUl->Setup(strLdir, strRdir, &vaastrSendFileName);        pvtDlUl->Start();        timer->Start();        return true;    }//signal response methodboolVwftc01Form::OnMenuItemexitActivate(VDKObject* sender){    Close();    return true;}bool Vwftc01Form::OnTimer(VDKObject*){        char  chtmp[1024];        textlocal->Clear();        strncpy(chtmp,pvtFTC->ShowInfo(),256);        chtmp[256] = '\0';        textlocal->TextInsert(chtmp);        return true;}  bool   Vwftc01Form::MySignalCallback(VDKObject* sender){        return true;}// end of file:vwftc01.cc

⌨️ 快捷键说明

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