Subversion Repositories SvarDOS

Compare Revisions

No changes between revisions

Ignore whitespace Rev 613 → Rev 612

/pkg/svarlang.lib
File deleted
\ No newline at end of file
Property changes:
Deleted: svn:special
-*
\ No newline at end of property
/pkg/Makefile
5,7 → 5,7
 
CFLAGS = -0 -mc -os -wx -we -d0 -i=zlib
LDFLAGS = -lr -fe=pkg.exe
LIBS = zlib\zlib_c.lib svarlang.lib\svarlngc.lib
LIBS = zlib\zlib_c.lib
 
all: pkg.exe
 
13,32 → 13,25
mkdir appinfo
mkdir bin
mkdir nls
copy pkg.lng nls
copy nls_utf8\pkg_en.txt nls\pkg.en
utf8tocp 850 nls_utf8\pkg_de.txt > nls\pkg.de
utf8tocp 850 nls_utf8\pkg_fr.txt > nls\pkg.fr
utf8tocp 850 nls_utf8\pkg_dk.txt > nls\pkg.dk
utf8tocp 852 nls_utf8\pkg_si.txt > nls\pkg.si
utf8tocp 857 nls_utf8\pkg_tr.txt > nls\pkg.tr
utf8tocp maz nls_utf8\pkg_pl.txt > nls\pkg.pl
upx --8086 -9 pkg.exe -o bin\pkg.exe
copy pkg.lsm appinfo
zip -9moDkrX pkg.zip appinfo bin nls
zip -9moDkr pkg.zip appinfo bin nls
rmdir appinfo
rmdir bin
rmdir nls
 
pkg.exe: main.obj crc32.obj fileexst.obj helpers.obj inf.obj kprintf.obj libunzip.obj loadconf.obj lsm.obj pkginst.obj pkgrem.obj trim.obj showinst.obj unzip.obj deflang.obj
pkg.exe: kitten.obj main.obj crc32.obj fileexst.obj helpers.obj inf.obj kprintf.obj libunzip.obj loadconf.obj lsm.obj pkginst.obj pkgrem.obj trim.obj showinst.obj unzip.obj
wcl $(LDFLAGS) $(LIBS) *.obj
 
deflang.obj: nls_utf8\pkg_en.txt
cd nls_utf8
copy pkg_en.txt en.txt
utf8tocp 850 pkg_de.txt > de.txt
utf8tocp 850 pkg_fr.txt > fr.txt
utf8tocp 850 pkg_dk.txt > dk.txt
utf8tocp 852 pkg_si.txt > si.txt
utf8tocp 857 pkg_tr.txt > tr.txt
utf8tocp maz pkg_pl.txt > pl.txt
..\svarlang.lib\tlumacz en de fr dk si tr pl
move out.lng ..\pkg.lng
move deflang.c ..
del ??.txt
cd ..
wcc $(CFLAGS) deflang.c
kitten.obj: kitten\kitten.c
wcc $(CFLAGS) kitten\kitten.c
 
main.obj: main.c
wcc $(CFLAGS) main.c
/pkg/kitten/kitten.c
0,0 → 1,698
/* Functions that emulate UNIX catgets */
 
/* Copyright (C) 1999,2000,2001 Jim Hall <jhall@freedos.org> */
/* Kitten version 2003 by Tom Ehlert, heavily modified by Eric Auer 2003 */
 
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
 
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
 
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
 
#ifndef NO_KITTEN
 
#include <stdio.h> /* sprintf */
#ifndef _MICROC_
#include <stdlib.h> /* getenv */
#include <string.h> /* strchr */
#include <dos.h>
#ifndef __PACIFIC__
#include <fcntl.h>
#else
#define O_RDONLY 0
#define O_TEXT 0
#endif
#else
#include <intr.h>
#include <file.h>
#define O_RDONLY READONLY
#define O_TEXT 0
#endif
/* assert we are running in small model */
/* else pointer below has to be done correctly */
/* char verify_small_pointers[sizeof(void*) == 2 ? 1 : -1]; */
 
#include "kitten.h"
 
char catcontents[8192];
 
struct catstring
{
char key1;
char key2;
char *text;
};
 
/* Micro-C does not support typedef */
#define catstring_t struct catstring
 
catstring_t catpoints[128];
 
 
/* Local prototypes */
 
int catread (char *catfile); /* Reads a catfile into the hash */
char *processEscChars (char *line); /* Converts c escape sequences to chars */
 
int get_char (int file); /* not meant for external use */
/* external use would cause consistency problems if */
/* value or related file of the file handle changes */
 
int mystrtoul (char *src, int base, int size);
 
 
/* Globals */
 
nl_catd _kitten_catalog = 0; /* _kitten_catalog descriptor or 0 */
char catfile[128]; /* full path to _kitten_catalog */
 
char getlbuf[8192]; /* read buffer for better speed */
char *getlp; /* current point in buffer */
int getlrem = -1; /* remaining bytes in buffer */
char lastcr = 0; /* for 2byte CR LF sequences */
 
 
#ifndef _MICROC_
#ifndef __DJGPP__
 
/* DOS handle based file usage */
 
int
dos_open (char *filename, int mode)
{
union REGS r;
struct SREGS s;
#ifndef __WATCOMC__
if (mode); /* mode ignored - readonly supported */
#endif
r.h.ah = 0x3d;
r.h.al = 0; /* read mode only supoported now !! */
r.x.dx = FP_OFF (filename);
s.ds = FP_SEG (filename);
intdosx (&r, &r, &s);
return ((r.x.cflag) ? -1 : (int) r.x.ax);
}
 
 
int
dos_read (int file, void *ptr, unsigned count)
{
union REGS r;
struct SREGS s;
r.h.ah = 0x3f;
r.x.bx = file;
r.x.cx = count;
r.x.dx = FP_OFF (ptr);
s.ds = FP_SEG (ptr);
intdosx (&r, &r, &s);
return ((r.x.cflag) ? 0 : r.x.ax);
}
 
 
int
dos_write (int file, void *ptr, unsigned count)
{
union REGS r;
struct SREGS s;
r.h.ah = 0x40;
r.x.bx = file;
r.x.cx = count;
r.x.dx = FP_OFF (ptr);
s.ds = FP_SEG (ptr);
intdosx (&r, &r, &s);
return ((r.x.cflag) ? 0 : r.x.ax);
}
 
 
void
dos_close (int file)
{
union REGS r;
r.h.ah = 0x3e;
r.x.bx = file;
intdos (&r, &r);
}
 
