mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 10:37:23 -07:00
use more static and fix [-Wmissing-prototypes], ongoing...
This commit is contained in:
parent
05374fce07
commit
4f32655004
25 changed files with 167 additions and 151 deletions
|
@ -262,33 +262,37 @@ bool getDemodBuff(uint8_t *buff, size_t *size) {
|
|||
|
||||
// include <math.h>
|
||||
// Root mean square
|
||||
double rms(double *v, size_t n) {
|
||||
/*
|
||||
static double rms(double *v, size_t n) {
|
||||
double sum = 0.0;
|
||||
for (size_t i = 0; i < n; i++)
|
||||
sum += v[i] * v[i];
|
||||
return sqrt(sum / n);
|
||||
}
|
||||
int cmp_int(const void *a, const void *b) {
|
||||
|
||||
static int cmp_int(const void *a, const void *b) {
|
||||
if (*(const int *)a < * (const int *)b)
|
||||
return -1;
|
||||
else
|
||||
return *(const int *)a > *(const int *)b;
|
||||
}
|
||||
int cmp_uint8(const void *a, const void *b) {
|
||||
static int cmp_uint8(const void *a, const void *b) {
|
||||
if (*(const uint8_t *)a < * (const uint8_t *)b)
|
||||
return -1;
|
||||
else
|
||||
return *(const uint8_t *)a > *(const uint8_t *)b;
|
||||
}
|
||||
// Median of a array of values
|
||||
double median_int(int *src, size_t size) {
|
||||
|
||||
static double median_int(int *src, size_t size) {
|
||||
qsort(src, size, sizeof(int), cmp_int);
|
||||
return 0.5 * (src[size / 2] + src[(size - 1) / 2]);
|
||||
}
|
||||
double median_uint8(uint8_t *src, size_t size) {
|
||||
static double median_uint8(uint8_t *src, size_t size) {
|
||||
qsort(src, size, sizeof(uint8_t), cmp_uint8);
|
||||
return 0.5 * (src[size / 2] + src[(size - 1) / 2]);
|
||||
}
|
||||
*/
|
||||
// function to compute mean for a series
|
||||
static double compute_mean(const int *data, size_t n) {
|
||||
double mean = 0.0;
|
||||
|
@ -358,7 +362,7 @@ void save_restoreDB(uint8_t saveOpt) {
|
|||
}
|
||||
}
|
||||
|
||||
int CmdSetDebugMode(const char *Cmd) {
|
||||
static int CmdSetDebugMode(const char *Cmd) {
|
||||
int demod = 0;
|
||||
sscanf(Cmd, "%i", &demod);
|
||||
g_debugMode = (uint8_t)demod;
|
||||
|
@ -550,7 +554,7 @@ int ASKDemod(const char *Cmd, bool verbose, bool emSearch, uint8_t askType) {
|
|||
//takes 5 arguments - clock, invert, maxErr, maxLen as integers and amplify as char == 'a'
|
||||
//attempts to demodulate ask while decoding manchester
|
||||
//prints binary found and saves in graphbuffer for further commands
|
||||
int Cmdaskmandemod(const char *Cmd) {
|
||||
static int Cmdaskmandemod(const char *Cmd) {
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (strlen(Cmd) > 45 || cmdp == 'h') return usage_data_rawdemod_am();
|
||||
|
||||
|
@ -705,7 +709,7 @@ int ASKbiphaseDemod(const char *Cmd, bool verbose) {
|
|||
return 1;
|
||||
}
|
||||
//by marshmellow - see ASKbiphaseDemod
|
||||
int Cmdaskbiphdemod(const char *Cmd) {
|
||||
static int Cmdaskbiphdemod(const char *Cmd) {
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (strlen(Cmd) > 25 || cmdp == 'h') return usage_data_rawdemod_ab();
|
||||
|
||||
|
@ -713,7 +717,7 @@ int Cmdaskbiphdemod(const char *Cmd) {
|
|||
}
|
||||
|
||||
//by marshmellow - see ASKDemod
|
||||
int Cmdaskrawdemod(const char *Cmd) {
|
||||
static int Cmdaskrawdemod(const char *Cmd) {
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (strlen(Cmd) > 25 || cmdp == 'h') return usage_data_rawdemod_ar();
|
||||
|
||||
|
@ -954,7 +958,7 @@ int AskEdgeDetect(const int *in, int *out, int len, int threshold) {
|
|||
//use large jumps in read samples to identify edges of waves and then amplify that wave to max
|
||||
//similar to dirtheshold, threshold commands
|
||||
//takes a threshold length which is the measured length between two samples then determines an edge
|
||||
int CmdAskEdgeDetect(const char *Cmd) {
|
||||
static int CmdAskEdgeDetect(const char *Cmd) {
|
||||
int thresLen = 25;
|
||||
int ans = 0;
|
||||
sscanf(Cmd, "%i", &thresLen);
|
||||
|
@ -967,7 +971,7 @@ int CmdAskEdgeDetect(const char *Cmd) {
|
|||
/* Print our clock rate */
|
||||
// uses data from graphbuffer
|
||||
// adjusted to take char parameter for type of modulation to find the clock - by marshmellow.
|
||||
int CmdDetectClockRate(const char *Cmd) {
|
||||
static int CmdDetectClockRate(const char *Cmd) {
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (strlen(Cmd) > 6 || strlen(Cmd) == 0 || cmdp == 'h')
|
||||
return usage_data_detectclock();
|
||||
|
@ -994,7 +998,7 @@ int CmdDetectClockRate(const char *Cmd) {
|
|||
return clock1;
|
||||
}
|
||||
|
||||
char *GetFSKType(uint8_t fchigh, uint8_t fclow, uint8_t invert) {
|
||||
static char *GetFSKType(uint8_t fchigh, uint8_t fclow, uint8_t invert) {
|
||||
static char fType[8];
|
||||
memset(fType, 0x00, 8);
|
||||
char *fskType = fType;
|
||||
|
@ -1088,7 +1092,7 @@ int FSKrawDemod(const char *Cmd, bool verbose) {
|
|||
//fsk raw demod and print binary
|
||||
//takes 4 arguments - Clock, invert, fchigh, fclow
|
||||
//defaults: clock = 50, invert=1, fchigh=10, fclow=8 (RF/10 RF/8 (fsk2a))
|
||||
int CmdFSKrawdemod(const char *Cmd) {
|
||||
static int CmdFSKrawdemod(const char *Cmd) {
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (strlen(Cmd) > 20 || cmdp == 'h') return usage_data_rawdemod_fs();
|
||||
|
||||
|
@ -1258,7 +1262,7 @@ int NRZrawDemod(const char *Cmd, bool verbose) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int CmdNRZrawDemod(const char *Cmd) {
|
||||
static int CmdNRZrawDemod(const char *Cmd) {
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (strlen(Cmd) > 16 || cmdp == 'h') return usage_data_rawdemod_nr();
|
||||
|
||||
|
@ -1287,7 +1291,7 @@ int CmdPSK1rawDemod(const char *Cmd) {
|
|||
|
||||
// by marshmellow
|
||||
// takes same args as cmdpsk1rawdemod
|
||||
int CmdPSK2rawDemod(const char *Cmd) {
|
||||
static int CmdPSK2rawDemod(const char *Cmd) {
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (strlen(Cmd) > 16 || cmdp == 'h') return usage_data_rawdemod_p2();
|
||||
|
||||
|
@ -1304,7 +1308,7 @@ int CmdPSK2rawDemod(const char *Cmd) {
|
|||
}
|
||||
|
||||
// by marshmellow - combines all raw demod functions into one menu command
|
||||
int CmdRawDemod(const char *Cmd) {
|
||||
static int CmdRawDemod(const char *Cmd) {
|
||||
int ans = 0;
|
||||
|
||||
if (strlen(Cmd) > 35 || strlen(Cmd) < 2)
|
||||
|
@ -1359,13 +1363,13 @@ int CmdGrid(const char *Cmd) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int CmdSetGraphMarkers(const char *Cmd) {
|
||||
static int CmdSetGraphMarkers(const char *Cmd) {
|
||||
sscanf(Cmd, "%i %i", &CursorCPos, &CursorDPos);
|
||||
RepaintGraphWindow();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CmdHexsamples(const char *Cmd) {
|
||||
static int CmdHexsamples(const char *Cmd) {
|
||||
int i, j, requested = 0, offset = 0;
|
||||
char string_buf[25];
|
||||
char *string_ptr = string_buf;
|
||||
|
@ -1503,7 +1507,7 @@ int getSamples(int n, bool silent) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int CmdSamples(const char *Cmd) {
|
||||
static int CmdSamples(const char *Cmd) {
|
||||
int n = strtol(Cmd, NULL, 0);
|
||||
return getSamples(n, false);
|
||||
}
|
||||
|
@ -1609,7 +1613,7 @@ int CmdTuneSamples(const char *Cmd) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int CmdLoad(const char *Cmd) {
|
||||
static int CmdLoad(const char *Cmd) {
|
||||
char filename[FILE_PATH_SIZE] = {0x00};
|
||||
int len = 0;
|
||||
|
||||
|
@ -1665,7 +1669,7 @@ int CmdLtrim(const char *Cmd) {
|
|||
}
|
||||
|
||||
// trim graph from the beginning
|
||||
int CmdRtrim(const char *Cmd) {
|
||||
static int CmdRtrim(const char *Cmd) {
|
||||
|
||||
int ds = atoi(Cmd);
|
||||
|
||||
|
@ -1678,7 +1682,7 @@ int CmdRtrim(const char *Cmd) {
|
|||
}
|
||||
|
||||
// trim graph (middle) piece
|
||||
int CmdMtrim(const char *Cmd) {
|
||||
static int CmdMtrim(const char *Cmd) {
|
||||
int start = 0, stop = 0;
|
||||
sscanf(Cmd, "%i %i", &start, &stop);
|
||||
|
||||
|
@ -1727,7 +1731,7 @@ int CmdPlot(const char *Cmd) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int CmdSave(const char *Cmd) {
|
||||
static int CmdSave(const char *Cmd) {
|
||||
|
||||
int len = 0;
|
||||
char filename[FILE_PATH_SIZE] = {0x00};
|
||||
|
@ -1752,7 +1756,7 @@ int CmdSave(const char *Cmd) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int CmdScale(const char *Cmd) {
|
||||
static int CmdScale(const char *Cmd) {
|
||||
CursorScaleFactor = atoi(Cmd);
|
||||
if (CursorScaleFactor == 0) {
|
||||
PrintAndLogEx(FAILED, "bad, can't have zero scale");
|
||||
|
@ -1791,7 +1795,7 @@ int directionalThreshold(const int *in, int *out, size_t len, int8_t up, int8_t
|
|||
return 0;
|
||||
}
|
||||
|
||||
int CmdDirectionalThreshold(const char *Cmd) {
|
||||
static int CmdDirectionalThreshold(const char *Cmd) {
|
||||
int8_t up = param_get8(Cmd, 0);
|
||||
int8_t down = param_get8(Cmd, 1);
|
||||
|
||||
|
@ -1809,7 +1813,7 @@ int CmdDirectionalThreshold(const char *Cmd) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int CmdZerocrossings(const char *Cmd) {
|
||||
static int CmdZerocrossings(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
// Zero-crossings aren't meaningful unless the signal is zero-mean.
|
||||
CmdHpf("");
|
||||
|
@ -1846,7 +1850,7 @@ int CmdZerocrossings(const char *Cmd) {
|
|||
* @param Cmd
|
||||
* @return
|
||||
*/
|
||||
int Cmdbin2hex(const char *Cmd) {
|
||||
static int Cmdbin2hex(const char *Cmd) {
|
||||
int bg = 0, en = 0;
|
||||
if (param_getptr(Cmd, &bg, &en, 0))
|
||||
return usage_data_bin2hex();
|
||||
|
@ -1876,7 +1880,7 @@ int Cmdbin2hex(const char *Cmd) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int Cmdhex2bin(const char *Cmd) {
|
||||
static int Cmdhex2bin(const char *Cmd) {
|
||||
int bg = 0, en = 0;
|
||||
if (param_getptr(Cmd, &bg, &en, 0)) return usage_data_hex2bin();
|
||||
|
||||
|
@ -1918,7 +1922,7 @@ static const int HighTone[] = {
|
|||
1, 1, 1, 1, -1, -1, -1, -1, -1, // note one extra -1 to padd due to 50/8 remainder
|
||||
};
|
||||
*/
|
||||
void GetHiLoTone(int *LowTone, int *HighTone, int clk, int LowToneFC, int HighToneFC) {
|
||||
static void GetHiLoTone(int *LowTone, int *HighTone, int clk, int LowToneFC, int HighToneFC) {
|
||||
int i, j = 0;
|
||||
int Left_Modifier = ((clk % LowToneFC) % 2) + ((clk % LowToneFC) / 2);
|
||||
int Right_Modifier = (clk % LowToneFC) / 2;
|
||||
|
@ -1981,7 +1985,7 @@ void GetHiLoTone(int *LowTone, int *HighTone, int clk, int LowToneFC, int HighTo
|
|||
|
||||
//old CmdFSKdemod adapted by marshmellow
|
||||
//converts FSK to clear NRZ style wave. (or demodulates)
|
||||
int FSKToNRZ(int *data, int *dataLen, int clk, int LowToneFC, int HighToneFC) {
|
||||
static int FSKToNRZ(int *data, int *dataLen, int clk, int LowToneFC, int HighToneFC) {
|
||||
uint8_t ans = 0;
|
||||
if (clk == 0 || LowToneFC == 0 || HighToneFC == 0) {
|
||||
int firstClockEdge = 0;
|
||||
|
@ -2042,7 +2046,7 @@ int FSKToNRZ(int *data, int *dataLen, int clk, int LowToneFC, int HighToneFC) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int CmdFSKToNRZ(const char *Cmd) {
|
||||
static int CmdFSKToNRZ(const char *Cmd) {
|
||||
// take clk, fc_low, fc_high
|
||||
// blank = auto;
|
||||
bool errors = false;
|
||||
|
@ -2082,7 +2086,7 @@ int CmdFSKToNRZ(const char *Cmd) {
|
|||
return ans;
|
||||
}
|
||||
|
||||
int CmdDataIIR(const char *Cmd) {
|
||||
static int CmdDataIIR(const char *Cmd) {
|
||||
uint8_t k = param_get8(Cmd, 0);
|
||||
//iceIIR_Butterworth(GraphBuffer, GraphTraceLen);
|
||||
iceSimple_Filter(GraphBuffer, GraphTraceLen, k);
|
||||
|
@ -2136,14 +2140,15 @@ static command_t CommandTable[] = {
|
|||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
static int CmdHelp(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
CmdsHelp(CommandTable);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CmdData(const char *Cmd) {
|
||||
clearCommandBuffer();
|
||||
CmdsParse(CommandTable, Cmd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CmdHelp(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
CmdsHelp(CommandTable);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue