char const* getMessageQuoted(int32_t token) { std::string msg = getMessage(token); str_remove(&msg, ",.!?"); str_replace(&msg, " ", '_'); str_tolower(&msg); return msg.c_str(); }
void release_list(TSTR_LIST list) { int i,j; if (list==NULL) return; j=str_count(list); for(i=0;i<j;i++) str_remove(&list, i); free(list); }
/* Removes value(s) from the option (-= operator). Returns non-zero on * success. */ static int set_remove(opt_t *opt, const char value[]) { if(opt->type != OPT_INT && opt->type != OPT_SET && opt->type != OPT_STRLIST && opt->type != OPT_CHARSET) return -1; if(opt->type == OPT_INT) { char *p; int i; i = strtol(value, &p, 10); if(*p != '\0') return -1; if(i == 0) return 0; opt->val.int_val -= i; notify_option_update(opt, OP_MODIFIED, opt->val); } else if(opt->type == OPT_SET) { if(set_op(opt, value, SO_REMOVE)) { notify_option_update(opt, OP_MODIFIED, opt->val); } } else if(opt->type == OPT_CHARSET) { if(charset_remove_all(opt, value)) { notify_option_update(opt, OP_MODIFIED, opt->val); } } else if(*value != '\0') { size_t len = 0; if(opt->val.str_val != NULL) len = strlen(opt->val.str_val); str_remove(opt->val.str_val, value); if(opt->val.str_val != NULL && len != strlen(opt->val.str_val)) { notify_option_update(opt, OP_MODIFIED, opt->val); } } return 0; }
/* -------------------------------------------------- void mpLoad(STRING *scan_path, STRING *scan_ext) Desc: Returns: - -------------------------------------------------- */ void mpLoad(STRING *scan_path, STRING *scan_ext) { WriteLog("[ ] Scanning for external music..."); STRING *_scan_path = str_create(scan_path); // Prevent modification of the original string mpSongs = txt_for_dir(mpPool, str_cat(_scan_path,scan_ext) ); while(proc_status(txt_for_dir)) wait(1); str_remove(_scan_path); WriteLog(", found " , (var) mpSongs ); // WriteLog(" tracks."); NewLine(); WriteLog("[X] Task completed."); NewLine(); }
int exalt_eth_save_autoload(exalt_ethernet* eth) { FILE* fr,*fw; char buf[1024]; char regexp[1024]; char* res = NULL; exalt_regex * r; if(!eth) { fprintf(stderr,"exalt_eth_save_autoload(): eth==null ! \n"); return -1; } if(!exalt_eth_save_file_exist(CONF_FILE)) if(exalt_eth_save_file_create(CONF_FILE,NULL)==-1) { fprintf(stderr,"exalt_eth_save_autoload(): error can't create the file! \n"); return -1; } exalt_eth_save_file_create(FILE_TEMP,NULL); //copy the conf file in the temp file fw = fopen(FILE_TEMP,"w"); fr = fopen(CONF_FILE,"r"); while(fgets(buf,1024,fr)) fprintf(fw,buf); fclose(fw); fclose(fr); //remove the current autoload for this card if it is present fr = fopen(FILE_TEMP,"r"); fw = fopen(CONF_FILE,"w"); sprintf(regexp,REGEXP_SAVE_DEBIAN_IS_AUTO_ETH, exalt_eth_get_name(eth)); r = exalt_regex_create("",regexp,0); while(fgets(buf,1024,fr)) { exalt_regex_set_request(r,buf); if( exalt_regex_execute(r) && r->nmatch>0 ) { res = str_remove(buf,exalt_eth_get_name(eth)); if(res) { exalt_regex_set_request(r,res); exalt_regex_set_regex(r,REGEXP_SAVE_DEBIAN_IS_AUTO_ALONE); if(!exalt_regex_execute(r)) fprintf(fw,res); EXALT_FREE(res) exalt_regex_set_regex(r,REGEXP_SAVE_DEBIAN_IS_AUTO_ETH); } } else fprintf(fw,buf); } if(exalt_eth_is_activate(eth)) fprintf(fw,"auto %s\n",exalt_eth_get_name(eth)); fclose(fw); fclose(fr); exalt_regex_free(&r); return 1; }
char *str_ftoa(char *result, double value, double reference) /* * str_ftoa - convert real value to floating equivalent */ { static char *digit = "0123456789"; char format[STR_MAX]; double abs_val; char str[STR_MAX], *fcp, *cp; int count, exponent, factor, mantissa; int fdigits, digits, scientific_notation; if (value != 0) { abs_val = fabs(value); exponent = (int) (log10(abs_val) + pow(10.0, -NDIGITS)); if (exponent < 0) exponent--; factor = (NDIGITS - 1) - exponent; mantissa = (int) (abs_val * pow(10.0, factor) + 0.5); strcpy(result, ""); count = 0; fdigits = digits = 0; do { count++; strcpy(str, result); result[0] = digit[mantissa % 10]; result[1] = '\0'; strcat(result, str); if (count == factor) { strcpy(str, result); strcpy(result, "."); strcat(result, str); } mantissa = mantissa / 10; } while (count != NDIGITS); scientific_notation = (exponent <= 1 - NDIGITS) || (exponent >= NDIGITS); if (scientific_notation || exponent < 0) { if (!scientific_notation) { strcpy(str, ""); str_pad(str, '0', -exponent - 1); strcat(str, result); strcpy(result, str); } strcpy(str, "0."); strcat(str, result); strcpy(result, str); } if (value < 0) { strcpy(str, "-"); strcat(str, result); strcpy(result, str); } if (strchr(result, '.') != 0) { str_remove(result, '0'); str_remove(result, '.'); } if (scientific_notation) { strcat(result, "E"); sprintf(str, "%d", exponent + 1); strcat(result, str); } else { sprintf(format, "%lg", reference); if (strchr(format, 'E') == 0) if ((fcp = strchr(format, '.')) != 0) { fdigits = strlen(format) - (int) (fcp - format) - 1; if ((cp = strchr(result, '.')) != 0) { digits = strlen(result) - (int) (cp - result) - 1; if (fdigits > digits) strncat(result, "000000000", fdigits - digits); } else { strcat(result, "."); strncat(result, "000000000", fdigits); } } } } else strcpy(result, "0"); return result; }