Add API to delete enroll data

This commit is contained in:
Daniel Drake 2007-11-19 18:29:26 +00:00
parent 887e0e6acf
commit 6245acea84
2 changed files with 45 additions and 0 deletions

View file

@ -25,6 +25,7 @@
#include <unistd.h> #include <unistd.h>
#include <glib.h> #include <glib.h>
#include <glib/gstdio.h>
#include "fp_internal.h" #include "fp_internal.h"
@ -357,6 +358,28 @@ API_EXPORTED int fp_print_data_load(struct fp_dev *dev,
return 0; return 0;
} }
/** \ingroup print_data
* Removes a stored print from disk previously saved with fp_print_data_save().
* \param dev the device that the print belongs to
* \param finger the finger of the file you are deleting
* \returns 0 on success, negative on error
*/
API_EXPORTED int fp_print_data_delete(struct fp_dev *dev,
enum fp_finger finger)
{
int r;
gchar *path = get_path_to_print(dev, finger);
fp_dbg("remove finger %d at %s", finger, path);
r = g_unlink(path);
g_free(path);
if (r < 0)
fp_dbg("unlink failed with error %d", r);
/* FIXME: cleanup empty directory */
return r;
}
/** \ingroup print_data /** \ingroup print_data
* Attempts to load a stored print based on a \ref dscv_print * Attempts to load a stored print based on a \ref dscv_print
* "discovered print" record. * "discovered print" record.
@ -639,3 +662,23 @@ API_EXPORTED enum fp_finger fp_dscv_print_get_finger(struct fp_dscv_print *print
return print->finger; return print->finger;
} }
/** \ingroup dscv_print
* Removes a discovered print from disk. After successful return of this
* function, functions such as fp_dscv_print_get_finger() will continue to
* operate as before, however calling fp_print_data_from_dscv_print() will
* fail for obvious reasons.
* \param print the discovered print to remove from disk
* \returns 0 on success, negative on error
*/
API_EXPORTED int fp_dscv_print_delete(struct fp_dscv_print *print)
{
int r;
fp_dbg("remove at %s", print->path);
r = g_unlink(print->path);
if (r < 0)
fp_dbg("unlink failed with error %d", r);
/* FIXME: cleanup empty directory */
return r;
}

View file

@ -80,6 +80,7 @@ void fp_dscv_prints_free(struct fp_dscv_print **prints);
uint16_t fp_dscv_print_get_driver_id(struct fp_dscv_print *print); uint16_t fp_dscv_print_get_driver_id(struct fp_dscv_print *print);
uint32_t fp_dscv_print_get_devtype(struct fp_dscv_print *print); uint32_t fp_dscv_print_get_devtype(struct fp_dscv_print *print);
enum fp_finger fp_dscv_print_get_finger(struct fp_dscv_print *print); enum fp_finger fp_dscv_print_get_finger(struct fp_dscv_print *print);
int fp_dscv_print_delete(struct fp_dscv_print *print);
/* Device handling */ /* Device handling */
struct fp_dev *fp_dev_open(struct fp_dscv_dev *ddev); struct fp_dev *fp_dev_open(struct fp_dscv_dev *ddev);
@ -199,6 +200,7 @@ int fp_print_data_load(struct fp_dev *dev, enum fp_finger finger,
int fp_print_data_from_dscv_print(struct fp_dscv_print *print, int fp_print_data_from_dscv_print(struct fp_dscv_print *print,
struct fp_print_data **data); struct fp_print_data **data);
int fp_print_data_save(struct fp_print_data *data, enum fp_finger finger); int fp_print_data_save(struct fp_print_data *data, enum fp_finger finger);
int fp_print_data_delete(struct fp_dev *dev, enum fp_finger finger);
void fp_print_data_free(struct fp_print_data *data); void fp_print_data_free(struct fp_print_data *data);
size_t fp_print_data_get_data(struct fp_print_data *data, unsigned char **ret); size_t fp_print_data_get_data(struct fp_print_data *data, unsigned char **ret);
struct fp_print_data *fp_print_data_from_data(unsigned char *buf, struct fp_print_data *fp_print_data_from_data(unsigned char *buf,