Text around -load option "(although Plink still requires an explicitly
[u/mdw/putty] / mac / macstore.c
index 1aa3209..548b7ac 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: macstore.c,v 1.16 2003/02/02 00:04:36 ben Exp $ */
+/* $Id: macstore.c,v 1.19 2003/04/01 18:10:25 simon Exp $ */
 
 /*
  * macstore.c: Macintosh-specific impementation of the interface
@@ -116,16 +116,20 @@ struct write_settings {
     FSSpec dstfile;
 };
 
-void *open_settings_w(char const *sessionname) {
+void *open_settings_w(char const *sessionname, char **errmsg) {
     short sessVRefNum;
     long sessDirID;
     OSErr error;
     Str255 psessionname;
     FSSpec dstfile;
-    
+
+    *errmsg = NULL;
+
     error = get_session_dir(kCreateFolder, &sessVRefNum, &sessDirID);
     if (error != noErr) return NULL;
 
+    if (!sessionname || !*sessionname)
+       sessionname = "Default Settings";
     c2pstrcpy(psessionname, sessionname);
     error = FSMakeFSSpec(sessVRefNum, sessDirID, psessionname, &dstfile);
     if (error == fnfErr) {
@@ -147,7 +151,7 @@ void *open_settings_w_fsp(FSSpec *dstfile)
     OSErr error;
     Str255 tmpname;
 
-    ws = smalloc(sizeof *ws);
+    ws = snew(struct write_settings);
     ws->dstfile = *dstfile;
 
     /* Create a temporary file to save to first. */
@@ -256,6 +260,8 @@ void *open_settings_r(char const *sessionname)
 
     error = get_session_dir(kDontCreateFolder, &sessVRefNum, &sessDirID);
 
+    if (!sessionname || !*sessionname)
+       sessionname = "Default Settings";
     c2pstrcpy(psessionname, sessionname);
     error = FSMakeFSSpec(sessVRefNum, sessDirID, psessionname, &sessfile);
     if (error != noErr) goto out;
@@ -274,7 +280,7 @@ void *open_settings_r_fsp(FSSpec *sessfile)
     fd = FSpOpenResFile(sessfile, fsRdPerm);
     if (fd == 0) {error = ResError(); goto out;}
 
-    handle = smalloc(sizeof *handle);
+    handle = snew(int);
     *handle = fd;
     return handle;