CTRACE(tfp, "remove_bookmark_link: deleting link number: %d\n", cur);
CTRACE((tfp, "remove_bookmark_link: deleting link number: %d\n", cur));
PUBLIC void remove_bookmark_link ARGS2(	int,		cur,	char *,		cur_bookmark_page){    FILE *fp, *nfp;    char *buf = NULL;    int n;#ifdef VMS    char filename_buffer[NAM$C_MAXRSS+12];    char newfile[NAM$C_MAXRSS+12];#else    char filename_buffer[LY_MAXPATH];    char newfile[LY_MAXPATH];    struct stat stat_buf;    mode_t mode;#endif /* VMS */    char homepath[LY_MAXPATH];    CTRACE(tfp, "remove_bookmark_link: deleting link number: %d\n", cur);    if (!cur_bookmark_page)	return;    LYAddPathToHome(filename_buffer,		    sizeof(filename_buffer),		    cur_bookmark_page);    CTRACE(tfp, "\nremove_bookmark_link: SEEKING %s\n   AS %s\n\n",		cur_bookmark_page, filename_buffer);    if ((fp = fopen(filename_buffer, "r")) == NULL) {	HTAlert(BOOKMARK_OPEN_FAILED_FOR_DEL);	return;    }    LYAddPathToHome(homepath, sizeof(homepath), "");    if ((nfp = LYOpenScratch(newfile, homepath)) == 0) {	fclose(fp);	HTAlert(BOOKSCRA_OPEN_FAILED_FOR_DEL);	return;    }#ifdef UNIX    /*     *	Explicitly preserve bookmark file mode on Unix. - DSL     */    if (stat(filename_buffer, &stat_buf) == 0) {	mode = ((stat_buf.st_mode & 0777) | 0600); /* make it writable */	(void) chmod(newfile, mode);	if ((nfp = LYReopenTemp(newfile)) == NULL) {	    (void) fclose(fp);	    HTAlert(BOOKTEMP_REOPEN_FAIL_FOR_DEL);	    return;	}    }#endif /* UNIX */    if (is_mosaic_hotlist) {	int del_line = cur*2;  /* two lines per entry */	n = -3;  /* skip past cookie and name lines */	while (LYSafeGets(&buf, fp) != NULL) {	    n++;	    if (n == del_line || n == del_line+1)		continue;  /* remove two lines */	    if (fputs(buf, nfp) == EOF)		goto failure;	}    } else {	char *cp;	BOOLEAN retain;	int seen;	n = -1;	while (LYSafeGets(&buf, fp) != NULL) {	    retain = TRUE;	    seen = 0;	    cp = buf;	    while (n < cur && (cp = LYstrstr(cp, "<a href="))) {		seen++;		if (++n == cur) {		    if (seen != 1 || !LYstrstr(buf, "</a>") ||			LYstrstr((cp + 1), "<a href=")) {			HTAlert(BOOKMARK_LINK_NOT_ONE_LINE);			goto failure;		    }		    CTRACE(tfp, "remove_bookmark_link: skipping link %d\n", n);		    retain = FALSE;		}		cp += 8;	    }	    if (retain && fputs(buf, nfp) == EOF)		goto failure;	}    }    CTRACE(tfp, "remove_bookmark_link: files: %s %s\n",			newfile, filename_buffer);    fclose(fp);    fp = NULL;    LYCloseTempFP(nfp);    nfp = NULL;#ifdef DOSPATH    remove(filename_buffer);#endif /* DOSPATH */#ifdef UNIX    /*     *	By copying onto the bookmark file, rather than renaming it, we     *	can preserve the original ownership of the file, provided that     *	it is writable by the current process.     *	Changed to copy  1998-04-26 -- gil     */    if (LYCopyFile(newfile, filename_buffer) == 0)	return;    HTAlert(BOOKTEMP_COPY_FAIL);#else  /* !UNIX */    if (rename(newfile, filename_buffer) != -1) {	HTSYS_purge(filename_buffer);	return;    } else {#ifndef VMS	/*	 *  Rename won't work across file systems.	 *  Check if this is the case and do something appropriate.	 *  Used to be ODD_RENAME	 */#ifdef _WINDOWS	if (errno == ENOTSAM)#else	if (errno == EXDEV)#endif /* WINDOWS */	{	    static CONST char MV_FMT[] = "%s %s %s";	    char *buffer = 0;	    HTAddParam(&buffer, MV_FMT, 1, MV_PATH);	    HTAddParam(&buffer, MV_FMT, 2, newfile);	    HTAddParam(&buffer, MV_FMT, 3, filename_buffer);	    HTEndParam(&buffer, MV_FMT, 3);	    LYSystem(buffer);	    FREE(buffer);	    return;	}#endif /* !VMS */#ifdef VMS	HTAlert(ERROR_RENAMING_SCRA);#else	HTAlert(ERROR_RENAMING_TEMP);#endif /* VMS */	if (TRACE)	    perror("renaming the file");    }#endif /* UNIX */failure:    FREE(buf);    HTAlert(BOOKMARK_DEL_FAILED);    LYCloseTempFP(nfp);    if (fp != NULL)	fclose(fp);    LYRemoveTemp(newfile);}