+struct algstate {
+ void (*callback)(void *ctx, int result);
+ void *ctx;
+};
+
+static void askalg_callback(void *ctx, int result)
+{
+ struct algstate *state = (struct algstate *)ctx;
+
+ state->callback(state->ctx, result == 0);
+ sfree(state);
+}
+
+int askalg(void *frontend, const char *algtype, const char *algname,
+ void (*callback)(void *ctx, int result), void *ctx)
+{
+ static const char msg[] =
+ "The first %s supported by the server is "
+ "%s, which is below the configured warning threshold.\n"
+ "Continue with connection?";
+
+ char *text;
+ SessionWindow *win = (SessionWindow *)frontend;
+ struct algstate *state;
+ NSAlert *alert;
+
+ text = dupprintf(msg, algtype, algname);
+
+ state = snew(struct algstate);
+ state->callback = callback;
+ state->ctx = ctx;
+
+ alert = [NSAlert alloc];
+ [alert setInformativeText:[NSString stringWithCString:text]];
+ [alert addButtonWithTitle:@"Yes"];
+ [alert addButtonWithTitle:@"No"];
+ [win startAlert:alert withCallback:askalg_callback andCtx:state];
+
+ return -1;
+}
+
+struct hostkeystate {
+ char *host, *keytype, *keystr;
+ int port;
+ void (*callback)(void *ctx, int result);
+ void *ctx;
+};
+
+static void verify_ssh_host_key_callback(void *ctx, int result)