| 2596 | } |
| 2597 | |
| 2598 | int CUT_FTPClient::PeekResponseCode(CUT_WSClient *ws, LPSTR string, int maxlen) { |
| 2599 | char c; |
| 2600 | int code; |
| 2601 | //int once = TRUE; |
| 2602 | char mlCode[5]{}; |
| 2603 | |
| 2604 | m_cachedResponse = true; |
| 2605 | |
| 2606 | m_listResponse.ClearList(); |
| 2607 | |
| 2608 | if(ws->ReceiveLine(m_szBuf,sizeof(m_szBuf),m_wsData.GetReceiveTimeOut ()/1000) <= 0) { |
| 2609 | m_lastResponseCode = 0; |
| 2610 | return 0; //no response |
| 2611 | } |
| 2612 | |
| 2613 | CUT_StrMethods::RemoveCRLF(m_szBuf); |
| 2614 | |
| 2615 | //get the code to return |
| 2616 | c = m_szBuf[3]; |
| 2617 | m_szBuf[3] = 0; |
| 2618 | code = atoi(m_szBuf); |
| 2619 | m_szBuf[3] = c; |
| 2620 | mlCode[0] = m_szBuf[0]; |
| 2621 | mlCode[1] = m_szBuf[1]; |
| 2622 | mlCode[2] = m_szBuf[2]; |
| 2623 | mlCode[3] = ' '; |
| 2624 | mlCode[4] = 0; |
| 2625 | |
| 2626 | //check for a multi-line response |
| 2627 | if(c =='-') { |
| 2628 | while(strstr(m_szBuf,mlCode) != m_szBuf) { |
| 2629 | |
| 2630 | //clear the multi-line response list the first time through |
| 2631 | /*if(once) { |
| 2632 | once = FALSE; |
| 2633 | |
| 2634 | // clear response list |
| 2635 | m_listResponse.ClearList(); |
| 2636 | }*/ |
| 2637 | |
| 2638 | m_listResponse.AddString(m_szBuf); |
| 2639 | |
| 2640 | //get the line |
| 2641 | if(ws->ReceiveLine(m_szBuf,sizeof(m_szBuf),m_wsData.GetReceiveTimeOut ()/1000) <=0) |
| 2642 | break; |
| 2643 | CUT_StrMethods::RemoveCRLF(m_szBuf); |
| 2644 | } |
| 2645 | |
| 2646 | m_listResponse.AddString(m_szBuf); |
| 2647 | } |
| 2648 | else |
| 2649 | m_listResponse.AddString(m_szBuf); |
| 2650 | |
| 2651 | strncpy(m_szResponse, m_szBuf, MAX_PATH); |
| 2652 | m_szResponse[MAX_PATH - 1] = '\0'; |
| 2653 | |
| 2654 | //copy the rest of the data |
| 2655 | if(string != NULL) { |
nothing calls this directly
no test coverage detected