2019-06-15 20:22:01 +00:00
|
|
|
#include <stdio.h>
|
2019-06-16 22:41:49 +00:00
|
|
|
#include <stdlib.h>
|
2019-06-15 20:22:01 +00:00
|
|
|
#include <cpm.h>
|
2019-06-16 17:04:17 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include "cpmsys.h"
|
|
|
|
|
2019-06-16 22:41:49 +00:00
|
|
|
static const char* fill(uint8_t* dest, const char* src, int len)
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
char c = toupper(*src);
|
|
|
|
if (!c || (c == '.'))
|
|
|
|
c = ' ';
|
|
|
|
else if (c == '*')
|
|
|
|
c = '?';
|
|
|
|
else
|
|
|
|
src++;
|
|
|
|
*dest++ = c;
|
|
|
|
}
|
|
|
|
while (--len);
|
|
|
|
return src;
|
|
|
|
}
|
|
|
|
|
2019-06-16 17:04:17 +00:00
|
|
|
uint8_t cpm_parse_filename(FCB* fcb, const char* filename)
|
|
|
|
{
|
|
|
|
uint8_t user = cpm_get_user();
|
2019-06-16 22:41:49 +00:00
|
|
|
char c;
|
2019-06-16 17:04:17 +00:00
|
|
|
|
|
|
|
memset(fcb, 0, sizeof(FCB));
|
|
|
|
memset(fcb->f, ' ', sizeof(fcb->f));
|
|
|
|
|
|
|
|
{
|
2019-06-16 22:41:49 +00:00
|
|
|
const char* colon = strchr(filename, ':');
|
|
|
|
if (colon)
|
2019-06-16 17:04:17 +00:00
|
|
|
{
|
|
|
|
c = *filename++;
|
|
|
|
if (isdigit(c))
|
|
|
|
{
|
2019-06-16 22:41:49 +00:00
|
|
|
user = strtol(filename-1, &filename, 10);
|
|
|
|
c = *filename++;
|
|
|
|
}
|
|
|
|
c = toupper(c);
|
|
|
|
if (isalpha(c))
|
|
|
|
{
|
|
|
|
fcb->dr = c - '@';
|
2019-06-16 17:04:17 +00:00
|
|
|
c = *filename++;
|
|
|
|
}
|
|
|
|
|
2019-06-16 22:41:49 +00:00
|
|
|
filename = colon + 1;
|
2019-06-16 17:04:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-16 22:41:49 +00:00
|
|
|
/* Read filename part. */
|
2019-06-16 17:04:17 +00:00
|
|
|
|
2019-06-16 22:41:49 +00:00
|
|
|
filename = fill(&fcb->f[0], filename, 8);
|
|
|
|
filename = strchr(filename, '.');
|
|
|
|
if (filename)
|
|
|
|
fill(&fcb->f[8], filename+1, 3);
|
2019-06-16 17:04:17 +00:00
|
|
|
|
|
|
|
if (fcb->dr == 0)
|
|
|
|
fcb->dr = cpm_get_current_drive() + 1;
|
|
|
|
return user;
|
|
|
|
}
|
2019-06-15 20:22:01 +00:00
|
|
|
|