#include #include #include #include #include float map(float value, float start1, float stop1, float start2, float stop2){ return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1)); } char *str_remove_all(char *str, const char *sub) { size_t len = strlen(sub); if (len > 0) { char *p = str; size_t size = 0; while ((p = strstr(p, sub)) != NULL) { size = (size == 0) ? (p - str) + strlen(p + len) + 1 : size - len; memmove(p, p + len, size - (p - str)); } } return str; } void str_before_nth(char *str, char *str2, char eraser, int found_count){ int i=0; int found=0; while(str[i]!='\0'){ if(str[i]==eraser){ if(found>=found_count){ break; } else { found++; } } i++; } memcpy(str2,str,sizeof(char)*i); } int execret(char *return_buffer, char *command){ // Open a process by creating a pipe FILE *fp = popen(command, "r"); if (fp == NULL) { perror("popen"); return 1; } // Read the output from the command char buffer[128]; while (fgets(buffer, sizeof(buffer) - 1, fp) != NULL) { strcat(return_buffer,buffer); } // Close the pipe if (pclose(fp) == -1) { perror("pclose"); return 1; } return 0; } int execretarr(char **return_arr, char *command){ // Open a process by creating a pipe FILE *fp = popen(command, "r"); int i=0; if (fp == NULL) { perror("popen"); return 1; } // Read the output from the command char buffer[128]; while (fgets(buffer, sizeof(buffer) - 1, fp) != NULL) { for( int i=0;i