+void mac_opensession(void) {
+ Session *s;
+ StandardFileReply sfr;
+ static const OSType sftypes[] = { 'Sess', 0, 0, 0 };
+ void *sesshandle;
+ int i;
+
+ s = smalloc(sizeof(*s));
+ memset(s, 0, sizeof(*s));
+
+ StandardGetFile(NULL, 1, sftypes, &sfr);
+ if (!sfr.sfGood) goto fail;
+
+ sesshandle = open_settings_r_fsp(&sfr.sfFile);
+ if (sesshandle == NULL) goto fail;
+ load_open_settings(sesshandle, TRUE, &s->cfg);
+ close_settings_r(sesshandle);
+
+ /*
+ * Select protocol. This is farmed out into a table in a
+ * separate file to enable an ssh-free variant.
+ */
+ s->back = NULL;
+ for (i = 0; backends[i].backend != NULL; i++)
+ if (backends[i].protocol == s->cfg.protocol) {
+ s->back = backends[i].backend;
+ break;
+ }
+ if (s->back == NULL) {
+ fatalbox("Unsupported protocol number found");
+ }
+ mac_startsession(s);
+ return;
+
+ fail:
+ sfree(s);
+ return;
+}
+