#endif /*DJGPP*/
#endif /*Micro-C */
/* Functions */
/**
* On success, catgets() returns a pointer to an internal
* buffer area containing the null-terminated message string.
* On failure, catgets() returns the value 'message'.
*/
char *
kittengets (int setnum, int msgnum, char *message)
{
/* In Micro-C, variables must be defined at the start of the
* function and may not be immediately assigned a value
*/
#ifdef _MICROC_
int i;
i = 0;
#else
int i = 0;
#endif
 
while ((catpoints[i].key1 != setnum) || (catpoints[i].key2 != msgnum))
{
if ((catpoints[i].text == NULL) || (i > 127)) /* at EOF */
return message;
i++;
}
 
if (catpoints[i].text == NULL)
return message;
else
return (catpoints[i].text);
}
 
 
/**
* Initialize kitten for program (name).
*/
 
nl_catd
kittenopen (char *name)
{
/* catopen() returns a message _kitten_catalog descriptor *
* of type nl_catd on success. On failure, it returns -1. */
 
char catlang[3]; /* from LANG environment var. */
char *nlsptr; /* ptr to NLSPATH */
char *lang; /* ptr to LANG */
int i;
#ifdef _MICROC_
char *tok;
int toklen;
#endif
 
/* Open the _kitten_catalog file */
/* The value of `_kitten_catalog' will be set based on catread */
 
if (_kitten_catalog)
{ /* Already one open */
write (1, "cat already open\r\n", strlen ("cat already open\r\n"));
return (-1);
}
 
for (i = 0; i < 128; i++)
catpoints[i].text = NULL;
 
if (strchr (name, '\\'))
{
/* unusual case: 'name' is a filename */
write (1, "found \\\r\n", 9);
_kitten_catalog = catread (name);
if (_kitten_catalog)
return (_kitten_catalog);
}
 
/* If the message _kitten_catalog file name does not contain a directory *
* separator, then we need to try to locate the message _kitten_catalog. */
 
/* We will need the value of LANG, and may need a 2-letter abbrev of
LANG later on, so get it now. */
 
lang = getenv ("LANG");
 
if (lang == NULL)
{
/* printf("no lang= found\n"); *//* not fatal, though */
/* Return failure - we won't be able to locate the cat file */
return (-1);
}
 
if ((strlen (lang) < 2) || ((strlen (lang) > 2) && (lang[2] != '-')))
{
/* Return failure - we won't be able to locate the cat file */
return (-1);
}
 
memcpy (catlang, lang, 2);
/* we copy the full LANG value or the part before "-" if "-" found */
catlang[2] = '\0';
 
/* step through NLSPATH */
 
nlsptr = getenv ("NLSPATH");
 
if (nlsptr == NULL)
{
/* printf("no NLSPATH= found\n"); *//* not fatal either */
/* Return failure - we won't be able to locate the cat file */
return (-1);
}
 
catfile[0] = '\0';
 
while (nlsptr && nlsptr[0])
{
#ifdef _MICROC_
tok = strchr (nlsptr, ';');
#else
char *tok = strchr (nlsptr, ';');
int toklen;
#endif
 
if (tok == NULL)
toklen = strlen (nlsptr); /* last segment */
else
toklen = tok - nlsptr; /* segment terminated by ';' */
 
/* catfile = malloc(toklen+1+strlen(name)+1+strlen(lang)+1); */
/* Try to find the _kitten_catalog file in each path from NLSPATH */
 
if ((toklen + 6 + strlen (name)) > sizeof (catfile))
{
write (1, "NLSPATH overflow\r\n", strlen ("NLSPATH overflow\r\n"));
return 0; /* overflow in NLSPATH, should never happen */
}
 
/* Rule #1: %NLSPATH%\%LANG%\cat */
 
memcpy (catfile, nlsptr, toklen);
strcpy (catfile + toklen, "\\");
strcat (catfile, catlang);
strcat (catfile, "\\");
strcat (catfile, name);
_kitten_catalog = catread (catfile);
if (_kitten_catalog)
return (_kitten_catalog);
 
/* Rule #2: %NLSPATH%\cat.%LANG% */
 
/* memcpy(catfile, nlsptr, toklen); */
strcpy (catfile + toklen, "\\");
strcat (catfile, name);
strcat (catfile, ".");
strcat (catfile, catlang);
_kitten_catalog = catread (catfile);
if (_kitten_catalog)
return (_kitten_catalog);
 
/* Grab next tok for the next while iteration */
 
nlsptr = tok;
if (nlsptr)
nlsptr++;
 
} /* while tok */
 
/* We could not find it. Return failure. */
 
return (-1);
}
 
 
/**
* Load a message catalog into memory.
*/
 
