TextFormatType *ED_text_format_get(Text *text) { TextFormatType *tft; if (text) { const char *text_ext = strchr(text->id.name + 2, '.'); if (text_ext) { text_ext++; /* skip the '.' */ /* Check all text formats in the static list */ for (tft = tft_lb.first; tft; tft = tft->next) { /* All formats should have an ext, but just in case */ const char **ext; for (ext = tft->ext; *ext; ext++) { /* If extension matches text name, return the matching tft */ if (BLI_strcasecmp(text_ext, *ext) == 0) { return tft; } } } } /* If we make it here we never found an extension that worked - return * the "default" text format */ return tft_lb.first; } else { /* Return the "default" text format */ return tft_lb.first; } }
void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, Bone *bone) { bArmature *arm = (bArmature *)ob_arm->data; int flag = arm->flag; std::vector<float> fra; //char prefix[256]; FCurve *fcu = (FCurve *)ob_arm->adt->action->curves.first; while (fcu) { std::string bone_name = getObjectBoneName(ob_arm, fcu); int val = BLI_strcasecmp((char *)bone_name.c_str(), bone->name); if (val == 0) break; fcu = fcu->next; } if (!(fcu)) return; bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone->name); if (!pchan) return; find_frames(ob_arm, fra); if (flag & ARM_RESTPOS) { arm->flag &= ~ARM_RESTPOS; BKE_pose_where_is(scene, ob_arm); } if (fra.size()) { dae_baked_animation(fra, ob_arm, bone); } if (flag & ARM_RESTPOS) arm->flag = flag; BKE_pose_where_is(scene, ob_arm); }
static int compare_extension(const void *a1, const void *a2) { const struct direntry *entry1=a1, *entry2=a2; const char *sufix1, *sufix2; const char *nil=""; if (!(sufix1= strstr (entry1->relname, ".blend.gz"))) sufix1= strrchr (entry1->relname, '.'); if (!(sufix2= strstr (entry2->relname, ".blend.gz"))) sufix2= strrchr (entry2->relname, '.'); if (!sufix1) sufix1= nil; if (!sufix2) sufix2= nil; /* type is equal to stat.st_mode */ if (S_ISDIR(entry1->type)){ if (S_ISDIR(entry2->type)==0) return (-1); } else{ if (S_ISDIR(entry2->type)) return (1); } if (S_ISREG(entry1->type)){ if (S_ISREG(entry2->type)==0) return (-1); } else{ if (S_ISREG(entry2->type)) return (1); } if ((entry1->type & S_IFMT) < (entry2->type & S_IFMT)) return (-1); if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1); /* make sure "." and ".." are always first */ if( strcmp(entry1->relname, ".")==0 ) return (-1); if( strcmp(entry2->relname, ".")==0 ) return (1); if( strcmp(entry1->relname, "..")==0 ) return (-1); if( strcmp(entry2->relname, "..")==0 ) return (1); return (BLI_strcasecmp(sufix1, sufix2)); }
int BLI_rename(char *from, char *to) { if (!BLI_exists(from)) return 0; /* make sure the filenames are different (case insensitive) before removing */ if (BLI_exists(to) && BLI_strcasecmp(from, to)) if(BLI_delete(to, 0, 0)) return 1; return rename(from, to); }
void set_property(bProperty *prop, const char *str) { // extern int Gdfra; /* sector.c */ switch (prop->type) { case GPROP_BOOL: if (BLI_strcasecmp(str, "true") == 0) prop->data = 1; else if (BLI_strcasecmp(str, "false") == 0) prop->data = 0; else prop->data = (atoi(str) != 0); break; case GPROP_INT: prop->data = atoi(str); break; case GPROP_FLOAT: case GPROP_TIME: *((float *)&prop->data) = (float)atof(str); break; case GPROP_STRING: strcpy(prop->poin, str); /* TODO - check size? */ break; } }
static int keycmp(const void *a, const void *b) { const bAKey *ka = a; const bAKey *kb = b; if (ka->pass == kb->pass || ka->pass == -1 || kb->pass == -1) { /* -1 is wildcard for pass */ if (ka->case_str == 1 || kb->case_str == 1) return BLI_strcasecmp(ka->arg, kb->arg); else return strcmp(ka->arg, kb->arg); } else { return BLI_ghashutil_intcmp((const void *)ka->pass, (const void *)kb->pass); } }
/* negative: prop is smaller * positive: prop is larger */ int compare_property(bProperty *prop, const char *str) { // extern int Gdfra; /* sector.c */ float fvalue, ftest; switch (prop->type) { case GPROP_BOOL: if (BLI_strcasecmp(str, "true") == 0) { if (prop->data == 1) return 0; else return 1; } else if (BLI_strcasecmp(str, "false") == 0) { if (prop->data == 0) return 0; else return 1; } /* no break, do GPROP_int too! */ case GPROP_INT: return prop->data - atoi(str); case GPROP_FLOAT: case GPROP_TIME: // WARNING: untested for GPROP_TIME // function isn't used currently fvalue = *((float *)&prop->data); ftest = (float)atof(str); if (fvalue > ftest) return 1; else if (fvalue < ftest) return -1; return 0; case GPROP_STRING: return strcmp(prop->poin, str); } return 0; }
void filepath_qt(char *string, RenderData *rd) { char txt[64]; if (string==0) return; strcpy(string, rd->pic); BLI_path_abs(string, G.main->name); BLI_make_existing_file(string); if (BLI_strcasecmp(string + strlen(string) - 4, ".mov")) { sprintf(txt, "%04d_%04d.mov", (rd->sfra) , (rd->efra) ); strcat(string, txt); } }
/* Get the output filename-- similar to the other output formats */ void BKE_ffmpeg_filepath_get(char *string, RenderData *rd) { char autosplit[20]; const char **exts = get_file_extensions(rd->ffcodecdata.type); const char **fe = exts; if (!string || !exts) return; strcpy(string, rd->pic); BLI_path_abs(string, G.main->name); BLI_make_existing_file(string); autosplit[0] = 0; if ((rd->ffcodecdata.flags & FFMPEG_AUTOSPLIT_OUTPUT) != 0) { sprintf(autosplit, "_%03d", ffmpeg_autosplit_count); } if (rd->scemode & R_EXTENSION) { while (*fe) { if (BLI_strcasecmp(string + strlen(string) - strlen(*fe), *fe) == 0) { break; } fe++; } if (*fe == NULL) { strcat(string, autosplit); BLI_path_frame_range(string, rd->sfra, rd->efra, 4); strcat(string, *exts); } else { *(string + strlen(string) - strlen(*fe)) = 0; strcat(string, autosplit); strcat(string, *fe); } } else { if (BLI_path_frame_check_chars(string)) { BLI_path_frame_range(string, rd->sfra, rd->efra, 4); } strcat(string, autosplit); } }
int BLI_testextensie(const char *str, const char *ext) { short a, b; int retval; a= strlen(str); b= strlen(ext); if(a==0 || b==0 || b>=a) { retval = 0; } else if (BLI_strcasecmp(ext, str + a - b)) { retval = 0; } else { retval = 1; } return (retval); }
static int match_format(const char *name, AVFormatContext *pFormatCtx) { const char *p; int len, namelen; const char *names = pFormatCtx->iformat->name; if (!name || !names) return 0; namelen = strlen(name); while ((p = strchr(names, ','))) { len = MAX2(p - names, namelen); if (!BLI_strncasecmp(name, names, len)) return 1; names = p + 1; } return !BLI_strcasecmp(name, names); }
static int compare_extension(const void *a1, const void *a2) { const struct direntry *entry1 = a1, *entry2 = a2; const char *sufix1, *sufix2; const char *nil = ""; int ret; if ((ret = compare_direntry_generic(entry1, entry2))) { return ret; } if (!(sufix1 = strstr(entry1->relname, ".blend.gz"))) sufix1 = strrchr(entry1->relname, '.'); if (!(sufix2 = strstr(entry2->relname, ".blend.gz"))) sufix2 = strrchr(entry2->relname, '.'); if (!sufix1) sufix1 = nil; if (!sufix2) sufix2 = nil; return BLI_strcasecmp(sufix1, sufix2); }
static void sort_alpha_id(ListBase *lb, ID *id) { ID *idtest; /* insert alphabetically */ if(lb->first!=lb->last) { BLI_remlink(lb, id); idtest= lb->first; while(idtest) { if(BLI_strcasecmp(idtest->name, id->name)>0 || idtest->lib) { BLI_insertlinkbefore(lb, idtest, id); break; } idtest= idtest->next; } /* as last */ if(idtest==NULL) { BLI_addtail(lb, id); } } }
/* Get the output filename-- similar to the other output formats */ static void ffmpeg_filepath_get(FFMpegContext *context, char *string, RenderData *rd, bool preview, const char *suffix) { char autosplit[20]; const char **exts = get_file_extensions(rd->ffcodecdata.type); const char **fe = exts; int sfra, efra; if (!string || !exts) return; if (preview) { sfra = rd->psfra; efra = rd->pefra; } else { sfra = rd->sfra; efra = rd->efra; } strcpy(string, rd->pic); BLI_path_abs(string, G.main->name); BLI_make_existing_file(string); autosplit[0] = 0; if ((rd->ffcodecdata.flags & FFMPEG_AUTOSPLIT_OUTPUT) != 0) { if (context) { sprintf(autosplit, "_%03d", context->ffmpeg_autosplit_count); } } if (rd->scemode & R_EXTENSION) { while (*fe) { if (BLI_strcasecmp(string + strlen(string) - strlen(*fe), *fe) == 0) { break; } fe++; } if (*fe == NULL) { strcat(string, autosplit); BLI_path_frame_range(string, sfra, efra, 4); strcat(string, *exts); } else { *(string + strlen(string) - strlen(*fe)) = 0; strcat(string, autosplit); strcat(string, *fe); } } else { if (BLI_path_frame_check_chars(string)) { BLI_path_frame_range(string, sfra, efra, 4); } strcat(string, autosplit); } BLI_path_suffix(string, FILE_MAX, suffix, ""); }
int BLI_strcaseeq(const char *a, const char *b) { return (BLI_strcasecmp(a, b)==0); }