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...
 

Functions

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.

Author
: Husni Fahmi husni.nosp@m.fahm.nosp@m.i@out.nosp@m.look.nosp@m..com
Date
: 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.

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

Open database connection.

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

Close message broker connection.

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

Open message broker connection.

Create a ZeroMQ socket for interprocess communication.

Parameters
contextZeroMQ context.
socket_typeSocket type which determines the semantics of communication over the socket.
identityBuffer to receive unique string identifying the connection.
Returns
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.

Parameters
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.
Returns
If successful the size of file data written in buffer, less than zero if failed.