int
catread (char *catfile)
{
int file; /* pointer to the catfile */
int i;
char *where;
char *tok;
#ifdef _MICROC_
char *msg;
char *key;
int key1;
int key2;
#endif
 
/* Get the whole catfile into a buffer and parse it */
 
file = open (catfile, O_RDONLY | O_TEXT);
if (file < 0)
/* Cannot open the file. Return failure */
return 0;
 
for (i = 0; i < 128; i++)
catpoints[i].text = NULL;
 
for (i = 0; (unsigned int) i < sizeof (catcontents); i++)
catcontents[i] = '\0';
 
/* Read the file into memory */
i = read (file, catcontents, sizeof (catcontents) - 1);
 
if ((i == sizeof (catcontents) - 1) || (i < 1))
return 0; /* file was too big or too small */
 
where = catcontents;
i = 0; /* catpoints entry */
 
do
{
#ifndef _MICROC_
char *msg;
char *key;
int key1 = 0;
int key2 = 0;
#else
key1 = 0;
key2 = 0;
#endif
 
tok = strchr (where, '\n');
 
if (tok == NULL)
{ /* done? */
close (file);
return 1; /* success */
}
 
tok[0] = '\0'; /* terminate here */
tok--; /* guess: \r before \n */
if (tok[0] != '\r')
tok++; /* if not, go back */
else
{
tok[0] = '\0'; /* terminate here already */
tok++;
}
tok++; /* this is where the next line starts */
 
if ((where[0] >= '0') && (where[0] <= '9') &&
((msg = strchr (where, ':')) != NULL))
{
/* Skip everything which starts with # or with no digit */
/* Entries look like "1.2:This is a message" */
 
msg[0] = '\0'; /* remove : */
msg++; /* go past the : */
 
if ((key = strchr (where, '.')) != NULL)
{
key[0] = '\0'; /* turn . into terminator */
key++; /* go past the . */
key1 = mystrtoul (where, 10, strlen (where));
key2 = mystrtoul (key, 10, strlen (key));
 
if ((key1 >= 0) && (key2 >= 0))
{
catpoints[i].key1 = key1;
catpoints[i].key2 = key2;
catpoints[i].text = processEscChars (msg);
if (catpoints[i].text == NULL) /* ESC parse error */
catpoints[i].text = msg;
i++; /* next entry! */
} /* valid keys */
 
} /* . found */
 
} /* : and digit found */
 
where = tok; /* go to next line */
 
}
while (1);
#ifdef __PACIFIC__
return 0;
#endif
}
 
 
void
kittenclose (void)
{
/* close a message _kitten_catalog */
_kitten_catalog = 0;
}
 
 
/**
* Parse a string that represents an unsigned integer.
* Returns -1 if an error is found. The first size
* chars of the string are parsed.
*/
 
int
mystrtoul (char *src, int base, int size)
{
#ifdef _MICROC_
int ret;
int digit;
int ch;
ret = 0;
#else
int ret = 0;
#endif
 
for (; size > 0; size--)
{
#ifdef _MICROC_
ch = *src;
#else
int digit;
int ch = *src;
#endif
src++;
 
if (ch >= '0' && ch <= '9')
digit = ch - '0';
else if (ch >= 'A' && ch <= 'Z')
digit = ch - 'A' + 10;
else if (ch >= 'a' && ch <= 'z')
digit = ch - 'a' + 10;
else
return -1;
 
if (digit >= base)
return -1;
 
ret = ret * base + digit;
} /* for */
 
return ret;
}
 
 
/**
* Process strings, converting \n, \t, \v, \b, \r, \f, \\,
* \ddd, \xdd and \x0dd to actual chars.
* (Note: \x is an extension to support hexadecimal)
* This is used to allow the messages to use c escape sequences.
* Modifies the line in-place (always same size or shorter).
* Returns a pointer to input string.
*/
 
char *
processEscChars (char *line)
{
/* used when converting \xdd and \ddd (hex or octal) characters */
char ch;
#ifdef _MICROC_
char *src;
char *dst;
int chx;
src = line;
dst = line;
#else
char *src = line;
char *dst = line; /* possible as dst is shorter than src */
#endif
 
if (line == NULL)
return line;
 
/* cycle through copying characters, except when a \ is encountered. */
while (*src != '\0')
{
ch = *src;
src++;
 
if (ch == '\\')
{
ch = *src; /* what follows slash? */
src++;
 
switch (ch)
{
case '\\': /* a single slash */
*dst = '\\';
dst++;
break;
case 'n': /* a newline (linefeed) */
*dst = '\n';
dst++;
break;
case 'r': /* a carriage return */
*dst = '\r';
dst++;
break;
case 't': /* a horizontal tab */
*dst = '\t';
dst++;
break;
case 'v': /* a vertical tab */
*dst = '\v';
dst++;
break;
case 'b': /* a backspace */
*dst = '\b';
dst++;
break;
case 'a': /* alert */
*dst = '\a';
dst++;
break;
case 'f': /* formfeed */
*dst = '\f';
dst++;
break;
case 'x': /* extension supporting hex numbers \xdd or \x0dd */
{
#ifdef _MICROC_
chx = mystrtoul (src, 16, 2); /* get value */
#else
int chx = mystrtoul (src, 16, 2); /* get value */
#endif
if (chx >= 0)
{ /* store character */
*dst = chx;
dst++;
src += 2;
}
else /* error so just store x (loose slash) */
{
*dst = *src;
dst++;
}
}
break;
default: /* just store letter (loose slash) or handle octal */
{
#ifdef _MICROC_
chx = mystrtoul (src, 8, 3); /* get value */
#else
int chx = mystrtoul (src, 8, 3); /* get value */
#endif
if (chx >= 0)
{ /* store character */
*dst = chx;
dst++;
src += 3;
}
else
{
*dst = *src;
dst++;
}
}
break;
} /* switch */
} /* if backslash */
else
{
*dst = ch;
dst++;
}
} /* while */
 
/* ensure '\0' terminated */
*dst = '\0';
 
return line;
}
 
 
int
get_char (int file)
{
#ifdef _MICROC_
int rval;
rval = -1;
#else
int rval = -1;
#endif
 
if (getlrem <= 0)
{ /* (re)init buffer */
getlrem = read (file, getlbuf, sizeof (getlbuf));
if (getlrem <= 0)
return -1; /* fail: read error / EOF */
getlp = getlbuf; /* init pointer */
}
 
if (getlrem > 0)
{ /* consume byte from buffer */
rval = getlp[0];
getlp++;
getlrem--;
}
 
return rval;
}
 
 
/**
* Read a line of text from file. You must call this with
* a null buffer or null size to flush buffers when you are
* done with a file before using it on the next file. Cannot
* be used for 2 files at the same time.
*/
 
