#include <stdio.h>
#include <sys/types.h>
#include <syslog.h>
#include <unistd.h>
static void simple_syslog_wrapper(int level, const char *msg, void *usrptr)
{
const char *prefix = (const char *)usrptr;
int priority;
switch(level) {
default:
fprintf(stderr, "Unsupported log level requested!\n");
return;
}
if (prefix)
syslog(priority, "%s:%s", prefix, msg);
else
syslog(priority, "%s", msg);
}
int main(void)
{
struct crypt_device *cd;
char usrprefix[] = "cslog_example";
int r;
if (geteuid()) {
printf("Using of libcryptsetup requires super user privileges.\n");
return 1;
}
openlog("cryptsetup", LOG_CONS | LOG_PID, LOG_USER);
if (r < 0) {
printf("crypt_init() failed.\n");
return 2;
}
closelog();
return 0;
}
void crypt_free(struct crypt_device *cd)
int crypt_init(struct crypt_device **cd, const char *device)
#define CRYPT_LOG_ERROR
Definition libcryptsetup.h:189
#define CRYPT_LOG_DEBUG
Definition libcryptsetup.h:193
#define CRYPT_LOG_VERBOSE
Definition libcryptsetup.h:191
#define CRYPT_LOG_NORMAL
Definition libcryptsetup.h:187
void crypt_set_log_callback(struct crypt_device *cd, void(*log)(int level, const char *msg, void *usrptr), void *usrptr)
void crypt_log(struct crypt_device *cd, int level, const char *msg)