Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/1 setting up antidote #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 15 additions & 6 deletions src/api/text_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,18 @@ char *intu32_2str(intu32 value)
char *intu16list_2str(intu16 *list, int size)
{
char *result = calloc(MAX_INT_STR * (size+1), sizeof(char));
char *current_result = calloc(MAX_INT_STR, sizeof(char));

if (size > 0) {
int i = 0;

for (i = 0; i < size-1; i++) {
sprintf(result, "%s%d,", result, list[i]);
sprintf(current_result, "%d", list[i]);
strcat(result, current_result);
}

sprintf(result, "%s%d", result, list[size-1]);
sprintf(current_result, "%d", list[size-1]);
strcat(result, current_result);
}

return result;
Expand Down Expand Up @@ -183,11 +186,12 @@ char *float2str(float value)
char *octet_string2str(octet_string *str)
{
char *result = calloc(str->length + 1, sizeof(char));

char *current_result = calloc(4, sizeof(char));
int i = 0;

for (i = 0; i < str->length; i++) {
sprintf(result, "%s%c", result, str->value[i]);
sprintf(current_result, "%c", str->value[i]);
strcat(result, current_result);
}

result[str->length] = '\0';
Expand All @@ -205,10 +209,13 @@ char *octet_string2hex(octet_string *str)
{
int size = str->length*2;
char *result = calloc(size+1, sizeof(char));
char *current_result = calloc(4, sizeof(char));

int i = 0;

for (i = 0; i < str->length; i++) {
sprintf(result, "%s%.2X", result, str->value[i]);
sprintf(current_result, "%.2X", str->value[i]);
strcat(result, current_result);
}

result[size] = '\0';
Expand All @@ -227,10 +234,12 @@ char *high_res_relative_time2hex(HighResRelativeTime *time)
int time_length = 8;
int size = time_length*2;
char *result = calloc(size+1, sizeof(char));
char *current_result = calloc(4, sizeof(char));
int i = 0;

for (i = 0; i < time_length; i++) {
sprintf(result, "%s%.2X", result, time->value[i]);
sprintf(result, "%.2X", time->value[i]);
strcat(result, current_result);
}

result[size] = '\0';
Expand Down
10 changes: 7 additions & 3 deletions src/communication/extconfigurations.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,18 @@ static char *ext_configurations_get_file_name(octet_string *system_id,
length = length + 1; // "\0"

char *file_path = calloc(length, sizeof(char));
char *current_file_path = calloc(4, sizeof(char));
sprintf(file_path, "%s", config_path);
int i;

for (i = 0; i < system_id->length; i++) {
sprintf(file_path, "%s%.2x", file_path, system_id->value[i]);
for (i = 0; i < system_id->length; i++) {
sprintf(current_file_path, "%.2x", system_id->value[i]);
strcat(file_path, current_file_path);
}

sprintf(file_path, "%s-%.4x.bin", file_path, config_id);
sprintf(file_path, "-%.4x.bin", config_id);
strcat(file_path, current_file_path);

free(config_path);
return file_path;
}
Expand Down
2 changes: 1 addition & 1 deletion src/communication/plugin/plugin_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ int plugin_network_tcp_setup(CommunicationPlugin *plugin, int numberOfPorts,

if (sockets) {
// plugin was already initialized once
llist_destroy(sockets, (llist_handle_element) free);
llist_destroy(sockets, (llist_handle_element)(int *) free);
sockets = NULL;
}

Expand Down
4 changes: 2 additions & 2 deletions src/trans/trans.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,12 @@ static void unregister_plugin(TransPlugin *plugin)
void trans_finalize()
{
if (_plugins) {
llist_destroy(_plugins, (llist_handle_element) unregister_plugin);
llist_destroy(_plugins, (llist_handle_element)(int *) unregister_plugin);
_plugins = NULL;
}

if (_devices) {
llist_destroy(_devices, (llist_handle_element) destroy_device);
llist_destroy(_devices, (llist_handle_element)(int *) destroy_device);
_devices = NULL;
}

Expand Down
8 changes: 5 additions & 3 deletions src/util/ioutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,14 @@ int ioutil_buffer_to_file(const char *file_path,
*/
void ioutil_print_buffer(intu8 *buffer, int size)
{
char *str = calloc(size*4, sizeof(char));
char *str = calloc(size*4, sizeof(char));
char *currentStr = calloc(4, sizeof(char));

int i;

for (i = 0; i < size; i++) {
sprintf(str, "%s%.2X ", str, buffer[i]);
for (i = 0; i < size; i++) {
sprintf(currentStr, "%.2X", buffer[i]);
strcat(str, currentStr);
}

DEBUG("%s", str);
Expand Down