Subversion Repositories SvarDOS

Compare Revisions

Ignore whitespace Rev 537 → Rev 538

/svarcom/trunk/doserr.h
File deleted
/svarcom/trunk/doserr.c
File deleted
/svarcom/trunk/cmd/cd.c
97,7 → 97,7
}
}
if (err != 0) {
outputnl(doserr(err));
nls_outputnl_doserr(err);
return(CMD_FAIL);
}
}
/svarcom/trunk/cmd/chcp.c
106,7 → 106,7
sprintf(p->BUFFER, "Active code page: %d", nnn);
outputnl(p->BUFFER);
} else {
outputnl(doserr(errcode));
nls_outputnl_doserr(errcode);
return(CMD_FAIL);
}
}
/svarcom/trunk/cmd/copy.c
283,7 → 283,7
if (t != 0) {
output(setup->src[i]);
output(" - ");
outputnl(doserr(t));
nls_outputnl_doserr(t);
continue;
}
cursrclen = strlen(setup->cursrc); /* remember cursrc length */
347,7 → 347,7
 
t = cmd_copy_internal(setup->dst, 0, setup->cursrc, 0, appendflag, setup->databuf, setup->databufsz);
if (t != 0) {
outputnl(doserr(t));
nls_outputnl_doserr(t);
return(CMD_FAIL);
}
 
/svarcom/trunk/cmd/date.c
149,7 → 149,7
 
i = nls_getpatterns(nls);
if (i != 0) {
outputnl(doserr(i));
nls_outputnl_doserr(i);
return(CMD_FAIL);
}
 
/svarcom/trunk/cmd/del.c
97,7 → 97,7
err = findfirst(dta, buff, DOS_ATTR_RO | DOS_ATTR_SYS | DOS_ATTR_HID);
if (err != 0) { /* report the error only if query had no wildcards */
for (i = 0; buff[i] != 0; i++) if (buff[i] == '?') break;
if (buff[i] == 0) outputnl(doserr(err));
if (buff[i] == 0) nls_outputnl_doserr(err);
break;
}
} else {
133,7 → 133,7
if (err != 0) {
output(fname);
output(": ");
outputnl(doserr(err));
nls_outputnl_doserr(err);
break;
}
}
/svarcom/trunk/cmd/dir.c
154,7 → 154,7
}
 
i = nls_getpatterns(nls);
if (i != 0) outputnl(doserr(i));
if (i != 0) nls_outputnl_doserr(i);
 
/* parse command line */
for (i = 0; i < p->argc; i++) {
230,7 → 230,7
i = file_truename(filespecptr, p->BUFFER);
}
if (i != 0) {
outputnl(doserr(i));
nls_outputnl_doserr(i);
return(CMD_FAIL);
}
 
258,7 → 258,7
 
i = findfirst(dta, p->BUFFER, DOS_ATTR_RO | DOS_ATTR_HID | DOS_ATTR_SYS | DOS_ATTR_DIR | DOS_ATTR_ARC);
if (i != 0) {
outputnl(doserr(i));
nls_outputnl_doserr(i);
return(CMD_FAIL);
}
 
352,7 → 352,7
if (flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
/* xxxx bytes free */
i = cmd_dir_df(&summary_totsz, drv);
if (i != 0) outputnl(doserr(i));
if (i != 0) nls_outputnl_doserr(i);
alignpos += 13 + 13;
memset(buff2, ' ', alignpos); /* align the freebytes value to same column as totbytes */
i = nls_format_number(buff2 + alignpos, summary_totsz, nls);
/svarcom/trunk/cmd/mkdir.c
69,7 → 69,7
}
 
if (err != 0) {
outputnl(doserr(err));
nls_outputnl_doserr(err);
return(CMD_FAIL);
}
 
/svarcom/trunk/cmd/rename.c
54,7 → 54,7
/* convert src to truename format */
i = file_truename(p->argv[0], src);
if (i != 0) {
outputnl(doserr(i));
nls_outputnl_doserr(i);
return(CMD_FAIL);
}
 
83,7 → 83,7
/* apply truename to dest to normalize wildcards into ? chars */
i = file_truename(buff1, dst);
if (i != 0) {
outputnl(doserr(i));
nls_outputnl_doserr(i);
return(CMD_FAIL);
}
 
101,7 → 101,7
*/
 
i = findfirst(dta, src, 0);
if (i != 0) outputnl(doserr(i));
if (i != 0) nls_outputnl_doserr(i);
 
