Exemple #1
0
char *
UUFNameFilterDOS (void *opaque, char *fname)
{
  static char dosname[13], *ptr1, *ptr2;
  int count=0;

  if (fname == NULL)
    return NULL;

  /*
   * strip directory information
   */

  if ((ptr1 = _FP_strrchr (fname, '/')) != NULL)
    fname = ptr1 + 1;
  else if ((ptr1 = _FP_strrchr (fname, '\\')) != NULL)
    fname = ptr1 + 1;

  ptr1 = dosname;

  while (*fname && *fname!='.' && count++ < 8) {
    if (*fname == ' ')
      *ptr1++ = '_';
    else
      *ptr1++ = *fname;
    fname++;
  }
  while (*fname && *fname!='.')
    fname++;
  if (ptr1 == dosname)
    *ptr1++ = '_';
  if (*fname=='.') {
    *ptr1++ = *fname++;
    if (_FP_stricmp (fname, "tar.gz") == 0) {
      *ptr1++ = 't';
      *ptr1++ = 'g';
      *ptr1++ = 'z';
    }
    else {
      if ((ptr2 = _FP_strrchr (fname, '.')) == NULL)
	ptr2 = fname;
      else
	ptr2++;
      count=0;
      while (*ptr2 && count++ < 3) {
	if (*ptr2 == ' ')
	  *ptr1++ = '_';
	else
	  *ptr1++ = *ptr2;
	ptr2++;
      }
    }
  }
  *ptr1 = '\0';
  return dosname;
}
Exemple #2
0
char *
UUFNameFilterUnix (void *opaque, char *fname)
{
  char *ptr;

  if (fname == NULL)
    return NULL;

  /*
   * strip directory information
   */

  if ((ptr = _FP_strrchr (fname, '/')) != NULL) {
    fname = ptr+1;
  }

  if ((ptr = _FP_strrchr (fname, '\\')) != NULL) {
    fname = ptr+1;
  }

  if (strcmp (fname, ".") == 0 || strcmp (fname, "..") == 0) {
    fname[0] = '_';
  }

  /*
   * remove space characters from the beginning
   */

  while (*fname == ' ') {
    fname++;
  }

  /*
   * If filename is empty by now, return a dummy string
   */

  if (!*fname) {
    return "blank_filename";
  }

  /*
   * Replace all questionable punctuation characters by underscores
   */

  for (ptr=fname; *ptr; ptr++) {
    if (*ptr == '"' || *ptr == '<' || *ptr == '>' ||
	*ptr == '{' || *ptr == '}' || *ptr == '|' ||
	*ptr == '&' || *ptr == '\t' || *ptr == '\r' ||
	*ptr == '\n') {
      *ptr = '_';
    }
  }
  
  return fname;
}
Exemple #3
0
static int
UUSMPKnownExt (char *filename)
{
  char **eiter = knownexts, *ptr=_FP_strrchr(filename, '.');
  int count=0, where=0;

  if (ptr == NULL)
    return -1;
  ptr++;

  while (*eiter) {
    if (_FP_stricmp (ptr, (**eiter=='@')?*eiter+1:*eiter) == 0)
      return where;
    else
      eiter++;

    if (*eiter == NULL)
      break;

    if (**eiter=='@')
      count++;
    else
      where = ++count;
  }
  return -1;
}
Exemple #4
0
char * FNameFilter (void *opaque, char *fname)
{
  static char dname[13];
  char *p1, *p2;
  int i;

  if ((p1 = _FP_strrchr (fname, '/')) == NULL)
    p1 = fname;
  if ((p2 = _FP_strrchr (p1, '\\')) == NULL)
    p2 = p1;
  for (i=0, p1=dname; *p2 && *p2!='.' && i<8; i++)
    *p1++ = (*p2==' ')?(p2++,'_'):*p2++;
  while (*p2 && *p2 != '.') p2++;
  if ((*p1++ = *p2++) == '.')
    for (i=0; *p2 && *p2!='.' && i<3; i++)
      *p1++ = (*p2==' ')?(p2++,'_'):*p2++;
  *p1 = '\0';
  return dname;
}