1 - new public function libssh2_trace() that enables tracing/debug output on
various stuff if libssh2 was built with debug. If built without debug, the function does nothing. 2 - configure --enable-debug is now enough to build a debug version (including picky compiler options) 3 - internally, we no longer need/use #ifdef/#endif around all uses of the _libssh2_debug() function/macro. The scp.c example is the first application to test this new debug logging.
This commit is contained in:
		
							
								
								
									
										16
									
								
								src/scp.c
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								src/scp.c
									
									
									
									
									
								
							| @@ -73,9 +73,7 @@ LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_recv(LIBSSH2_SESSION *session, | ||||
| 	} | ||||
| 	command[command_len - 1] = '\0'; | ||||
|  | ||||
| #ifdef LIBSSH2_DEBUG_SCP | ||||
| 	_libssh2_debug(session, LIBSSH2_DBG_SCP, "Opening channel for SCP receive"); | ||||
| #endif | ||||
| 	/* Allocate a channel */ | ||||
| 	if ((channel = libssh2_channel_open_session(session)) == NULL) { | ||||
| 		LIBSSH2_FREE(session, command); | ||||
| @@ -92,9 +90,7 @@ LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_recv(LIBSSH2_SESSION *session, | ||||
| 	} | ||||
| 	LIBSSH2_FREE(session, command); | ||||
|  | ||||
| #ifdef LIBSSH2_DEBUG_SCP | ||||
| 	_libssh2_debug(session, LIBSSH2_DBG_SCP, "Sending initial wakeup"); | ||||
| #endif | ||||
| 	/* SCP ACK */ | ||||
| 	response[0] = '\0'; | ||||
| 	if (libssh2_channel_write(channel, response, 1) != 1) { | ||||
| @@ -208,9 +204,8 @@ LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_recv(LIBSSH2_SESSION *session, | ||||
| 			libssh2_channel_free(channel); | ||||
| 			return NULL; | ||||
| 		} | ||||
| #ifdef LIBSSH2_DEBUG_SCP | ||||
|  | ||||
| 		_libssh2_debug(session, LIBSSH2_DBG_SCP, "mtime = %ld, atime = %ld", mtime, atime); | ||||
| #endif | ||||
|  | ||||
| 		/* We *should* check that atime.usec is valid, but why let that stop use? */ | ||||
| 		break; | ||||
| @@ -309,9 +304,7 @@ LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_recv(LIBSSH2_SESSION *session, | ||||
| 			libssh2_channel_free(channel); | ||||
| 			return NULL; | ||||
| 		} | ||||
| #ifdef LIBSSH2_DEBUG_SCP | ||||
| 	_libssh2_debug(session, LIBSSH2_DBG_SCP, "mod = 0%lo size = %ld", mode, size); | ||||
| #endif | ||||
|  | ||||
| 		/* We *should* check that basename is valid, but why let that stop us? */ | ||||
| 		break; | ||||
| @@ -362,9 +355,7 @@ LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_send_ex(LIBSSH2_SESSION *session, const | ||||
| 	} | ||||
| 	command[command_len - 1] = '\0'; | ||||
|  | ||||
| #ifdef LIBSSH2_DEBUG_SCP | ||||
| 	_libssh2_debug(session, LIBSSH2_DBG_SCP, "Opening channel for SCP send"); | ||||
| #endif | ||||
| 	/* Allocate a channel */ | ||||
| 	if ((channel = libssh2_channel_open_session(session)) == NULL) { | ||||
| 		/* previous call set libssh2_session_last_error(), pass it through */ | ||||
| @@ -393,9 +384,8 @@ LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_send_ex(LIBSSH2_SESSION *session, const | ||||
| 	/* Send mtime and atime to be used for file */ | ||||
| 	if (mtime || atime) { | ||||
| 		response_len = snprintf(response, LIBSSH2_SCP_RESPONSE_BUFLEN, "T%ld 0 %ld 0\n", mtime, atime); | ||||
| #ifdef LIBSSH2_DEBUG_SCP | ||||
| 		_libssh2_debug(session, LIBSSH2_DBG_SCP, "Sent %s", response); | ||||
| #endif | ||||
|  | ||||
| 		if (libssh2_channel_write(channel, response, response_len) != response_len) { | ||||
| 			libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND, "Unable to send time data for SCP file", 0); | ||||
| 			libssh2_channel_free(channel); | ||||
| @@ -418,9 +408,7 @@ LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_send_ex(LIBSSH2_SESSION *session, const | ||||
| 	} | ||||
|  | ||||
| 	response_len = snprintf(response, LIBSSH2_SCP_RESPONSE_BUFLEN, "C0%o %lu %s\n", mode, (unsigned long)size, base); | ||||
| #ifdef LIBSSH2_DEBUG_SCP | ||||
| 	_libssh2_debug(session, LIBSSH2_DBG_SCP, "Sent %s", response); | ||||
| #endif | ||||
| 	if (libssh2_channel_write(channel, response, response_len) != response_len) { | ||||
| 		libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND, "Unable to send core file data for SCP file", 0); | ||||
| 		libssh2_channel_free(channel); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Daniel Stenberg
					Daniel Stenberg