while (i == 0) {
/* write found fname into buff1 and dst fname into buff2 - both in FCB
153,7 → 153,7
output(" -> ");
output(buff2 + fnameoffset);
output(" ");
outputnl(doserr(i));
nls_outputnl_doserr(i);
}
/* next please */
i = findnext(dta);
/svarcom/trunk/cmd/rmdir.c
69,7 → 69,7
}
 
if (err != 0) {
outputnl(doserr(err));
nls_outputnl_doserr(err);
return(CMD_FAIL);
}
 
/svarcom/trunk/cmd/time.c
152,7 → 152,7
 
i = nls_getpatterns(nls);
if (i != 0) {
outputnl(doserr(i));
nls_outputnl_doserr(i);
return(CMD_FAIL);
}
 
/svarcom/trunk/cmd/type.c
105,7 → 105,7
}
 
if (err != 0) {
outputnl(doserr(err));
nls_outputnl_doserr(err);
return(CMD_FAIL);
}
 
/svarcom/trunk/cmd.c
33,7 → 33,6
#include <stdlib.h>
#include <string.h>
 
#include "doserr.h"
#include "env.h"
#include "helpers.h"
#include "redir.h"
231,7 → 230,7
pop ax
}
if (curdrive == drive) return(CMD_OK);
outputnl(doserr(0x0f));
nls_outputnl_doserr(0x0f);
return(CMD_FAIL);
}
}
/svarcom/trunk/command.c
31,7 → 31,6
#include <process.h>
 
#include "cmd.h"
#include "doserr.h"
#include "env.h"
#include "helpers.h"
#include "redir.h"
624,7 → 623,7
 
/* printf("blen=%u filepos_cx=%u filepos_dx=%u\r\n", blen, filepos_cx, filepos_dx); */
 
if (errv != 0) outputnl(doserr(errv));
if (errv != 0) nls_outputnl_doserr(errv);
 
