From d820153a619a0094806a0397262b161940bb8e6d Mon Sep 17 00:00:00 2001 From: jlitewski Date: Fri, 26 Apr 2024 07:23:38 -0400 Subject: [PATCH 1/2] Fix the issue of SKIPQT builds not working --- client/src/graph.c | 3 +++ client/src/graph.h | 9 +++++++++ client/src/proxgui.cpp | 3 --- client/src/proxgui.h | 8 -------- client/src/proxguiqt.h | 1 + 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/client/src/graph.c b/client/src/graph.c index c0679d19e..423593622 100644 --- a/client/src/graph.c +++ b/client/src/graph.c @@ -32,6 +32,9 @@ int32_t g_OverlayBuffer[MAX_GRAPH_TRACE_LEN]; bool g_useOverlays = false; size_t g_GraphTraceLen; buffer_savestate_t g_saveState_gb; +marker_t g_MarkerA, g_MarkerB, g_MarkerC, g_MarkerD; +marker_t *g_TempMarkers; +uint8_t g_TempMarkerSize = 0; /* write a manchester bit to the graph */ diff --git a/client/src/graph.h b/client/src/graph.h index 5c51481f2..6ab45e74a 100644 --- a/client/src/graph.h +++ b/client/src/graph.h @@ -33,6 +33,11 @@ typedef struct { uint32_t clock; //Not used by all buffers } buffer_savestate_t; +typedef struct { + uint32_t pos; + char label[30]; +} marker_t; + void AppendGraph(bool redraw, uint16_t clock, int bit); size_t ClearGraph(bool redraw); bool HasGraphData(void); @@ -68,6 +73,10 @@ extern int32_t g_OverlayBuffer[MAX_GRAPH_TRACE_LEN]; extern bool g_useOverlays; extern size_t g_GraphTraceLen; +extern marker_t g_MarkerA, g_MarkerB, g_MarkerC, g_MarkerD; +extern marker_t *g_TempMarkers; +extern uint8_t g_TempMarkerSize; + extern double g_GridOffset; extern buffer_savestate_t g_saveState_gb; diff --git a/client/src/proxgui.cpp b/client/src/proxgui.cpp index 29eb79d7a..528df4d5e 100644 --- a/client/src/proxgui.cpp +++ b/client/src/proxgui.cpp @@ -24,9 +24,6 @@ #include "ui.h" // for prints static ProxGuiQT *gui = NULL; -marker_t g_MarkerA, g_MarkerB, g_MarkerC, g_MarkerD; -marker_t *g_TempMarkers; -uint8_t g_TempMarkerSize = 0; static WorkerThread *main_loop_thread = NULL; WorkerThread::WorkerThread(char *script_cmds_file, char *script_cmd, bool stayInCommandLoop) : script_cmds_file(script_cmds_file), script_cmd(script_cmd), stayInCommandLoop(stayInCommandLoop) { diff --git a/client/src/proxgui.h b/client/src/proxgui.h index daeed30b6..498c0a83f 100644 --- a/client/src/proxgui.h +++ b/client/src/proxgui.h @@ -27,11 +27,6 @@ extern "C" { #include #include -typedef struct { - uint32_t pos; - char label[30]; -} marker_t; - void ShowGraphWindow(void); void HideGraphWindow(void); void RepaintGraphWindow(void); @@ -53,9 +48,6 @@ extern void remove_temporary_markers(void); extern double g_CursorScaleFactor; extern char g_CursorScaleFactorUnit[11]; extern double g_PlotGridX, g_PlotGridY, g_DefaultGridX, g_DefaultGridY; -extern marker_t g_MarkerA, g_MarkerB, g_MarkerC, g_MarkerD; -extern marker_t *g_TempMarkers; -extern uint8_t g_TempMarkerSize; extern uint32_t g_GraphStart, g_GraphStart_old, g_GraphStop; extern int CommandFinished; extern int offline; diff --git a/client/src/proxguiqt.h b/client/src/proxguiqt.h index 2f4879495..6e7f8efb1 100644 --- a/client/src/proxguiqt.h +++ b/client/src/proxguiqt.h @@ -30,6 +30,7 @@ #include #include "proxgui.h" +#include "graph.h" #include "ui/ui_overlays.h" #include "ui/ui_image.h" From 8789991f9ad39500a1da9196162feadeb1526180 Mon Sep 17 00:00:00 2001 From: jlitewski Date: Fri, 26 Apr 2024 08:29:17 -0400 Subject: [PATCH 2/2] Fixed compile issues I missed --- client/src/graph.c | 41 +++++++++++++++++++++++++++++++++++++++++ client/src/graph.h | 3 +++ client/src/proxgui.cpp | 41 ----------------------------------------- client/src/proxgui.h | 4 ---- 4 files changed, 44 insertions(+), 45 deletions(-) diff --git a/client/src/graph.c b/client/src/graph.c index 423593622..2eb185e0a 100644 --- a/client/src/graph.c +++ b/client/src/graph.c @@ -468,6 +468,47 @@ bool fskClocks(uint8_t *fc1, uint8_t *fc2, uint8_t *rf1, int *firstClockEdge) { return true; } +void add_temporary_marker(uint32_t position, const char *label) { + if (g_TempMarkerSize == 0) { //Initialize the marker array + g_TempMarkers = (marker_t *)calloc(1, sizeof(marker_t)); + } else { //add more space to the marker array using realloc() + marker_t *temp = (marker_t *)realloc(g_TempMarkers, ((g_TempMarkerSize + 1) * sizeof(marker_t))); + + if (temp == NULL) { //Unable to reallocate memory for a new marker + PrintAndLogEx(FAILED, "Unable to allocate memory for a new temporary marker!"); + free(temp); + return; + } else { + //Set g_TempMarkers to the new pointer + g_TempMarkers = temp; + } + } + + g_TempMarkers[g_TempMarkerSize].pos = position; + + char *markerLabel = (char *)calloc(1, strlen(label) + 1); + strcpy(markerLabel, label); + + if (strlen(markerLabel) > 30) { + PrintAndLogEx(WARNING, "Label for temporary marker too long! Trunicating..."); + markerLabel[30] = '\0'; + } + + strncpy(g_TempMarkers[g_TempMarkerSize].label, markerLabel, 30); + g_TempMarkerSize++; + + memset(markerLabel, 0x00, strlen(label)); + free(markerLabel); +} + +void remove_temporary_markers(void) { + if (g_TempMarkerSize == 0) return; + + memset(g_TempMarkers, 0x00, (g_TempMarkerSize * sizeof(marker_t))); + free(g_TempMarkers); + g_TempMarkerSize = 0; +} + buffer_savestate_t save_buffer32(uint32_t *src, size_t length) { //calloc the memory needed uint32_t* savedBuffer = (uint32_t*)calloc(length, sizeof(uint32_t)); diff --git a/client/src/graph.h b/client/src/graph.h index 6ab45e74a..b2e02b137 100644 --- a/client/src/graph.h +++ b/client/src/graph.h @@ -56,6 +56,9 @@ int GetNrzClock(const char *str, bool verbose); int GetFskClock(const char *str, bool verbose); bool fskClocks(uint8_t *fc1, uint8_t *fc2, uint8_t *rf1, int *firstClockEdge); +extern void add_temporary_marker(uint32_t position, const char *label); +extern void remove_temporary_markers(void); + buffer_savestate_t save_buffer32(uint32_t *src, size_t length); buffer_savestate_t save_bufferS32(int32_t *src, size_t length); buffer_savestate_t save_buffer8(uint8_t *src, size_t length); diff --git a/client/src/proxgui.cpp b/client/src/proxgui.cpp index 528df4d5e..9d95a372d 100644 --- a/client/src/proxgui.cpp +++ b/client/src/proxgui.cpp @@ -134,47 +134,6 @@ extern "C" void InitGraphics(int argc, char **argv, char *script_cmds_file, char gui = new ProxGuiQT(argc, argv, main_loop_thread); } -void add_temporary_marker(uint32_t position, const char *label) { - if (g_TempMarkerSize == 0) { //Initialize the marker array - g_TempMarkers = (marker_t *)calloc(1, sizeof(marker_t)); - } else { //add more space to the marker array using realloc() - marker_t *temp = (marker_t *)realloc(g_TempMarkers, ((g_TempMarkerSize + 1) * sizeof(marker_t))); - - if (temp == NULL) { //Unable to reallocate memory for a new marker - PrintAndLogEx(FAILED, "Unable to allocate memory for a new temporary marker!"); - free(temp); - return; - } else { - //Set g_TempMarkers to the new pointer - g_TempMarkers = temp; - } - } - - g_TempMarkers[g_TempMarkerSize].pos = position; - - char *markerLabel = (char *)calloc(1, strlen(label) + 1); - strcpy(markerLabel, label); - - if (strlen(markerLabel) > 30) { - PrintAndLogEx(WARNING, "Label for temporary marker too long! Trunicating..."); - markerLabel[30] = '\0'; - } - - strncpy(g_TempMarkers[g_TempMarkerSize].label, markerLabel, 30); - g_TempMarkerSize++; - - memset(markerLabel, 0x00, strlen(label)); - free(markerLabel); -} - -void remove_temporary_markers(void) { - if (g_TempMarkerSize == 0) return; - - memset(g_TempMarkers, 0x00, (g_TempMarkerSize * sizeof(marker_t))); - free(g_TempMarkers); - g_TempMarkerSize = 0; -} - extern "C" void ExitGraphics(void) { if (!gui) return; diff --git a/client/src/proxgui.h b/client/src/proxgui.h index 498c0a83f..8ec934265 100644 --- a/client/src/proxgui.h +++ b/client/src/proxgui.h @@ -41,10 +41,6 @@ void MainGraphics(void); void InitGraphics(int argc, char **argv, char *script_cmds_file, char *script_cmd, bool stayInCommandLoop); void ExitGraphics(void); -//Temporary Marker Functions -extern void add_temporary_marker(uint32_t position, const char *label); -extern void remove_temporary_markers(void); - extern double g_CursorScaleFactor; extern char g_CursorScaleFactorUnit[11]; extern double g_PlotGridX, g_PlotGridY, g_DefaultGridX, g_DefaultGridY;