Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. #include <string.h>
  2. #include"libmgfx.h"
  3.  
  4. static struct mgfx_image_format * the_fmts=NULL;
  5.  
  6. void register_image_format(struct mgfx_image_format * fmt)
  7. {
  8.  fmt->next=the_fmts;
  9.  the_fmts=fmt;
  10. }
  11.  
  12. struct mgfx_image_format * get_image_format(char * fname)
  13. {
  14.  char * p;
  15.  int j;
  16.  struct mgfx_image_format * fmt;
  17.  if(!the_fmts) return NULL;
  18.  p=strstr(fname,".");
  19.  if(!p) return NULL;
  20.  p++;
  21.  j=strlen(p);
  22.  if(!j) return NULL;
  23.  strlwr(p);
  24.  for(fmt=the_fmts;fmt;fmt=fmt->next)
  25.  {
  26.   if(strlen(fmt->fmt_ext)==j)
  27.    if(!strncmp(p,fmt->fmt_ext,j)) return fmt;
  28.  }
  29.  return NULL;
  30. }
  31.