# the Salvage API

# Typical usage

    #include"adflib.h"

    int main()
    {
        struct List *list, *cell;

        /* initialization */
        /* the device and volume are mounted */

        cell = list = adfGetDelEnt(vol);
        while(cell) {
            block =(struct Block*) cell->content;
            printf("%s %d %d %ld\n",block->name,block->type,block->secType,
                block->sect);
            cell = cell->next;
        }
        /* we noted the entry 883 and 885 */
        adfFreeDelList(list);

        /* 883 is a file */
        if (adfCheckEntry(vol,883,0)==RC_OK)
            adfUndelEntry(vol,vol->curDirPtr,883);

        /* 885 is a directory */
        if (adfCheckEntry(vol,885,0)==RC_OK)
            adfUndelEntry(vol,vol->curDirPtr,885);

        /* unmounts done */
        /* cleanup */
    }

adfGetDelEnt()

## Syntax

struct List* adfGetDelEnt(struct Volume *vol)

## Description

Returns the list of the files/directories that MIGHT be undeleted. The entries must be checked before !

See adfFreeDelList() to free this list.
See adfCheckEntry() to check if the entry could be undeleted.

## Internals

Scans all the blocks of the volume to find directory blocks and file header blocks that are not allocated in the bitmap.

adfCheckEntry()

## Syntax

RETCODE adfCheckEntry(struct Volume* vol, SECTNUM nSect, int level)

## Description

Checks if an entry (directory or file) could be undeleted.

The 'level' argument is not used yet. Could be set to 0.

adfUndelEntry()

## Syntax

RETCODE adfUndelEntry(struct Volume* vol, SECTNUM parent, SECTNUM nSect)

## Description

Undelete a directory or a file. The parent directory of an entry must exist.

## Internals

Add the entry first block pointer in the parent directory list and allocated the related blocks in the bitmap.

void adfFreeDelList(struct List* list)

## Syntax

void adfFreeDelList(struct List* list)

## Description

Free the list of deleted entries.