/* on EOF - abort processing the bat file */
if (blen == 0) goto OOPS;
/svarcom/trunk/helpers.c
68,9 → 68,9
}
 
 
/* outputs a NULL-terminated string to stdout */
void output_internal(const char *s, unsigned char nl) {
const static unsigned char *crlf = "\r\n$";
/* outputs a NULL-terminated string to handle (1=stdout 2=stderr) */
void output_internal(const char *s, unsigned char nl, unsigned char handle) {
const static unsigned char *crlf = "\r\n";
_asm {
push ds
pop es /* make sure es=ds (scasb uses es) */
88,7 → 88,8
 
/* output by writing to stdout */
/* mov ah, 0x40 */ /* DOS 2+ -- write to file via handle */
mov bx, 1 /* handle 1 is always stdout */
xor bh, bh
mov bl, handle /* set handle (1=stdout 2=stderr) */
/* mov cx, xxx */ /* write CX bytes */
/* mov dx, s */ /* DS:DX is the source of bytes to "write" */
int 0x21
95,9 → 96,11
WRITEDONE:
 
/* print out a CR/LF trailer if nl set */
or byte ptr [nl], 0
test byte ptr [nl], 0xff
jz FINITO
mov ah, 0x09
/* bx still contains handle */
mov ah, 0x40 /* "write to file" */
mov cx, 2
mov dx, crlf
int 0x21
FINITO:
105,25 → 108,44
}
 
 
void nls_output_internal(unsigned short id, unsigned char nl) {
static const char *nlsblock_findstr(unsigned short id) {
const char *ptr = langblock + 4; /* first 4 bytes are lang id and lang len */
const char *NOTFOUND = "NLS_STRING_NOT_FOUND";
/* find the string id in langblock memory */
for (;;) {
if (((unsigned short *)ptr)[0] == id) {
ptr += 3;
break;
return(ptr);
}
if (ptr[2] == 0) {
ptr = NOTFOUND;
break;
}
if (ptr[2] == 0) return(NULL);
ptr += ptr[2] + 3;
}
output_internal(ptr, nl);
}
 
 
void nls_output_internal(unsigned short id, unsigned char nl) {
const char *NOTFOUND = "NLS_STRING_NOT_FOUND";
const char *ptr = nlsblock_findstr(id);
if (ptr == NULL) ptr = NOTFOUND;
output_internal(ptr, nl, hSTDOUT);
}
 
 
/* output DOS error e to stderr */
void nls_outputnl_doserr(unsigned short e) {
static char errstr[16];
const char *ptr = NULL;
/* find string in nls block */
if (e < 0xff) ptr = nlsblock_findstr(0xff00 | e);
/* if not found, use a fallback */
if (ptr == NULL) {
sprintf(errstr, "DOS ERR %u", e);
ptr = errstr;
}
/* display */
output_internal(ptr, 1, hSTDERR);
}
 
 
/* find first matching files using a FindFirst DOS call
* returns 0 on success or a DOS err code on failure */
unsigned short findfirst(struct DTA *dta, const char *pattern, unsigned short attr) {
/svarcom/trunk/helpers.h
34,17 → 34,23
/* returns zero if s1 starts with s2 */
int strstartswith(const char *s1, const char *s2);
 
/* outputs a NULL-terminated string to stdout */
void output_internal(const char *s, unsigned char nl);
/* outputs a NULL-terminated string to handle (hSTDOUT or hSTDERR) */
void output_internal(const char *s, unsigned char nl, unsigned char handle);
 
/* outputs a NULL-terminated NLS string to stdout */
void nls_output_internal(unsigned short id, unsigned char nl);
 
#define output(x) output_internal(x, 0)
#define outputnl(x) output_internal(x, 1)
#define hSTDOUT 1
#define hSTDERR 2
 
#define output(x) output_internal(x, 0, hSTDOUT)
#define outputnl(x) output_internal(x, 1, hSTDOUT)
#define nls_output(x,y) nls_output_internal((x << 8) | y, 0)
#define nls_outputnl(x,y) nls_output_internal((x << 8) | y, 1)
 
/* output DOS error e to stderr */
void nls_outputnl_doserr(unsigned short e);
 
/*
* FileInfoRec (DTA) format:
* offset size desc
/svarcom/trunk/history.txt
9,6 → 9,7
- DIR: fixed /P pagination in wide mode
- implemented IF command (IF EXIST, IF ERRORLEVEL, IF str==str)
- added a break handler (running application can be aborted with CTRL+C)
- Error messages are output to stderr
 
 
=== ver 2021.0 (24.11.2021) ==================================================
/svarcom/trunk/makefile
26,8 → 26,8
 
all: command.com
 
command.com: rmodcore.h command.obj cmd.obj doserr.obj env.obj redir.obj rmodinit.obj sayonara.obj helpers.obj
*wcl $(LDFLAGS) command.obj cmd.obj doserr.obj env.obj redir.obj rmodinit.obj sayonara.obj helpers.obj
command.com: rmodcore.h command.obj cmd.obj env.obj redir.obj rmodinit.obj sayonara.obj helpers.obj
*wcl $(LDFLAGS) command.obj cmd.obj env.obj redir.obj rmodinit.obj sayonara.obj helpers.obj
 
cmd.obj: cmd.c cmd\*.c
wcc $(CFLAGS) cmd.c
/svarcom/trunk/redir.c
24,7 → 24,6
 
#include <string.h> /* memset() */
 
#include "doserr.h"
#include "helpers.h"
#include "rmodinit.h"
 
148,7 → 147,7
pop ax
}
if (errcode != 0) {
outputnl(doserr(errcode));
nls_outputnl_doserr(errcode);
return(-1);
}
}
/svarcom/trunk/tlumacz/lang/english.txt
12,3 → 12,43
# SHIFT
16.0:Changes the position of arguments in a batch file:
16.1:Argument %1 becomes %0, argument %2 becomes %1, etc.
 
# DOS ERRORS
255.1:Function number invalid
255.2:File not found
255.3:Path not found
255.4:Too many open files (no handles available)
255.5:Access denied
255.6:Invalid handle
255.7:Memory control block destroyed
255.8:Insufficient memory
255.9:Memory block address invalid
255.10:Environment invalid
255.11:Format invalid
255.12:Access code invalid
255.13:Data invalid
255.15:Invalid drive
255.16:Attemted to remove current directory
255.17:Not same device
255.18:No more files
255.19:Disk write-protected
255.20:Unknown unit
255.21:Drive not ready
255.22:Unknown command
255.23:Data error (CRC)
255.24:Bad request structure length
255.25:Seek error
255.26:Unknown media type (non-DOS disk)
255.27:Sector not found
255.28:Printer out of paper
255.29:Write fault
255.30:Read fault
255.31:General failure
255.32:Sharing violation
255.33:Lock violation
255.34:Disk change invalid
255.35:FCB unavailable
255.36:Sharing buffer overflow
255.37:Code page mismatch
255.38:Cannot complete file operations (EOF / out of input)
255.39:Insufficient disk space