mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 22:03:42 -07:00
string trimming
This commit is contained in:
parent
9be3473864
commit
810eaeac25
2 changed files with 16 additions and 0 deletions
|
@ -1409,6 +1409,20 @@ void str_inverse_bin(char *buf, size_t len) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void str_trim(char *s) {
|
||||||
|
if (s == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle empty string
|
||||||
|
if (!*s) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *ptr;
|
||||||
|
for (ptr = s + strlen(s) - 1; (ptr >= s) && isspace(*ptr); --ptr);
|
||||||
|
ptr[1] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a hex string to component "hi2", "hi" and "lo" 32-bit integers
|
* Converts a hex string to component "hi2", "hi" and "lo" 32-bit integers
|
||||||
|
|
|
@ -168,10 +168,12 @@ void str_creplace(char *buf, size_t len, char from, char to);
|
||||||
void str_reverse(char *buf, size_t len);
|
void str_reverse(char *buf, size_t len);
|
||||||
void str_inverse_hex(char *buf, size_t len);
|
void str_inverse_hex(char *buf, size_t len);
|
||||||
void str_inverse_bin(char *buf, size_t len);
|
void str_inverse_bin(char *buf, size_t len);
|
||||||
|
void str_trim(char *s);
|
||||||
|
|
||||||
char *str_dup(const char *src);
|
char *str_dup(const char *src);
|
||||||
char *str_ndup(const char *src, size_t len);
|
char *str_ndup(const char *src, size_t len);
|
||||||
size_t str_nlen(const char *src, size_t maxlen);
|
size_t str_nlen(const char *src, size_t maxlen);
|
||||||
|
|
||||||
int hexstring_to_u96(uint32_t *hi2, uint32_t *hi, uint32_t *lo, const char *str);
|
int hexstring_to_u96(uint32_t *hi2, uint32_t *hi, uint32_t *lo, const char *str);
|
||||||
int binstring_to_u96(uint32_t *hi2, uint32_t *hi, uint32_t *lo, const char *str);
|
int binstring_to_u96(uint32_t *hi2, uint32_t *hi, uint32_t *lo, const char *str);
|
||||||
int binarray_to_u96(uint32_t *hi2, uint32_t *hi, uint32_t *lo, const uint8_t *arr, int arrlen);
|
int binarray_to_u96(uint32_t *hi2, uint32_t *hi, uint32_t *lo, const uint8_t *arr, int arrlen);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue