Skip to content
Snippets Groups Projects
Commit 5548f666 authored by Jakob Olsson's avatar Jakob Olsson
Browse files

common: move remove_newline to common.c, add some documentation, minor change to isdigits

parent 56b52ce9
Branches
No related tags found
No related merge requests found
......@@ -127,10 +127,10 @@ fail_doc_ptr:
}
int isdigits(const char *pin)
int isdigits(const char *str)
{
while (*pin) {
if (isdigit(*pin++) == 0)
while (*str) {
if (isdigit(*str++) == 0)
return false;
}
......@@ -220,3 +220,14 @@ int check_response(struct json_object *response)
fail:
return -1;
}
void remove_newline(char *input)
{
char *pos;
pos = strchr(input, '\n');
if (!pos)
return;
*pos = '\0';
}
......@@ -75,8 +75,34 @@ void json_to_blob(struct json_object *response, struct blob_buf *bb);
char *xml_parser(struct write_result *result, char *tag);
struct json_object *xml_to_json_converter(struct write_result *result);
int isdigits(const char *pin);
/**
* Function: isdigits
*
* Checks if a string is made up entirely out of digits.
*
* Parameters:
* str - the string to check for digits.
*
* Returns:
* true if the string is made up entirely out of digits.
* false if the string contains any non-digit character.
*/
int isdigits(const char *str);
int validate_puk_format(char *puk);
/**
* Function: validate_pin_format
*
* Checks whether a given PIN code is of valid format or not.
*
* Parameters:
* pin - the string to check for structure validity
*
* Returns:
* 0 if the string is of valid format.
* -1 on invalid format.
*/
int validate_pin_format(char *pin);
int pin_status(struct blob_buf *bb, struct device *dev);
int check_response(struct json_object *response);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment