Main Page | Modules | Data Structures | File List | Data Fields

pwd.h

00001 /*
00002  * Copyright (c) 2005-2008 by KoanLogic s.r.l. - All rights reserved.
00003  */
00004 
00005 #ifndef _U_PWD_H_
00006 #define _U_PWD_H_
00007 
00008 #include <u/libu_conf.h>
00009 
00010 #ifdef __cplusplus
00011 extern "C" {
00012 #endif
00013 
00014 #define U_PWD_LINE_MAX  256
00015 
00016 struct u_pwd_s;
00017 typedef struct u_pwd_s u_pwd_t;
00018 
00019 struct u_pwd_rec_s;
00020 typedef struct u_pwd_rec_s u_pwd_rec_t;
00021 
00022 /* password hashing function:
00023  * supply a string and its lenght, return the hashed string */
00024 typedef int (*u_pwd_hash_cb_t) (const char *, size_t, char []);
00025 
00026 /* load function:
00027  * fgets-like prototype with generic stream type */
00028 typedef char *(*u_pwd_load_cb_t) (char *, int, void *);
00029 
00030 /* master password db open:
00031  * supply an uri, return the resource handler */
00032 typedef int (*u_pwd_open_cb_t) (const char *, void **);
00033 
00034 /* master password db close:
00035  * supply res handler */
00036 typedef void (*u_pwd_close_cb_t) (void *);
00037 
00038 /* update notification:
00039  * return true if supplied timestamp is older than last modification time */
00040 typedef int (*u_pwd_notify_cb_t) (const char *, time_t, time_t *);
00041 
00042 /* interface */
00043 int u_pwd_init (const char *res_uri, u_pwd_open_cb_t cb_open, 
00044         u_pwd_load_cb_t cb_load, u_pwd_close_cb_t cb_close, 
00045         u_pwd_notify_cb_t cb_notify, u_pwd_hash_cb_t cb_hash, 
00046         size_t hash_len, int in_memory, u_pwd_t **ppwd);
00047 int u_pwd_init_file (const char *res_uri, u_pwd_hash_cb_t cb_hash, 
00048         size_t hash_len, int in_memory, u_pwd_t **ppwd);
00049 void u_pwd_term (u_pwd_t *pwd);
00050 int u_pwd_in_memory (u_pwd_t *pwd);
00051 int u_pwd_retr (u_pwd_t *pwd, const char *user, u_pwd_rec_t **prec);
00052 int u_pwd_auth_user (u_pwd_t *pwd, const char *user, const char *password);
00053 void u_pwd_rec_free (u_pwd_t *pwd, u_pwd_rec_t *rec);
00054 const char *u_pwd_rec_get_user (u_pwd_rec_t *rec);
00055 const char *u_pwd_rec_get_password (u_pwd_rec_t *rec);
00056 const char *u_pwd_rec_get_opaque (u_pwd_rec_t *rec);
00057 
00058 #ifdef __cplusplus
00059 }
00060 #endif
00061 
00062 #endif /* !_U_PWD_H_ */

←Products
© 2005-2008 - KoanLogic S.r.l. - All rights reserved