int
get_line (int file, char *str, int size)
{
int ch;
#ifdef _MICROC_
int success;
success = 0;
#else
int success = 0;
#endif
 
if ((size == 0) || (str == NULL))
{ /* re-init get_line buffers */
getlp = getlbuf;
getlrem = -1;
lastcr = 0;
return 0;
}
 
str[0] = '\0';
 
while ((size > 0) && (success == 0))
{
ch = get_char (file);
if (ch < 0)
break; /* (can cause fail if no \n found yet) */
 
if (ch == '\r')
ch = get_char (file); /* ignore \r */
 
str[0] = ch;
 
if ((ch == '\n') || (ch == '\r'))
{ /* done? */
str[0] = '\0';
return 1; /* success */
}
 
str++;
size--;
 
} /* while */
 
str[0] = '\0'; /* terminate buffer */
 
return success;
 
}
 
#endif /*NO_KITTEN */
/pkg/kitten/kitten.h
0,0 → 1,78
/* Functions that emulate UNIX catgets, some small DOS file functions */
 
/* Copyright (C) 1999,2000 Jim Hall <jhall@freedos.org> */
/* Kitten version by Tom Ehlert, heavily modified by Eric Auer 2003 */
 
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
 
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
 
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
 
 
#ifndef _CATGETS_H
#define _CATGETS_H
 
#ifdef __cplusplus
extern "C"
{
#endif
 
#ifdef NO_KITTEN
 
#define kittengets(x,y,z) (z)
#define kittenclose()
#define kittenopen(a)
 
#else
 
/* Data types */
 
#define nl_catd int
 
/* Functions */
 
#define catgets(catalog, set,message_number,message) kittengets(set,message_number,message)
#define catopen(name,flag) kittenopen(name)
#define catclose(catalog) kittenclose()
 
 
char *kittengets (int set_number, int message_number, char *message);
nl_catd kittenopen (char *name);
void kittenclose (void);
 
int get_line (int file, char *buffer, int size);
 
#ifndef _MICROC_
#ifndef __DJGPP__
 
int dos_open (char *filename, int mode);
#define open(filename,mode) dos_open(filename,mode)
 
int dos_read (int file, void *ptr, unsigned count);
#define read(file, ptr, count) dos_read(file,ptr,count)
 
int dos_write (int file, void *ptr, unsigned count);
#define write(file, ptr, count) dos_write(file,ptr,count)
 
void dos_close (int file);
#define close(file) dos_close(file)
 
#endif /*DJGPP*/
#endif /*Micro-C */
#endif /*NO_KITTEN */
#ifdef __cplusplus
}
#endif
 
#endif /* _CATGETS_H */
/pkg/kprintf.c
2,19 → 2,23
* This file provides dummy functions that simulate kitten-enabled routines
* without actually having kitten.
*
* Copyright (C) 2015-2022 Mateusz Viste
* Copyright (C) 2015-2021 Mateusz Viste
*/
 
#include <stdio.h> /* vprintf() */
#include <stdarg.h> /* va_list, va_start()... */
 
#include "svarlang.lib\svarlang.h"
#include "kitten/kitten.h"
 
#include "kprintf.h"
 
void kitten_printf(short x, short y, ...) {
void kitten_printf(short x, short y, char *fmt, ...) {
va_list args;
va_start(args, y);
vprintf(svarlang_str(x, y), args);
va_start(args, fmt);
vprintf(kittengets(x, y, fmt), args);
va_end(args);
}
 
void kitten_puts(short x, short y, char *fmt) {
puts(kittengets(x, y, fmt));
}
/pkg/kprintf.h
6,6 → 6,7
#ifndef kprintf_sentinel
#define kprintf_sentinel
 
void kitten_printf(short x, short y, ...);
void kitten_printf(short x, short y, char *fmt, ...);
void kitten_puts(short x, short y, char *fmt);
 
#endif
/pkg/libunzip.c
88,7 → 88,7
/* create new entry and link it into the list */
newentry = calloc(sizeof(struct ziplist) + filenamelen, 1);
if (newentry == NULL) {
kitten_printf(2, 14, "libunzip"); /* "Out of memory! (%s)" */
kitten_printf(2, 14, "Out of memory! (%s)", "libunzip");
puts("");
zip_freelist(&reslist);
break;
149,7 → 149,7
/* no need to read the header we just have to skip it */
fseek(fd, 12, SEEK_CUR); /* the header is 3x4 bytes (CRC + compressed len + uncompressed len) */
} else { /* unknown sig */
kitten_printf(8, 1, entrysig); /* "unknown zip sig: 0x%08lx" */
kitten_printf(8, 1, "unknown zip sig: 0x%08lx", entrysig);
puts("");
zip_freelist(&reslist);
break;
/pkg/loadconf.c
29,7 → 29,7
for (; dirlist != NULL; dirlist = dirlist->next) {
for (curpos = dirlist->next; curpos != NULL; curpos = curpos->next) {
if (strcasecmp(curpos->name, dirlist->name) == 0) {
kitten_printf(7, 0, curpos->name); /* "ERROR: custom dir '%s' is listed twice!" */
kitten_printf(7, 0, "ERROR: custom dir '%s' is listed twice!", curpos->name);
puts("");
return(-1);
}
44,7 → 44,7
for (; dirlist != NULL; dirlist = dirlist->next) {
/* the location must be at least 3 characters long to be a valid absolute path (like 'c:\')*/
if (strlen(dirlist->location) < 3) {
kitten_printf(7, 15, dirlist->name); /* "ERROR: custom dir '%s' is not a valid absolute path!" */
kitten_printf(7, 15, "ERROR: custom dir '%s' is not a valid absolute path!", dirlist->name);
puts("");
return(-1);
}
52,7 → 52,7
if ((dirlist->location[1] != ':') ||
((dirlist->location[2] != '/') && (dirlist->location[2] != '\\')) ||
(((dirlist->location[0] < 'a') || (dirlist->location[0] > 'z')) && ((dirlist->location[0] < 'A') || (dirlist->location[0] > 'Z')))) {
kitten_printf(7, 15, dirlist->name); /* "ERROR: custom dir '%s' is not a valid absolute path!" */
kitten_printf(7, 15, "ERROR: custom dir '%s' is not a valid absolute path!", dirlist->name);
puts("");
return(-1);
}
63,7 → 63,7
(strcasecmp(dirlist->name, "help") == 0) ||
(strcasecmp(dirlist->name, "nls") == 0) ||
(strcasecmp(dirlist->name, "packages") == 0)) {
kitten_printf(7, 16, dirlist->name); /* "ERROR: custom dir '%s' is a reserved name!" */
kitten_printf(7, 16, "ERROR: custom dir '%s' is a reserved name!", dirlist->name);
puts("");
return(-1);
}
96,7 → 96,7
snprintf(token, sizeof(token), "%s\\cfg\\pkg.cfg", dosdir);
fd = fopen(token, "r");
if (fd == NULL) {
kitten_printf(7, 1, token); /* "ERROR: Could not open config file (%s)!" */
kitten_printf(7, 1, "ERROR: Could not open config file (%s)!", token);
puts("");
return(-1);
}
111,7 → 111,7
if ((token[0] == '#') || (token[0] == 0)) continue;
 
if ((value == NULL) || (value[0] == 0)) {
kitten_printf(7, 4, nline); /* "Warning: token with empty value on line #%d" */
kitten_printf(7, 4, "Warning: token with empty value on line #%d", nline);
puts("");
continue;
}
123,7 → 123,7
/* find nearer space */
for (i = 0; (value[i] != ' ') && (value[i] != 0); i++);
if (value[i] == 0) {
kitten_printf(7, 11, nline); /* "Warning: Invalid 'DIR' directive found at line #%d" */
kitten_printf(7, 11, "Warning: Invalid 'DIR' directive found at line #%d", nline);
puts("");
continue;
}
135,7 → 135,7
removeDoubleBackslashes(location);
if (location[strlen(location) - 1] != '\\') strcat(location, "\\"); /* make sure to end dirs with a backslash */
if (addnewdir(dirlist, value, location) != 0) {
kitten_printf(2, 14, "addnewdir"); /* "Out of memory! (%s)" */
kitten_printf(2, 14, "Out of memory! (%s)", "addnewdir");
puts("");
freeconf(dirlist);
fclose(fd);
142,7 → 142,7
return(-1);
}
} else { /* unknown token */
kitten_printf(7, 8, token, nline); /* "Warning: Unknown token '%s' at line #%d" */
kitten_printf(7, 8, "Warning: Unknown token '%s' at line #%d", token, nline);
puts("");
}
}
/pkg/main.c
3,7 → 3,7
*
* PUBLISHED UNDER THE TERMS OF THE MIT LICENSE
*
* COPYRIGHT (C) 2016-2022 MATEUSZ VISTE, ALL RIGHTS RESERVED.
* COPYRIGHT (C) 2016-2021 MATEUSZ VISTE, ALL RIGHTS RESERVED.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
29,7 → 29,7
#include <stdlib.h> /* malloc() and friends */
#include <string.h> /* strcasecmp() */
 
#include "svarlang.lib/svarlang.h"
#include "kitten/kitten.h"
#include "kprintf.h"
#include "libunzip.h"
#include "pkginst.h"
53,17 → 53,17
static int showhelp(void) {
puts("PKG ver " PVER " Copyright (C) " PDATE " Mateusz Viste");
puts("");
puts(svarlang_str(1, 0)); /* "PKG is the package installer for SvarDOS." */
kitten_puts(1, 0, "PKG is the package installer for SvarDOS.");
puts("");
puts(svarlang_str(1, 20)); /* "Usage: pkg install package.zip */
puts(svarlang_str(1, 21)); /* " pkg update package.zip" */
puts(svarlang_str(1, 22)); /* " pkg remove package" */
puts(svarlang_str(1, 23)); /* " pkg listfiles package" */
puts(svarlang_str(1, 24)); /* " pkg listlocal [filter]" */
puts(svarlang_str(1, 27)); /* " pkg unzip file.zip" */
kitten_puts(1, 20, "Usage: pkg install package.zip");
kitten_puts(1, 21, " pkg update package.zip");
kitten_puts(1, 22, " pkg remove package");
kitten_puts(1, 23, " pkg listfiles package");
kitten_puts(1, 24, " pkg listlocal [filter]");
kitten_puts(1, 27, " pkg unzip file.zip");
puts("");
puts(svarlang_str(1, 25)); /* "PKG is published under the MIT license." */
puts(svarlang_str(1, 26)); /* "It is configured through %DOSDIR%\CFG\PKG.CFG" */
kitten_puts(1, 25, "PKG is published under the MIT license.");
kitten_puts(1, 26, "It is configured through %DOSDIR%\\CFG\\PKG.CFG");
return(1);
}
 
108,7 → 108,7
if (lastdot <= lastpathdelim) lastdot = t; /* a dot before last path delimiters is not an extension prefix */
t = lastdot - (lastpathdelim + 1);
if (t + 1 > sizeof(pkgname)) {
puts(svarlang_str(3, 24)); /* "ERROR: package name too long" */
kitten_puts(3, 24, "ERROR: package name too long");
return(1);
}
memcpy(pkgname, file + lastpathdelim + 1, t);
131,7 → 131,7
const char *dosdir;
struct customdirs *dirlist;
 
svarlang_autoload("pkg"); /* NLS init */
kittenopen("pkg"); /* NLS init */
 
action = parsearg(argc, argv);
if (action == ACTION_HELP) {
142,8 → 142,8
/* read the DOSDIR environment variable */
dosdir = getenv("DOSDIR");
if (dosdir == NULL) {
puts(svarlang_str(2, 2)); /* "%DOSDIR% not set! You should make it point to the FreeDOS main directory." */
puts(svarlang_str(2, 3)); /* "Example: SET DOSDIR=C:\FDOS" */
kitten_puts(2, 2, "%DOSDIR% not set! You should make it point to the FreeDOS main directory.");
kitten_puts(2, 3, "Example: SET DOSDIR=C:\\FDOS");
goto GAMEOVER;
}
 
173,6 → 173,7
}
 
GAMEOVER:
kittenclose(); /* NLS de-init */
if (res != 0) return(1);
return(0);
}
/pkg/nls_utf8/pkg_de.txt
3,6 → 3,7
# Time-stamp: "2017-03-09 22:50:34 joerg"
#
# Language..: German
# Codepage..: 850
# Translator: Jörg Jenderek
# Version...: 0.99.4
 
17,12 → 18,12
1.24: pkg listlocal [filter]
1.27: pkg unzip datei.zip
1.25:PKG is published under the MIT license.
1.26:It is configured through %DOSDIR%\CFG\PKG.CFG
1.26:It is configured through %DOSDIR%\\CFG\\PKG.CFG
 
### General stuff ####
 
2.2:%DOSDIR% nicht gesetzt! Sie sollte auf das SvarDOS-Hauptverzeichnis verweisen.
2.3:Beispiel: SET DOSDIR=C:\SVARDOS
2.3:Beispiel: SET DOSDIR=C:\\SVARDOS
2.14:Kein Speicher mehr! (%s)
 
#### Installing package ####
/pkg/nls_utf8/pkg_dk.txt
2,6 → 2,7
# FDNPKG language file
#
# Language..: Danish
# Codepage..: 850 (858)
# Translator: Henrik Schick-Hansen
#
 
15,12 → 16,12
1.24: pkg listlocal [filter]
1.27: pkg unzip file.zip
1.25:PKG is published under the MIT license.
1.26:It is configured through %DOSDIR%\CFG\PKG.CFG
1.26:It is configured through %DOSDIR%\\CFG\\PKG.CFG
 
### General stuff ####
 
2.2:%DOSDIR% ikke sat! DOSDIR skal pege på SvarDOS hoved biblioteket.
2.3:Eksempel: SET DOSDIR=C:\SVARDOS
2.3:Eksempel: SET DOSDIR=C:\\SVARDOS
2.14:Hukommelse opbrugt! (%s)
 
#### Installing package ####
/pkg/nls_utf8/pkg_en.txt
2,6 → 2,7
# PKG language file
#
# Language..: English
# Codepage..: 437
# Translator: Mateusz Viste
#
 
15,12 → 16,12
1.24: pkg listlocal [filter]
1.27: pkg unzip file.zip
1.25:PKG is published under the MIT license.
1.26:It is configured through %DOSDIR%\CFG\PKG.CFG
1.26:It is configured through %DOSDIR%\\CFG\\PKG.CFG
 
### General stuff ####
 
2.2:%DOSDIR% not set! You should make it point to the SvarDOS main directory.
2.3:Example: SET DOSDIR=C:\SVARDOS
2.3:Example: SET DOSDIR=C:\\SVARDOS
2.14:Out of memory! (%s)
 
#### Installing package ####
/pkg/nls_utf8/pkg_fr.txt
2,6 → 2,7
# FDNPKG language file
#
# Language..: French
# Codepage..: 850
# Translator: anonymous
#
 
15,12 → 16,12
1.24: pkg listlocal [filter]
1.27: pkg unzip fichier.zip
1.25:PKG est publié sous license MIT.
1.26:Cet outil est configurable via %DOSDIR%\CFG\PKG.CFG
1.26:Cet outil est configurable via %DOSDIR%\\CFG\\PKG.CFG
 
### General stuff ####
 
2.2:%DOSDIR% non défini! Faites-le pointer vers le répertoire principal de SvarDOS.
2.3:Exemple : SET DOSDIR=C:\SVARDOS
2.3:Exemple : SET DOSDIR=C:\\SVARDOS
2.14:Mémoire insuffisante! (%s)
 
#### Installing package ####
/pkg/nls_utf8/pkg_pl.txt
2,6 → 2,7
# PKG language file
#
# Language..: Polish
# Codepage..: MAZOVIA
# Translator: Mateusz Viste
#
 
15,12 → 16,12
1.24: pkg listlocal [filtr]
1.27: pkg unzip plik.zip
1.25:PKG jest opublikowany na licencji MIT.
1.26:Konfiguracja znajduje się w pliku %DOSDIR%\CFG\PKG.CFG
1.26:Konfiguracja znajduje się w pliku %DOSDIR%\\CFG\\PKG.CFG
 
### General stuff ####
 
2.2:%DOSDIR% nie ustawione! Ustaw by wskazywało na katalog instalacji SvarDOS.
2.3:Przykład: SET DOSDIR=C:\SVARDOS
2.3:Przykład: SET DOSDIR=C:\\SVARDOS
2.14:Brak pamięci! (%s)
 
#### Installing package ####
/pkg/nls_utf8/pkg_si.txt
4,6 → 4,7
# Language..: Slovene
# Translator: Matej Horvat (http://matejhorvat.si/)
# Updated...: 2016-12-12
# Codepage..: 852
 
#### Help ####
 
15,12 → 16,12
1.24: pkg listlocal [filter]
1.27: pkg unzip file.zip
1.25:PKG is published under the MIT license.
1.26:It is configured through %DOSDIR%\CFG\PKG.CFG
1.26:It is configured through %DOSDIR%\\CFG\\PKG.CFG
 
### General stuff ####
 
2.0:Spremenljivka TEMP ni nastavljena! Kaže naj na imenik, kamor se da pisati.
2.3:Primer: SET DOSDIR=C:\SVARDOS
2.3:Primer: SET DOSDIR=C:\\SVARDOS
2.14:Ni dovolj spomina! (%s)
 
#### Installing package ####
/pkg/nls_utf8/pkg_tr.txt
2,6 → 2,7
# FDNPKG language file
#
# Language..: Turkish
# Codepage..: 857
# Translator: anonymous
#
 
15,12 → 16,12
1.24: pkg listlocal [filter]
1.27: pkg unzip file.zip
1.25:PKG is published under the MIT license.
1.26:It is configured through %DOSDIR%\CFG\PKG.CFG
1.26:It is configured through %DOSDIR%\\CFG\\PKG.CFG
 
### General stuff ####
 
2.2:%DOSDIR% ayarlanmamış! Onun SvarDOS ana dizinine işaret etmesi gerekir.
2.3:Örnek: SET DOSDIR=C:\SVARDOS
2.3:Örnek: SET DOSDIR=C:\\SVARDOS
2.14:Bellek yetersiz! (%s)
 
#### Installing package ####
/pkg/pkg.lsm
1,2 → 1,3
version: 20220203
description: SvarDOS package manager installs, removes and updates packages
version: 20210212
description: SvarDOS package manager: installs, removes and updates packages
license: MIT
/pkg/pkginst.c
1,6 → 1,6
/*
* This file is part of pkg (SvarDOS)
* Copyright (C) 2012-2022 Mateusz Viste
* Copyright (C) 2012-2021 Mateusz Viste
*/
 
#include <ctype.h> /* toupper() */
15,7 → 15,6
#include "kprintf.h"
#include "libunzip.h" /* zip_listfiles()... */
#include "showinst.h" /* pkg_loadflist() */
#include "svarlang.lib\svarlang.h"
 
#include "pkginst.h" /* include self for control */
 
76,7 → 75,7
/* checks that pkgname is NOT installed. return 0 on success, non-zero otherwise. */
static int validate_package_not_installed(const char *pkgname, const char *dosdir) {
if (is_package_installed(pkgname, dosdir) != 0) {
kitten_printf(3, 18, pkgname); /* "Package %s is already installed! You might want to use the 'update' action." */
kitten_printf(3, 18, "Package %s is already installed! You might want to use the 'update' action.", pkgname);
puts("");
return(-1);
}
116,12 → 115,12
 
*zipfd = fopen(zipfile, "rb");
if (*zipfd == NULL) {
puts(svarlang_str(3, 8)); /* "ERROR: Invalid zip archive! Package not installed." */
kitten_puts(3, 8, "ERROR: Invalid zip archive! Package not installed.");
goto RAII;
}
ziplinkedlist = zip_listfiles(*zipfd);
if (ziplinkedlist == NULL) {
puts(svarlang_str(3, 8)); /* "ERROR: Invalid zip archive! Package not installed." */
kitten_puts(3, 8, "ERROR: Invalid zip archive! Package not installed.");
goto RAII;
}
/* if updating, load the list of files belonging to the current package */
158,7 → 157,7
}
/* validate that the file has a valid filename (8+3, no shady chars...) */
if (validfilename(curzipnode->filename) != 0) {
puts(svarlang_str(3, 23)); /* "ERROR: Package contains an invalid filename:" */
kitten_puts(3, 23, "ERROR: Package contains an invalid filename:");
printf(" %s\n", curzipnode->filename);
goto RAII_ERR;
}
167,19 → 166,20
shortfile = computelocalpath(curzipnode->filename, fname, dosdir, dirlist);
strcat(fname, shortfile);
if ((findfileinlist(flist, fname) == NULL) && (fileexists(fname) != 0)) {
puts(svarlang_str(3, 9)); /* "ERROR: Package contains a file that already exists locally:" */
kitten_puts(3, 9, "ERROR: Package contains a file that already exists locally:");
printf(" %s\n", fname);
goto RAII_ERR;
}
/* abort if any entry is encrypted */
if ((curzipnode->flags & ZIP_FLAG_ENCRYPTED) != 0) {
puts(svarlang_str(3, 20)); /* "ERROR: Package contains an encrypted file:" */
kitten_printf(3, 20, "ERROR: Package contains an encrypted file:");
puts("");
printf(" %s\n", curzipnode->filename);
goto RAII_ERR;
}
/* abort if any file is compressed with an unsupported method */
if ((curzipnode->compmethod != ZIP_METH_STORE) && (curzipnode->compmethod != ZIP_METH_DEFLATE)) { /* unsupported compression method */
kitten_printf(8, 2, curzipnode->compmethod); /* "ERROR: Package contains a file compressed with an unsupported method (%d):" */
kitten_printf(8, 2, "ERROR: Package contains a file compressed with an unsupported method (%d):", curzipnode->compmethod);
puts("");
printf(" %s\n", curzipnode->filename);
goto RAII_ERR;
190,7 → 190,7
}
/* if appinfo file not found, this is not a real FreeDOS package */
if (appinfopresence != 1) {
kitten_printf(3, 12, appinfofile); /* "ERROR: Package do not contain the %s file! Not a valid SvarDOS package." */
kitten_printf(3, 12, "ERROR: Package do not contain the %s file! Not a valid FreeDOS package.", appinfofile);
puts("");
goto RAII_ERR;
}
232,7 → 232,7
sprintf(buff, "%s\\%s", dosdir, packageslst);
lstfd = fopen(buff, "wb"); /* opening it in binary mode, because I like to have control over line terminators (CR/LF) */
if (lstfd == NULL) {
kitten_printf(3, 10, buff); /* "ERROR: Could not create %s!" */
kitten_printf(3, 10, "ERROR: Could not create %s!", buff);
puts("");
return(-2);
}
250,7 → 250,7
/* Now unzip the file */
unzip_result = zip_unzip(zipfd, curzipnode, fulldestfilename);
if (unzip_result != 0) {
kitten_printf(8, 3, curzipnode->filename, fulldestfilename); /* "ERROR: failed extracting '%s' to '%s'!" */
kitten_printf(8, 3, "ERROR: failed extracting '%s' to '%s'!", curzipnode->filename, fulldestfilename);
printf(" [%d]\n", unzip_result);
filesextractedfailure += 1;
} else {
260,7 → 260,7
}
fclose(lstfd);
 
kitten_printf(3, 19, pkgname, filesextractedsuccess, filesextractedfailure); /* "Package %s installed: %ld files extracted, %ld errors." */
kitten_printf(3, 19, "Package %s installed: %ld files extracted, %ld errors.", pkgname, filesextractedsuccess, filesextractedfailure);
puts("");
return(filesextractedfailure);
}
/pkg/pkgrem.c
1,6 → 1,6
/*
* This file is part of the pkg (SvarDOS) project.
* Copyright (C) Mateusz Viste 2012-2022
* Copyright (C) Mateusz Viste 2012-2021
*/
 
#include <ctype.h> /* toupper() */
32,7 → 32,7
/* not in the list yet - add it */
res = malloc(sizeof(struct dirliststruct) + strlen(path));
if (res == NULL) { /* out of memory */
kitten_printf(4, 3, path); /* "Out of memory! Could not store directory %s!" */
kitten_printf(4, 3, "Out of memory! Could not store directory %s!", path);
puts("");
return(NULL);
}
74,7 → 74,7
sprintf(fpath, "%s\\packages\\%s.lst", dosdir, pkgname);
flist = fopen(fpath, "rb");
if (flist == NULL) {
kitten_printf(4, 0, pkgname); /* "Package %s is not installed, so not removed." */
kitten_printf(4, 0, "Package %s is not installed, so not removed.", pkgname);
puts("");
return(-1);
}
103,7 → 103,7
if (strcasecmp(buff, fpath) == 0) continue;
 
/* remove it */
kitten_printf(4, 4, buff); /* "removing %s" */
kitten_printf(4, 4, "removing %s", buff);
puts("");
unlink(buff);
}
136,7 → 136,7
 
/* remove the lst file */
unlink(fpath);
kitten_printf(4, 5, pkgname); /* "Package %s has been removed." */
kitten_printf(4, 5, "Package %s has been removed.", pkgname);
puts("");
return(0);
}
/pkg/showinst.c
1,6 → 1,6
/*
* This file is part of PKG (SvarDOS)
* Copyright (C) 2013-2022 Mateusz Viste
* Copyright (C) 2013-2021 Mateusz Viste
*/
 
