File:  [CSRG BSD Unix] / 43BSD / contrib / notes / src / delete.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:54 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD43
BSD 4.3

#include "parms.h"
#include "structs.h"

#ifdef	RCSIDENT
static char rcsid[] = "$Header: /var/lib/cvsd/repos/CSRG/43BSD/contrib/notes/src/delete.c,v 1.1.1.1 2018/04/24 16:12:54 root Exp $";
#endif	RCSIDENT

/*
 *	mdelete(io, first, last)
 *	deletes all the notes in the specified range in the notefile.
 *
 *	no verification of the desire to delete the notes is performed.
 *	It just goes and zaps them..
 *
 *	returns 0 if all goes well, -1 if it didn't like something
 *
 *	Original coding:	Ray Essick	Jan 1982
 */
mdelete (io, first, last, zapping)
struct io_f *io;
int     first,
        last,						/* range */
        zapping;					/* delete/undelete */
{
    int     which;
    struct note_f   note;				/* for undelete */

    x (first > last, "mdelete: nonsense first/last");
    locknf (io, DSCRLOCK);				/* lock for duration */
    getdscr (io, &io -> descr);
    if (last > io -> descr.d_nnote)
	last = io -> descr.d_nnote;
    if (first > io -> descr.d_nnote)
	first = io -> descr.d_nnote;
    for (which = first; which <= last; which++)
    {
	if (zapping)					/* deletion */
	{
	    delnote (io, which, NOLOCKIT);
	}
	else
	{
	    getnrec (io, which, &note);			/* get the note */
	    note.n_stat &= NOT DELETED;			/* un-deleted */
	    putnrec (io, which, &note);
	}
    }
    unlocknf (io, DSCRLOCK);				/* release the lock */
    return 0;
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.