Biometric Middleware Server  0.0.1
Manage database management for biometrics and identification based on biometrics.
Data Structures | Functions
bio-read-enroll.c File Reference

This program reads enrollment records from the enrollment queue. More...

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>
#include <zmq.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#include <libpq-fe.h>
#include <zip.h>
#include "./biom.h"

Data Structures

struct  Connection
 Singleton that holds connection objects. More...
struct  BiometryUpload
 Biometry data. More...


PGconn * db_open (const char *username, const char *password, const char *dbname)
 Open database connection. More...
void db_close (PGconn *conn)
 Close database connection. More...
void * mb_open (const void *context, int socket_type, char *identity)
 Open message broker connection. More...
void mb_close (void *conn)
 Close message broker connection. More...
int next_queue (const struct Connection *conn, size_t count, struct BiometryUpload **items)
 Get queued file. More...
int read_uploaded_file (const char *filepath, char *buffer, const size_t filesize)
 Read uploaded file in its compressed form. More...

Detailed Description

This program reads enrollment records from the enrollment queue.

: Husni Fahmi
: Sunday, 18 December 2016
  1. Open connection to database biometrics_upload.
  2. Connect to bio-midware socket
  3. Read one record from table received_file.
  4. Read the command from the retrieved record.
  5. Read the corresponding file from the retrieved record.
  6. Send the read data to bio-midware.
  7. Receive response from the bio-midware.
  8. Update response to table received_file.
  9. Go to step 2.

Function Documentation

void db_close ( PGconn *  conn)

Close database connection.

connConnection object.
PGconn* db_open ( const char *  username,
const char *  password,
const char *  dbname 

Open database connection.

usernameUsername used to open database connection.
passwordPassword used to open database connection.
dbnameName of database being opened.
Connection object or NULL.
void mb_close ( void *  conn)

Close message broker connection.

connZeroMQ socket
void* mb_open ( const void *  context,
int  socket_type,
char *  identity 

Open message broker connection.

Create a ZeroMQ socket for interprocess communication.

contextZeroMQ context.
socket_typeSocket type which determines the semantics of communication over the socket.
identityBuffer to receive unique string identifying the connection.
ZeroMQ socket or NULL.
int next_queue ( const struct Connection conn,
size_t  count,
struct BiometryUpload **  items 

Get queued file.

Process user uploaded file, fetch the next one in line.

int read_uploaded_file ( const char *  filepath,
char *  buffer,
const size_t  filesize 

Read uploaded file in its compressed form.

filepathFile location.
bufferPreviously allocated buffer to hold the data. At most it should be 30MB in size (maximum of 32bit integer).
filesizeThe size of buffer.
If successful the size of file data written in buffer, less than zero if failed.