|
|
@@ -185,27 +185,32 @@ int connect_to_pass_server()
|
|
|
return fd;
|
|
|
}
|
|
|
|
|
|
-int do_database_flush(passdb_context *ctx)
|
|
|
-{
|
|
|
- int retval;
|
|
|
-
|
|
|
- //Detach from the current pass database
|
|
|
- detach_from_passdb(ctx);
|
|
|
- //Format a new database file...
|
|
|
- format_new_passdb();
|
|
|
-
|
|
|
- retval = attach_to_passdb(ctx);
|
|
|
-
|
|
|
- if( DB_FAIL(retval) ) //If we fail to attach to our new database
|
|
|
- {
|
|
|
- fprintf(stderr, "Error (%d) attaching to pass database during flush attempt\n", retval); //report failure
|
|
|
- return retval;
|
|
|
- }
|
|
|
- else //Otherwise, report success.
|
|
|
- {
|
|
|
- printf("Pass database flushed!\n");
|
|
|
- return 0;
|
|
|
- }
|
|
|
+int do_database_flush(passdb_context *ctx) {
|
|
|
+ int retval;
|
|
|
+
|
|
|
+ // Detach from the current pass database
|
|
|
+ //
|
|
|
+ detach_from_passdb(ctx);
|
|
|
+
|
|
|
+ // Format a new database file...
|
|
|
+ //
|
|
|
+ format_new_passdb();
|
|
|
+
|
|
|
+ retval = attach_to_passdb(ctx);
|
|
|
+
|
|
|
+ // If we fail to attach to our new database
|
|
|
+ //
|
|
|
+ if( DB_FAIL(retval) ) {
|
|
|
+ fprintf(stderr, "Error (%d) attaching to pass database during flush attempt\n", retval); //report failure
|
|
|
+ return retval;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Otherwise, report success.
|
|
|
+ //
|
|
|
+ else {
|
|
|
+ printf("Pass database flushed!\n");
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
int send_query_message(int fd, passdb_context *ctx)
|
|
|
@@ -640,6 +645,8 @@ int do_zflush(passdb_context *ctx, void *data, int len)
|
|
|
|
|
|
// printf("do_zflush(%p, %p, %d)\n", ctx, data, len);
|
|
|
|
|
|
+ memset(&incoming_msg, 0, sizeof(struct message_record));
|
|
|
+
|
|
|
retval = inflateInit(&foo);
|
|
|
|
|
|
if(retval != Z_OK)
|
|
|
@@ -996,6 +1003,29 @@ void maintain_ipc_hub_connect(char *progname)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+int passdb_context_alloc(passdb_context *ctx) {
|
|
|
+ ctx->logical_card_id_hash = (rider_node **)malloc(sizeof(rider_node *)*STORED_PASS_HASH);
|
|
|
+ if (!(ctx->logical_card_id_hash)) { return -1; }
|
|
|
+
|
|
|
+ ctx->rider_mag_hash = (rider_node **)malloc(sizeof(rider_node *)*STORED_PASS_HASH);
|
|
|
+ if (!(ctx->rider_mag_hash)) { return -1; }
|
|
|
+
|
|
|
+ ctx->rider_rf_hash = (rider_node **)malloc(sizeof(rider_node *)*STORED_PASS_HASH);
|
|
|
+ if (!(ctx->rider_rf_hash)) { return -1; }
|
|
|
+
|
|
|
+ memset(ctx->logical_card_id_hash, 0, sizeof(rider_node **)*STORED_PASS_HASH);
|
|
|
+ memset(ctx->rider_mag_hash, 0, sizeof(rider_node **)*STORED_PASS_HASH);
|
|
|
+ memset(ctx->rider_rf_hash, 0, sizeof(rider_node **)*STORED_PASS_HASH);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+void passdb_context_dealloc(passdb_context *ctx) {
|
|
|
+ if (ctx->logical_card_id_hash) { free(ctx->logical_card_id_hash); }
|
|
|
+ if (ctx->rider_mag_hash) { free(ctx->rider_mag_hash); }
|
|
|
+ if (ctx->rider_rf_hash) { free(ctx->rider_rf_hash); }
|
|
|
+}
|
|
|
+
|
|
|
int main(int argc, char **argv)
|
|
|
{
|
|
|
struct pollfd fds[2];
|
|
|
@@ -1013,6 +1043,13 @@ int main(int argc, char **argv)
|
|
|
|
|
|
passdb_context ctx = {0};
|
|
|
|
|
|
+ passdb_context_alloc(&ctx);
|
|
|
+
|
|
|
+ //------------------
|
|
|
+
|
|
|
+ memset(input_line, 0, sizeof(char)*LINE_BUFFER_SIZE);
|
|
|
+ memset(&incoming_msg, 0, sizeof(struct message_record));
|
|
|
+
|
|
|
//------------------
|
|
|
|
|
|
configure_signal_handlers(argv[0]);
|
|
|
@@ -1395,6 +1432,7 @@ int main(int argc, char **argv)
|
|
|
|
|
|
printf("Detatching from Pass Database\n");
|
|
|
detach_from_passdb(&ctx);
|
|
|
+ passdb_context_dealloc(&ctx);
|
|
|
|
|
|
printf("Closing connections\n");
|
|
|
if(server_fd >= 0)
|