#include <stdlib.h>
#include <sys/resource.h>
#include <sys/stat.h>
-#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
static void init();
static void destroy();
-static void timeDiff(struct timeval* const end, const struct timeval* const start);
-
-static gint gcfCompareAnalysis(gconstpointer a, gconstpointer b);
-static gint gcfCompareProcessing(gconstpointer a, gconstpointer b);
static void gfAppendAnalysisName(gpointer data, gpointer user_data);
static gboolean optionSync;
struct timeval startTime, endTime;
struct rusage startUsage, endUsage;
GList* result;
- char* cwd;
FILE* graphsStream;
- int graphsFp;
int retval;
if (optionSync == FALSE)
syncState->processingModule= (ProcessingModule*) result->data;
graphsStream= NULL;
- if (syncState->graphs)
+ if (syncState->graphs &&
+ syncState->processingModule->writeProcessingGraphsPlots != NULL)
{
+ char* cwd;
+ int graphsFp;
+
// Create the graph directory right away in case the module initialization
// functions have something to write in it.
cwd= changeToGraphDir(syncState->graphs);
- if (syncState->processingModule->writeProcessingGraphsPlots != NULL)
+ if ((graphsFp= open("graphs.gnu", O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR |
+ S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH
+ | S_IWOTH | S_IXOTH)) == -1)
{
- if ((graphsFp= open("graphs.gnu", O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR |
- S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH
- | S_IWOTH | S_IXOTH)) == -1)
- {
- g_error(strerror(errno));
- }
- if ((graphsStream= fdopen(graphsFp, "w")) == NULL)
- {
- g_error(strerror(errno));
- }
+ g_error(strerror(errno));
+ }
+ if ((graphsStream= fdopen(graphsFp, "w")) == NULL)
+ {
+ g_error(strerror(errno));
}
retval= chdir(cwd);
free(cwd);
}
- syncState->processingModule->initProcessing(syncState, traceSetContext);
+ // Identify matching and analysis modules
+ result= g_queue_find_custom(&matchingModules, "TCP", &gcfCompareMatching);
+ g_assert(result != NULL);
+ syncState->matchingModule= (MatchingModule*) result->data;
- // Identify and initialize matching and analysis modules
- syncState->matchingData= NULL;
- syncState->analysisData= NULL;
- if (optionSyncNull)
+ result= g_queue_find_custom(&analysisModules, optionSyncAnalysis,
+ &gcfCompareAnalysis);
+ if (result != NULL)
{
- syncState->matchingModule= NULL;
- syncState->analysisModule= NULL;
+ syncState->analysisModule= (AnalysisModule*) result->data;
}
else
{
- g_assert(g_queue_get_length(&matchingModules) == 1);
- syncState->matchingModule= (MatchingModule*)
- g_queue_peek_head(&matchingModules);
- syncState->matchingModule->initMatching(syncState);
+ g_error("Analysis module '%s' not found", optionSyncAnalysis);
+ }
- result= g_queue_find_custom(&analysisModules, optionSyncAnalysis,
- &gcfCompareAnalysis);
- if (result != NULL)
- {
- syncState->analysisModule= (AnalysisModule*) result->data;
- syncState->analysisModule->initAnalysis(syncState);
- }
- else
- {
- g_error("Analysis module '%s' not found", optionSyncAnalysis);
- }
+ syncState->processingModule->initProcessing(syncState, traceSetContext);
+
+ syncState->matchingData= NULL;
+ syncState->analysisData= NULL;
+
+ if (!optionSyncNull)
+ {
+ syncState->matchingModule->initMatching(syncState);
+ syncState->analysisModule->initAnalysis(syncState);
}
// Process traceset
* end: end time, result is also stored in this structure
* start: start time
*/
-static void timeDiff(struct timeval* const end, const struct timeval* const start)
+void timeDiff(struct timeval* const end, const struct timeval* const start)
{
if (end->tv_usec >= start->tv_usec)
{
* A GCompareFunc for g_slist_find_custom()
*
* Args:
- * a: AnalysisModule*, element's data
+ * a: ProcessingModule*, element's data
* b: char*, user data to compare against
*
* Returns:
- * 0 if the analysis module a's name is b
+ * 0 if the processing module a's name is b
*/
-static gint gcfCompareAnalysis(gconstpointer a, gconstpointer b)
+gint gcfCompareProcessing(gconstpointer a, gconstpointer b)
{
- const AnalysisModule* analysisModule;
+ const ProcessingModule* processingModule;
const char* name;
- analysisModule= (const AnalysisModule*)a;
- name= (const char*)b;
+ processingModule= (const ProcessingModule*) a;
+ name= (const char*) b;
- return strncmp(analysisModule->name, name, strlen(analysisModule->name) +
+ return strncmp(processingModule->name, name,
+ strlen(processingModule->name) + 1);
+}
+
+
+/*
+ * A GCompareFunc for g_slist_find_custom()
+ *
+ * Args:
+ * a: MatchingModule*, element's data
+ * b: char*, user data to compare against
+ *
+ * Returns:
+ * 0 if the matching module a's name is b
+ */
+gint gcfCompareMatching(gconstpointer a, gconstpointer b)
+{
+ const MatchingModule* matchingModule;
+ const char* name;
+
+ matchingModule= (const MatchingModule*) a;
+ name= (const char*) b;
+
+ return strncmp(matchingModule->name, name, strlen(matchingModule->name) +
1);
}
* A GCompareFunc for g_slist_find_custom()
*
* Args:
- * a: ProcessingModule*, element's data
+ * a: AnalysisModule*, element's data
* b: char*, user data to compare against
*
* Returns:
* 0 if the analysis module a's name is b
*/
-static gint gcfCompareProcessing(gconstpointer a, gconstpointer b)
+gint gcfCompareAnalysis(gconstpointer a, gconstpointer b)
{
- const ProcessingModule* processingModule;
+ const AnalysisModule* analysisModule;
const char* name;
- processingModule= (const ProcessingModule*)a;
- name= (const char*)b;
+ analysisModule= (const AnalysisModule*) a;
+ name= (const char*) b;
- return strncmp(processingModule->name, name,
- strlen(processingModule->name) + 1);
+ return strncmp(analysisModule->name, name, strlen(analysisModule->name) +
+ 1);
}