Skip to content
This repository has been archived by the owner on Aug 1, 2020. It is now read-only.
/ readsb Public archive

Commit

Permalink
Optimized structure layout.
Browse files Browse the repository at this point in the history
Sorted init declarations to fit new layout.
  • Loading branch information
Mictronics committed Feb 22, 2017
1 parent 7a87073 commit 9de8db8
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions sdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@
#endif

typedef struct {
const char *name;
sdr_type_t sdr_type;
void (*initConfig)();
void (*showHelp)();
bool (*handleOption)(int, char**, int*);
bool (*open)();
void (*run)();
void (*close)();
const char *name;
sdr_type_t sdr_type;
uint32_t padding;
} sdr_handler;

static void noInitConfig()
Expand Down Expand Up @@ -78,17 +79,17 @@ static bool unsupportedOpen()

static sdr_handler sdr_handlers[] = {
#ifdef ENABLE_RTLSDR
{ "rtlsdr", SDR_RTLSDR, rtlsdrInitConfig, rtlsdrShowHelp, rtlsdrHandleOption, rtlsdrOpen, rtlsdrRun, rtlsdrClose },
{ rtlsdrInitConfig, rtlsdrShowHelp, rtlsdrHandleOption, rtlsdrOpen, rtlsdrRun, rtlsdrClose, "rtlsdr", SDR_RTLSDR, 0 },
#endif

#ifdef ENABLE_BLADERF
{ "bladerf", SDR_BLADERF, bladeRFInitConfig, bladeRFShowHelp, bladeRFHandleOption, bladeRFOpen, bladeRFRun, bladeRFClose },
{ bladeRFInitConfig, bladeRFShowHelp, bladeRFHandleOption, bladeRFOpen, bladeRFRun, bladeRFClose, "bladerf", SDR_BLADERF, 0 },
#endif

{ "ifile", SDR_IFILE, ifileInitConfig, ifileShowHelp, ifileHandleOption, ifileOpen, ifileRun, ifileClose },
{ "none", SDR_NONE, noInitConfig, noShowHelp, noHandleOption, noOpen, noRun, noClose },
{ ifileInitConfig, ifileShowHelp, ifileHandleOption, ifileOpen, ifileRun, ifileClose, "ifile", SDR_IFILE, 0 },
{ noInitConfig, noShowHelp, noHandleOption, noOpen, noRun, noClose, "none", SDR_NONE, 0 },

{ NULL, SDR_NONE, NULL, NULL, NULL, NULL, NULL, NULL } /* must come last */
{ NULL, NULL, NULL, NULL, NULL, NULL, NULL, SDR_NONE, 0 } /* must come last */
};

void sdrInitConfig()
Expand Down Expand Up @@ -142,7 +143,7 @@ bool sdrHandleOption(int argc, char **argv, int *jptr)

static sdr_handler *current_handler()
{
static sdr_handler unsupported_handler = { "unsupported", SDR_NONE, noInitConfig, noShowHelp, noHandleOption, unsupportedOpen, noRun, noClose };
static sdr_handler unsupported_handler = { noInitConfig, noShowHelp, noHandleOption, unsupportedOpen, noRun, noClose, "unsupported", SDR_NONE, 0 };

for (int i = 0; sdr_handlers[i].name; ++i) {
if (Modes.sdr_type == sdr_handlers[i].sdr_type) {
Expand Down

0 comments on commit 9de8db8

Please sign in to comment.