diff options
| author | Přemysl Janouch <p.janouch@gmail.com> | 2014-09-23 22:59:01 +0200 | 
|---|---|---|
| committer | Přemysl Janouch <p.janouch@gmail.com> | 2014-09-23 22:59:01 +0200 | 
| commit | 1f9f9b9a395351fd2b001c24ffe89c546723763d (patch) | |
| tree | d688869ae29c20c2e5deb72f4e35dd9d6233cb37 /plugins/ssh.c | |
| parent | f9d6627456e8232fe7a2ae1283347236aa2b34df (diff) | |
| download | ponymap-1f9f9b9a395351fd2b001c24ffe89c546723763d.tar.gz ponymap-1f9f9b9a395351fd2b001c24ffe89c546723763d.tar.xz ponymap-1f9f9b9a395351fd2b001c24ffe89c546723763d.zip  | |
Simplify the plugin API
Diffstat (limited to 'plugins/ssh.c')
| -rw-r--r-- | plugins/ssh.c | 16 | 
1 files changed, 8 insertions, 8 deletions
diff --git a/plugins/ssh.c b/plugins/ssh.c index cf18c3c..8a1cc3a 100644 --- a/plugins/ssh.c +++ b/plugins/ssh.c @@ -32,16 +32,16 @@ g_data;  struct scan_data  { +	struct unit *u;                     ///< Scan unit  	struct str input;                   ///< Input buffer  };  static void *  scan_init (struct unit *u)  { -	(void) u; -  	struct scan_data *scan = xcalloc (1, sizeof *scan);  	str_init (&scan->input); +	scan->u = u;  	return scan;  } @@ -54,14 +54,14 @@ scan_free (void *handle)  }  static void -on_data (void *handle, struct unit *u, struct str *data) +on_data (void *handle, const void *data, size_t len)  {  	// See RFC 4253 -- we check for a valid SSH banner  	struct scan_data *scan = handle; -	if (scan->input.len + data->len > 255) +	if (scan->input.len + len > 255)  		goto end_scan; -	str_append_str (&scan->input, data); +	str_append_data (&scan->input, data, len);  	char *input = scan->input.str;  	char *nl = strstr (input, "\r\n");  	if (!nl) @@ -71,11 +71,11 @@ on_data (void *handle, struct unit *u, struct str *data)  		goto end_scan;  	*nl = '\0'; -	g_data.api->unit_add_info (u, input); -	g_data.api->unit_set_success (u, true); +	g_data.api->unit_add_info (scan->u, input); +	g_data.api->unit_set_success (scan->u, true);  end_scan: -	g_data.api->unit_abort (u); +	g_data.api->unit_abort (scan->u);  }  static struct service g_ssh_service =  | 
