mars_dosutils-0.10
This commit is contained in:
155
map.c
155
map.c
@@ -24,6 +24,7 @@ static void show_map(uint8 *drvstr)
|
||||
if ((!get_drive_info(j, &connid, &dhandle, &flags)) && flags){
|
||||
char servern[52];
|
||||
char path[256];
|
||||
servern[0]='\0';
|
||||
if (flags & 0x80) { /* lokal DRIVE */
|
||||
path[0]= '\\';
|
||||
if (j < 2){
|
||||
@@ -35,11 +36,11 @@ static void show_map(uint8 *drvstr)
|
||||
if (get_dir_path(dhandle, path)) {
|
||||
strcpy(path, "DHANDLE !OK");
|
||||
}
|
||||
if (connid) {
|
||||
get_fs_name(connid, servern);
|
||||
strcat(servern, "\\");
|
||||
} else servern[0]='\0';
|
||||
}
|
||||
if (connid) {
|
||||
get_fs_name(connid, servern);
|
||||
strcat(servern, "\\");
|
||||
} else servern[0]='\0';
|
||||
printf("MAP %c: = %s%s\n", (char)j+'A', servern, path);
|
||||
}
|
||||
}
|
||||
@@ -76,22 +77,27 @@ static void do_map(int drive, NWPATH *nwp)
|
||||
}
|
||||
#endif
|
||||
|
||||
static int do_map(int drive, NWPATH *nwp)
|
||||
static int do_map(int drive, NWPATH *nwp, int delete)
|
||||
{
|
||||
int result = -1;
|
||||
if (drive > -1 && drive < 32) {
|
||||
uint8 nmdrive[3];
|
||||
nmdrive[0] = drive+'A';
|
||||
nmdrive[1] = ':';
|
||||
nmdrive[2] = '\0';
|
||||
result = redir_device_drive(0x4, nmdrive, nwp->path);
|
||||
uint8 connid;
|
||||
uint8 dhandle;
|
||||
uint8 flags;
|
||||
if (!delete ||
|
||||
(!get_drive_info(drive, &connid, &dhandle, &flags) && flags && connid)){
|
||||
uint8 nmdrive[3];
|
||||
nmdrive[0] = drive+'A';
|
||||
nmdrive[1] = ':';
|
||||
nmdrive[2] = '\0';
|
||||
result = redir_device_drive(delete ? -1 : 0x4, nmdrive, nwp->path);
|
||||
}
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
static int parse_argv(uint8 *drvstr, NWPATH *nwpath,
|
||||
int argc, char *argv[], int smode)
|
||||
int argc, char *argv[], int smode, int argvmode)
|
||||
{
|
||||
int k = 0;
|
||||
int mode = 0;
|
||||
@@ -149,7 +155,8 @@ static int parse_argv(uint8 *drvstr, NWPATH *nwpath,
|
||||
} /* while *p */
|
||||
} /* while k */
|
||||
if (mode == 30) {
|
||||
getcwd((char *)nwpath->buff, sizeof(nwpath->buff));
|
||||
if (argvmode != 1)
|
||||
getcwd((char *)nwpath->buff, sizeof(nwpath->buff));
|
||||
mode = 40;
|
||||
}
|
||||
if (mode && mode != 20 && mode != 40) {
|
||||
@@ -159,21 +166,24 @@ static int parse_argv(uint8 *drvstr, NWPATH *nwpath,
|
||||
return(0);
|
||||
}
|
||||
|
||||
int func_map(int argc, char *argv[])
|
||||
int func_map(int argc, char *argv[], int mode)
|
||||
{
|
||||
uint8 drvstr[22];
|
||||
NWPATH nwpath;
|
||||
if (!ipx_init()) argc = 1;
|
||||
if (!parse_argv(drvstr, &nwpath, argc, argv, 0)) {
|
||||
if (*(nwpath.path)) {
|
||||
if (do_map(*drvstr - 'A', &nwpath)< 0)
|
||||
if (!parse_argv(drvstr, &nwpath, argc, argv, 0, mode)) {
|
||||
if (*(nwpath.path) || mode==1) {
|
||||
if (do_map(*drvstr - 'A', &nwpath, mode)< 0)
|
||||
fprintf(stderr, "MAP Error\n");
|
||||
}
|
||||
show_map(drvstr);
|
||||
if (mode != 1)
|
||||
show_map(drvstr);
|
||||
return(0);
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------- */
|
||||
static int show_search(uint8 *drvstr)
|
||||
{
|
||||
@@ -183,38 +193,42 @@ static int show_search(uint8 *drvstr)
|
||||
get_search_drive_vektor(drives);
|
||||
while (p->drivenummer != 0xff && j++ < 16) {
|
||||
char path[256];
|
||||
char nwname[256];
|
||||
char nwname_path[300];
|
||||
|
||||
|
||||
if ( !*drvstr || j == *(drvstr+1)) {
|
||||
if (p->flags && !(p->flags & 0x80)){
|
||||
get_fs_name(p->u.fs.connid, nwname);
|
||||
if (get_dir_path(p->u.fs.dhandle, path)) {
|
||||
strcpy(path, "ERROR NW");
|
||||
}
|
||||
(void)xadd_char(nwname, '\\', 20);
|
||||
|
||||
if (p->drivenummer == 0xfe){
|
||||
strcpy(path, p->dospath);
|
||||
} else {
|
||||
nwname[0] = '\0';
|
||||
/*
|
||||
nwname[0] = '<';
|
||||
strcpy(nwname+1, "LOCAL");
|
||||
*/
|
||||
if (p->drivenummer == 0xfe){
|
||||
strcpy(path, p->u.d.dospath);
|
||||
} else if (getcurdir((int)(p->drivenummer)+1, path)) {
|
||||
strcpy(path, "ERROR DOS");
|
||||
}
|
||||
/*
|
||||
(void)xadd_char(nwname, '>', 20);
|
||||
*/
|
||||
*path = p->drivenummer+'A';
|
||||
*(path+1) = ':';
|
||||
strcpy(path+2, p->dospath);
|
||||
}
|
||||
strcat(nwname, path);
|
||||
printf("SEARCH%2d = %c: %s\n", j, (char)(p->drivenummer)+'A', nwname);
|
||||
|
||||
if (p->flags && !(p->flags & 0x80)){
|
||||
char *pp=nwname_path;
|
||||
*pp++ = '[';
|
||||
get_fs_name(p->connid, pp);
|
||||
pp +=strlen(pp);
|
||||
*pp++='\\';
|
||||
if (get_dir_path(p->dhandle, pp)) {
|
||||
strcpy(pp, "ERROR NW");
|
||||
}
|
||||
pp += strlen(pp);
|
||||
*pp ++= ']';
|
||||
*pp = '\0';
|
||||
} else {
|
||||
*nwname_path = '\0';
|
||||
}
|
||||
printf("SEARCH%2d = %s %s\n", j, path, nwname_path);
|
||||
}
|
||||
p++;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int set_search(uint8 *drvstr, NWPATH *nwp)
|
||||
static int set_search(uint8 *drvstr, NWPATH *nwp, int pathmode)
|
||||
{
|
||||
int result=-1;
|
||||
SEARCH_VECTOR drives;
|
||||
@@ -222,31 +236,78 @@ static int set_search(uint8 *drvstr, NWPATH *nwp)
|
||||
int j=0;
|
||||
int entry = (*drvstr=='s') ? *(drvstr+1) : 0;
|
||||
get_search_drive_vektor(drives);
|
||||
|
||||
while (p->drivenummer != 0xff && j++ < 16) {
|
||||
if (!entry && (p->drivenummer + 'A' == *drvstr)) entry=j;
|
||||
if (p->drivenummer + 'A' == nwp->path[0] && nwp->path[1] == ':'
|
||||
&& !strcmp(nwp->path+2, p->dospath)) {
|
||||
p->drivenummer=0xfe;
|
||||
*(p->dospath) = '\0';
|
||||
}
|
||||
p++;
|
||||
}
|
||||
|
||||
if (entry > 0) {
|
||||
if (entry > 16) entry = 16;
|
||||
if (--entry < j) p = drives+entry;
|
||||
if (pathmode == 2 && entry <= j && entry < 16) { /* insert modus */
|
||||
int k=j+1-entry;
|
||||
if (j < 16) {
|
||||
p++;
|
||||
k++;
|
||||
j++;
|
||||
}
|
||||
while (k--) {
|
||||
memcpy(p, p-1, sizeof(SEARCH_VECTOR_ENTRY));
|
||||
--p;
|
||||
}
|
||||
}
|
||||
if (--entry < j)
|
||||
p = drives+entry;
|
||||
else (p+1)->drivenummer = 0xff;
|
||||
p->flags = 0;
|
||||
p->drivenummer = 0xfe;
|
||||
strcpy(p->u.d.dospath, nwp->path);
|
||||
if (pathmode==1)
|
||||
*(p->dospath) = '\0';
|
||||
else
|
||||
strcpy(p->dospath, nwp->path);
|
||||
result = set_search_drive_vektor(drives);
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
int func_path(int argc, char *argv[])
|
||||
int func_path(int argc, char *argv[], int mode)
|
||||
{
|
||||
uint8 drvstr[22];
|
||||
NWPATH nwpath;
|
||||
if (!parse_argv(drvstr, &nwpath, argc, argv, 1)) {
|
||||
if (!parse_argv(drvstr, &nwpath, argc, argv, 1, mode)) {
|
||||
int result=0;
|
||||
if (*(nwpath.path)) result=set_search(drvstr, &nwpath);
|
||||
show_search(drvstr);
|
||||
if (*(nwpath.path) || mode==1)
|
||||
result=set_search(drvstr, &nwpath, mode);
|
||||
if (mode != 1)
|
||||
show_search(drvstr);
|
||||
return(result);
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
void remove_nwpathes(void)
|
||||
{
|
||||
SEARCH_VECTOR drives;
|
||||
SEARCH_VECTOR_ENTRY *p=drives;
|
||||
int j=0;
|
||||
get_search_drive_vektor(drives);
|
||||
while (p->drivenummer != 0xff && j++ < 16) {
|
||||
if (p->flags && !(p->flags & 0x80)){
|
||||
p->flags=0;
|
||||
p->drivenummer=0xfe;
|
||||
*(p->dospath) ='\0';
|
||||
}
|
||||
++p;
|
||||
}
|
||||
set_search_drive_vektor(drives);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user