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

ic_sub as first data in output[] eg. after an ic_push doesn't clear the previously added section correctly #1

Open
kendownie opened this issue Jul 13, 2021 · 0 comments

Comments

@kendownie
Copy link

I've added a very hacky line in ic_sub() to clear the buffer in these circumstances. There are clearly tidier ways of doing this, but I just wanted it to work! New ic_sub() below....

void ic_sub(char *resource)
{
int i;

ic_check( strlen(saved_section) + strlen(influx_tags) +strlen(saved_sub) + strlen(resource) + 9);

/* remove previously added section */
if (first_sub) {
for (i = output_char - 1; i > 0; i--) {
    if (output[i] == '\n') {
	output[i + 1] = 0;
	output_char = i + 1;
	break;
    }
}
if( i==0 ){ output_char = 0; output[output_char] = '\0'; }      // Clears previous section at start of output[]
}
first_sub = 0;

/* remove the trailing s */
strcpy(saved_sub, saved_section);
if (saved_sub[strlen(saved_sub) - 1] == 's') {
saved_sub[strlen(saved_sub) - 1] = 0;
}
output_char += sprintf(&output[output_char], "%s,%s,%s_name=%s ", saved_section, influx_tags, saved_sub, resource);
subended = 0;
DEBUG fprintf(stderr, "ic_sub(\"%s\") count=%ld\n", resource, output_char);

}

@kendownie kendownie changed the title ic_sub as first data in outpuyt[] eg. after an ic_push doesn't clear the previously added section correctly ic_sub as first data in output[] eg. after an ic_push doesn't clear the previously added section correctly Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant