This repository has been archived by the owner on Dec 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The input tag length needs to be in 27 trytes for ta_find_transactions_by_tag(). Therefore fill_nines() needs to be called if tag's length is under 27. At the same time, api_find_transactions_by_tag() would return error if the length of tag is more than 27 trytes.
- Loading branch information
Showing
8 changed files
with
70 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "fill_nines.h" | ||
|
||
status_t fill_nines(char* new_str, const char* const old_str, | ||
size_t new_str_len) { | ||
if (!new_str || !old_str || new_str_len != NUM_TRYTES_TAG) { | ||
return SC_SERIALIZER_NULL; | ||
} | ||
|
||
int old_str_len = strlen(old_str); | ||
strncpy(new_str, old_str, old_str_len); | ||
|
||
int diff = new_str_len - old_str_len; | ||
if (diff) { | ||
memset((new_str + old_str_len), '9', diff); | ||
} else { | ||
return SC_UTILS_WRONG_REQUEST_OBJ; | ||
} | ||
new_str[new_str_len] = '\0'; | ||
|
||
return SC_OK; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "accelerator/errors.h" | ||
#include "cclient/types/types.h" | ||
|
||
/** | ||
* @brief Patch input string with nines into assigned length. | ||
* | ||
* @param[out] new_str Output patched string | ||
* @param[in] old_str Input string which needs to be patched | ||
* @param[in] new_str_len assigned output string length | ||
* | ||
* @return | ||
* - SC_OK on success | ||
* - non-zero on error | ||
*/ | ||
status_t fill_nines(char* new_str, const char* const old_str, | ||
size_t new_str_len); |