#include <stdio.h>
14,7 → 14,6
#include "kprintf.h"
#include "libunzip.h" /* zip_freelist()... */
#include "lsm.h"
#include "svarlang.lib\svarlang.h"
 
#include "showinst.h" /* include self for control */
 
29,7 → 28,7
sprintf(buff, "%s\\packages", dosdir);
dp = opendir(buff);
if (dp == NULL) {
kitten_printf(9, 0, buff); /* "ERROR: Could not access directory %s" */
kitten_printf(9, 0, "ERROR: Could not access directory %s", buff);
puts("");
return(-1);
}
53,7 → 52,7
puts("");
matchfound = 1;
}
if (matchfound == 0) puts(svarlang_str(5, 0)); /* "No package matched the search." */
if (matchfound == 0) kitten_puts(5, 0, "No package matched the search.");
 
closedir(dp);
return(0);
79,7 → 78,7
sprintf(buff, "%s\\packages\\%s.lst", dosdir, pkgname);
fd = fopen(buff, "rb");
if (fd == NULL) {
kitten_printf(9, 1, pkgname); /* "ERROR: Local package '%s' not found." */
kitten_printf(9, 1, "ERROR: Local package '%s' not found.", pkgname);
puts("");
return(NULL);
}
91,7 → 90,7
/* add the new node to the result */
newnode = malloc(sizeof(struct flist_t) + strlen(buff));
if (newnode == NULL) {
kitten_printf(2, 14, "malloc failure"); /* "Out of memory! (%s)" */
kitten_printf(2, 14, "Out of memory! (%s)", "malloc failure");
continue;
}
newnode->next = res;
/pkg/unzip.c
3,7 → 3,7
* returns 0 on success
*
* this file is part of pkg (SvarDOS)
* copyright (C) 2021-2022 Mateusz Viste
* copyright (C) 2021 Mateusz Viste
*/
 
