Logo Search packages:      
Sourcecode: cbmconvert version File versions  Download package

const char* getFilename ( const struct Filename name  ) 

Convert a file name to a printable null-terminated string.

Parameters:
name the PETSCII file name to be converted
Returns:
the corresponding ASCII file name

Definition at line 34 of file util.c.

References CBM, DEL, Filename::name, PRG, Filename::recordLength, REL, SEQ, Filename::type, and USR.

Referenced by writeLog().

{
  static char buf[sizeof(name->name) + 5];
  int i;

  if (!name)
    return 0;

  /* remove trailing shifted spaces */

  for (i = sizeof(name->name); name->name[--i] == 0xA0; );
  buf [++i] = 0;
  while (i--)
    if (name->name[i] >= 0x41 && name->name[i] <= 0x5A)
      buf[i] = name->name[i] - 0x41 + 'a';
    else if (name->name[i] >= 0xC1 && name->name[i] <= 0xDA)
      buf[i] = name->name[i] - 0xC1 + 'A';
    else if (name->name[i] >= 0x61 && name->name[i] <= 0x7A)
      buf[i] = name->name[i] - 0x61 + 'A';
    else if (name->name[i] >= 0x20 && name->name[i] <= 0x5F)
      buf[i] = name->name[i];
    else
      buf[i] = '_'; /* non-ASCII character */

  switch (name->type) {
  case DEL:
    strcat (buf, ",del");
    break;
  case SEQ:
    strcat (buf, ",seq");
    break;
  case PRG:
    strcat (buf, ",prg");
    break;
  case USR:
    strcat (buf, ",usr");
    break;
  case REL:
    sprintf (buf + strlen(buf), ",l%02X", name->recordLength);
    break;
  case CBM:
    strcat (buf, ",cbm");
    break;
  }

  return buf;
}


Generated by  Doxygen 1.6.0   Back to index