reshandle = Get1NamedResource(FOUR_CHAR_CODE('TEXT'), presname); if (reshandle != NULL) {  RemoveResource(reshandle); }
void store_host_key(const char *hostname, int port,		    const char *keytype, const char *key){    short puttyVRefNum;    long puttyDirID;    OSErr error;    FSSpec keyfile;    short keyrefnum;    char *resname;    Str255 presname;    Handle resvalue;    int id;    /* Open the host key file */    if (get_putty_dir(~kCreateFolder, &puttyVRefNum, &puttyDirID) != noErr)	goto out;    error = FSMakeFSSpec(puttyVRefNum, puttyDirID, "\pSSH Host Keys",			 &keyfile);    if (error == fnfErr) {	/* It doesn't exist, so create it */	FSpCreateResFile(&keyfile, INTERNAL_CREATOR, HKYS_TYPE, smRoman);	keyrefnum = FSpOpenResFile(&keyfile, fsWrPerm);	if (ResError() == noErr) {	    copy_resource('STR', -16397); /* XXX: wtf is this? */	    CloseResFile(keyrefnum);	}    } else if (error != noErr) goto out;    keyrefnum = FSpOpenResFile(&keyfile, fsWrPerm);    if (keyrefnum == -1) goto out;    UseResFile(keyrefnum);    resname = dupprintf("%s@%d:%s", keytype, port, hostname);    c2pstrcpy(presname, resname);        error = PtrToHand(key, &resvalue, strlen(key));    if (error != noErr) goto out;    id = Unique1ID(FOUR_CHAR_CODE('TEXT'));    if (ResError() != noErr) goto out;    AddResource(resvalue, FOUR_CHAR_CODE('TEXT'), id, presname);    if (ResError() != noErr) goto out;    CloseResFile(keyrefnum);    return;  out:    fatalbox("Writing host key failed (%d)", error);    sfree(resname);}