#include <stdio.h>
12,7 → 12,6
#include "helpers.h"
#include "kprintf.h"
#include "libunzip.h"
#include "svarlang.lib\svarlang.h"
 
#include "unzip.h"
 
24,13 → 23,13
 
fd = fopen(zipfile, "rb");
if (fd == NULL) {
puts(svarlang_str(10, 1)); /* "ERROR: Failed to open the archive file" */
kitten_puts(10, 1, "ERROR: Failed to open the archive file");
return(1);
}
 
zlist = zip_listfiles(fd);
if (zlist == NULL) {
puts(svarlang_str(10, 2)); /* "ERROR: Invalid ZIP archive" */
kitten_puts(10, 2, "ERROR: Invalid ZIP archive");
fclose(fd);
return(-1);
}
48,7 → 47,7
if (znode->flags == ZIP_FLAG_ISADIR) goto OK;
/* file already exists? */
if (fileexists(znode->filename) != 0) {
puts(svarlang_str(10, 3)); /* "ERROR: File already exists" */
kitten_puts(10, 3, "ERROR: File already exists");
r = 1;
continue;
}
60,7 → 59,7
continue;
}
OK:
puts(svarlang_str(10, 0)); /* "OK" */
kitten_puts(10, 0, "OK");
}
 
zip_freelist(&zlist);
/pkg/version.h
4,7 → 4,7
#ifndef COMMON_H_SENTINEL
#define COMMON_H_SENTINEL
 
#define PVER "20220203"
#define PDATE "2012-2022"
#define PVER "20210212"
#define PDATE "2012-2021"
 
#endif