mirror of
				https://github.com/libssh2/libssh2.git
				synced 2025-11-03 22:13:11 +03:00 
			
		
		
		
	improved error handling
This commit is contained in:
		@@ -38,7 +38,7 @@ int main(int argc, char *argv[])
 | 
				
			|||||||
    int sock, i, auth_pw = 1;
 | 
					    int sock, i, auth_pw = 1;
 | 
				
			||||||
    struct sockaddr_in sin;
 | 
					    struct sockaddr_in sin;
 | 
				
			||||||
    const char *fingerprint;
 | 
					    const char *fingerprint;
 | 
				
			||||||
    LIBSSH2_SESSION *session;
 | 
					    LIBSSH2_SESSION *session = NULL;
 | 
				
			||||||
    LIBSSH2_CHANNEL *channel;
 | 
					    LIBSSH2_CHANNEL *channel;
 | 
				
			||||||
    const char *username="username";
 | 
					    const char *username="username";
 | 
				
			||||||
    const char *password="password";
 | 
					    const char *password="password";
 | 
				
			||||||
@@ -77,7 +77,7 @@ int main(int argc, char *argv[])
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    local = fopen(loclfile, "rb");
 | 
					    local = fopen(loclfile, "rb");
 | 
				
			||||||
    if (!local) {
 | 
					    if (!local) {
 | 
				
			||||||
        fprintf(stderr, "Can't local file %s\n", loclfile);
 | 
					        fprintf(stderr, "Can't open local file %s\n", loclfile);
 | 
				
			||||||
        goto shutdown;
 | 
					        goto shutdown;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -189,9 +189,10 @@ int main(int argc, char *argv[])
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 shutdown:
 | 
					 shutdown:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
 | 
					    if(session) {
 | 
				
			||||||
    libssh2_session_free(session);
 | 
					        libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
 | 
				
			||||||
 | 
					        libssh2_session_free(session);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
#ifdef WIN32
 | 
					#ifdef WIN32
 | 
				
			||||||
    closesocket(sock);
 | 
					    closesocket(sock);
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user