Beispiel #1
0
static inline int get_format(unsigned char *filename, int l)
{
    char buf[4];
    int x;
    while (l)
    {
        l--;
        if (filename[l] == '.')
        {
            filename = &filename[l];
            l = 0;
            if (strlen(filename) > 4 || strlen(filename) == 1)
            {
                return PTP_OFC_Undefined;
            }
            filename++;
            for (x = 0; x < strlen(filename); x++)
            {
                buf[x] = __tolower(filename[x]);
            }
            buf[strlen(filename)] = 0;
            const struct mime_map *map = mime_map;
            while (map->ext)
            {
                if (!strcmp(buf,map->ext))
                {
                    return map->type;
                }
                map++;
            }
        }
    }
    return PTP_OFC_Undefined;
}
Beispiel #2
0
int atoi (const char *str)
{
    int value = 0;
    int sign = 1;
    
    while (isspace(*str))
    {
        str++;
    }
    
    if(('0' == *str) && ('x'==*(str+1) || 'X'==*(str+1))) /* hex specific code */
    {
        str+=2;
        while ('0' == *str)
        {
            str++;
        }
        
        while (isxdigit(*str))
        {
            value = (value << 4);
            if(isdigit(*str))
                value += (*str - '0');
            else
                value += (__tolower(*str) - 'a' + 10);
            str++;
        }
        
        return value;
    }
    else
    {    
        if ('-' == *str)
        {
            sign = -1;
            str++;
        }
        else if ('+' == *str)
        {
            str++;
        }
        
        while ('0' == *str)
        {
            str++;
        }
        
        while (isdigit(*str))
        {
            value = (value * 10) + (*str - '0');
            str++;
        }
    
        return value * sign;
    }
}
Beispiel #3
0
DECL_EXTERN_API(BOOLEAN, StringToLowerW, IN OUT LPWSTR lpStr)
{
	LPWSTR p = lpStr;
	for (; *p; ++p)
	{
		*p = __tolower(*p);
	}

	return TRUE;
}
Beispiel #4
0
int tolower(int c) 
{
	return __tolower(c);
}
Beispiel #5
0
wint_t
towlower(wint_t wc)
{
        return (__tolower(wc));
}
int  TreeCreateTreeFiles(char *tree, int shot, int source_shot)
{
  int len = strlen(tree);
  char tree_lower[13];
  char pathname[32];
  char *path;
  char *pathin;
  int pathlen;
  char name[32];
  int i;
  int status = 1;
  int itype;
  char *types[] = {".tree",".characteristics",".datafile"};
  for (i=0;i<len && i < 12;i++)
    tree_lower[i] = __tolower(tree[i]);
  tree_lower[i]=0;
  strcpy(pathname,tree_lower);
  strcat(pathname,TREE_PATH_SUFFIX);
#if defined(__VMS)
  pathin = strcpy(malloc(strlen(pathname)+1,pathname);
#else
  pathin = TranslateLogical(pathname);
#endif
  if (pathin)
  {
    pathlen = strlen(pathin);
    for (itype=0;itype<3 && (status & 1);itype++)
    {
      struct stat stat_info;
      char *srcfile = 0;
      char *dstfile = 0;
      char *type = types[itype];
      char *part;
      path = MaskReplace(pathin,tree_lower,source_shot);
      pathlen = strlen(path);
      if (source_shot < 0)
        sprintf(name,"%s_model",tree_lower);
      else if (source_shot < 1000)
        sprintf(name,"%s_%03d",tree_lower,source_shot);
      else
        sprintf(name,"%s_%d",tree_lower,source_shot);
      for (i=0,part=path;i<pathlen+1;i++)
      {
        if (*part == ' ') 
          part++;
        else if ((path[i] == ';' || path[i] == 0) && strlen(part))
        {
	      path[i] = 0;
          srcfile = strcpy(malloc(strlen(part)+strlen(name)+strlen(type)+2),part);
          if (srcfile[strlen(srcfile)-1] == '+')
	  {
            srcfile[strlen(srcfile)-1] = '\0';
          }
          else
	  {
	    if (strcmp(srcfile+strlen(srcfile)-1,TREE_PATH_DELIM))
	        strcat(srcfile,TREE_PATH_DELIM);
	    strcat(srcfile,name);
          }
	  strcat(srcfile,type);
          if (MDS_IO_EXISTS(srcfile))
            break;
          else
		  {
            free(srcfile);
            srcfile = 0;
	        part = &path[i+1];
          }
        }
      }
      free(path);
      if (srcfile)
      {
        path = MaskReplace(pathin,tree_lower,shot);
        pathlen = strlen(path);
        if (shot < 0)
          sprintf(name,"%s_model",tree_lower);
        else if (shot < 1000)
          sprintf(name,"%s_%03d",tree_lower,shot);
        else
          sprintf(name,"%s_%d",tree_lower,shot);
        for (i=0,part=path;i<pathlen+1;i++)
        {
          if (*part == ' ') 
			  part++;
          else if ((path[i] == ';' || path[i] == 0) && strlen(part))
          {
	    path[i] = 0;
	    dstfile = strcpy(malloc(strlen(part)+strlen(name)+strlen(type)+2),part);
            if (dstfile[strlen(dstfile)-1] == '+')
	    {
              char *delim = TREE_PATH_DELIM;
              int j = strlen(dstfile) - 1;
              dstfile[j] = '\0';
              for (j--;j >= 0 && dstfile[j] != delim[0]; j--);
              if (j >= 0)
	      {
                dstfile[j] = 0;
                if (MDS_IO_EXISTS(dstfile))
		{
                  dstfile[j] = delim[0];
                  strcat(dstfile,type);
                  break;
                }
              }
            }
            else
	    {
	      if (strcmp(dstfile+strlen(dstfile)-1,TREE_PATH_DELIM) == 0)
                *(dstfile+strlen(dstfile)-1) = 0;
              if (MDS_IO_EXISTS(dstfile))
              {
                strcat(dstfile,TREE_PATH_DELIM);
                strcat(dstfile,name);
                strcat(dstfile,type);
                break;
              }
            }
            free(dstfile);
            dstfile = 0;
            part = &path[i+1];
          }
        }
        free(path);
        if (dstfile)
        {
          status = CopyFile(srcfile,dstfile,0);
          free(dstfile);
        }
        else
          status = TreeINVPATH;
        free(srcfile);
      }
      else
        status = TreeTREENF;
    }
    TranslateLogicalFree(pathin);
  }
  else
    status = TreeINVPATH;
  return status;
}