Subversion Repositories SvarDOS

Compare Revisions

Ignore whitespace Rev 1280 → Rev 1281

/svarlang.lib/trunk/history.txt
2,6 → 2,7
- dropped svarlang_autoload() (replaced by more specialized functions below)
- added svarlang_autoload_exepath() and svarlang_autoload_nlspath()
- svarlang_load() simplified so it takes the target filename as an argument
- file access relies on fopen() when svarlang is compiled with -DWITHSTDIO
 
20230630
- tlumacz.exe warns about empty strings (patch by Bernd Boeckmann)
/svarlang.lib/trunk/makefile
5,10 → 5,15
 
all: svarlngs.lib svarlngc.lib svarlngm.lib svarlngl.lib tlumacz.exe
 
CFLAGS=-0 -wx -we -ox
CFLAGS = -0 -wx -we -ox
 
ALLFILES=auto_exe.c auto_nls.c svarlang.c version.c
# uncomment this if you prefer that SvarLANG uses fopen() etc to handle files
# instead of direct DOS calls. this might make the final program slightly
# larger if it does not use FILE accesses already.
#CFLAGS += -DWITHSTDIO
 
ALLFILES = auto_exe.c auto_nls.c svarlang.c version.c
 
svarlngs.lib: $(ALLFILES)
wcc $(CFLAGS) -ms auto_exe.c
wcc $(CFLAGS) -ms auto_nls.c
/svarlang.lib/trunk/svarlang.c
22,7 → 22,24
* DEALINGS IN THE SOFTWARE.
*/
 
/* if WITHSTDIO is enabled, then remap file operations to use the standard
* stdio amenities */
#ifdef WITHSTDIO
 
#include <stdio.h> /* FILE, fopen(), fseek(), etc */
typedef FILE* FHANDLE;
#define FOPEN(x) fopen(x, "rb")
#define FCLOSE(x) fclose(x)
#define FSEEK(f,b) fseek(f,b,SEEK_CUR)
#define FREAD(f,t,b) fread(t, 1, b, f)
 
#else
 
#include <i86.h>
typedef unsigned short FHANDLE;
 
#endif
 
#include <stdlib.h> /* NULL */
#include <string.h> /* memcmp(), strcpy() */
 
44,11 → 61,14
}
}
 
 
/* routines below are simplified (dos-based) versions of the libc FILE-related
* functions. Using them avoids a dependency on FILE, hence makes the binary
* smaller if the application does not need to pull fopen() and friends */
#ifndef WITHSTDIO
static unsigned short FOPEN(const char *s) {
unsigned short fname_seg = FP_SEG(s);
unsigned short fname_off = FP_OFF(s);
unsigned short res = 0xffff;
unsigned short res = 0; /* fd 0 is already used by stdout so it's a good error value */
_asm {
push dx
push ds
116,7 → 136,7
}
 
 
static void FJUMP(unsigned short handle, unsigned short bytes) {
static void FSEEK(unsigned short handle, unsigned short bytes) {
_asm {
push bx
push cx
133,19 → 153,19
pop bx
}
}
#endif
 
 
int svarlang_load(const char *fname, const char *lang) {
unsigned short langid;
unsigned short fd;
char hdr[4];
unsigned short buff16[2];
FHANDLE fd;
 
langid = *((unsigned short *)lang);
langid &= 0xDFDF; /* make sure lang is upcase */
 
fd = FOPEN(fname);
if (fd == 0xffff) return(-1);
if (!fd) return(-1);
 
/* read hdr, should be "SvL\33" */
if ((FREAD(fd, hdr, 4) != 4) || (memcmp(hdr, "SvL\33", 4) != 0)) {
158,7 → 178,7
 
/* is it the lang I am looking for? */
if (buff16[0] != langid) { /* skip to next lang */
FJUMP(fd, buff16[1]);
FSEEK(fd, buff16[1]);
continue;
}
 
/svarlang.lib/trunk/svarlang.h
26,7 → 26,7
#define SVARLANG_H
 
/* library version */
#define SVARLANGVER "20230709"
#define SVARLANGVER "20230710"
 
/* returns a pointer to a string with the SvarLANG's library version,
* independently of the SVARLANGVER string above. */