Subversion Repositories SvarDOS

Compare Revisions

Ignore whitespace Rev 295 → Rev 296

/pkg/Makefile
24,7 → 24,7
copy pkg.lsm appinfo
zip -9 -m -o -r pkg.zip appinfo bin nls
 
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
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
 
kitten.obj: kitten\kitten.c
69,6 → 69,9
showinst.obj: showinst.c
wcc $(CFLAGS) showinst.c
 
unzip.obj: unzip.c
wcc $(CFLAGS) unzip.c
 
clean: .symbolic
del *.obj
del pkg.exe
/pkg/main.c
35,6 → 35,7
#include "pkginst.h"
#include "pkgrem.h"
#include "showinst.h"
#include "unzip.h"
#include "version.h"
 
 
44,6 → 45,7
ACTION_REMOVE,
ACTION_LISTFILES,
ACTION_LISTLOCAL,
ACTION_UNZIP,
ACTION_HELP
};
 
58,6 → 60,7
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("");
kitten_puts(1, 25, "PKG is published under the MIT license.");
kitten_puts(1, 26, "It is configured through %DOSDIR%\\CFG\\PKG.CFG");
77,6 → 80,8
return(ACTION_LISTFILES);
} else if ((argc >= 2) && (argc <= 3) && (strcasecmp(argv[1], "listlocal") == 0)) {
return(ACTION_LISTLOCAL);
} else if ((argc == 3) && (strcasecmp(argv[1], "unzip") == 0)) {
return(ACTION_UNZIP);
} else {
return(ACTION_HELP);
}
159,6 → 164,9
case ACTION_LISTLOCAL:
res = showinstalledpkgs((argc == 3)?argv[2]:NULL, dosdir);
break;
case ACTION_UNZIP:
res = unzip(argv[2]);
break;
default:
res = showhelp();
break;
/pkg/nls_utf8/pkg_en.txt
14,6 → 14,7
1.22: pkg remove package
1.23: pkg listfiles package
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
 
66,3 → 67,11
 
9.0:ERROR: Could not access directory %s
9.1:ERROR: Local package '%s' not found
 
#### unzip ####
 
10.0:OK
10.1:ERROR: Failed to open the archive file
10.2:ERROR: Invalid ZIP archive
10.3:ERROR: File already exists
10.4:ERROR: unzip failure (%d)
/pkg/nls_utf8/pkg_pl.txt
66,3 → 66,11
 
9.0:BŁĄD: Dostęp do katalogu %s nie powiódł się.
9.1:BŁĄD: Nie znaleziono lokalnego pakietu %s.
 
#### unzip ####
 
10.0:OK
10.1:BŁĄD: Otwarcie pliku archiwum nie powiodło się
10.2:BŁĄD: Nieprawidłowe archiwum ZIP
10.3:BŁĄD: Plik już istnieje
10.4:BŁĄD: błąd unzip (%d)
/pkg/pkg.lsm
1,3 → 1,3
version: 20210211
version: 20210212
description: SvarDOS package manager: installs, removes and updates packages
license: MIT
/pkg/unzip.c
0,0 → 1,68
/*
* simple unzip tool that unzips the content of a zip archive to current directory
* returns 0 on success
*
* this file is part of pkg (SvarDOS)
* copyright (C) 2021 Mateusz Viste
*/
 
#include <stdio.h>
 
#include "fileexst.h"
#include "helpers.h"
#include "kprintf.h"
#include "libunzip.h"
 
#include "unzip.h"
 
 
int unzip(const char *zipfile) {
struct ziplist *zlist, *znode;
FILE *fd;
int r = 0;
 
fd = fopen(zipfile, "rb");
if (fd == NULL) {
kitten_puts(10, 1, "ERROR: Failed to open the archive file");
return(1);
}
 
zlist = zip_listfiles(fd);
if (zlist == NULL) {
kitten_puts(10, 2, "ERROR: Invalid ZIP archive");
fclose(fd);
return(-1);
}
 
/* examine the list of zipped files - make sure that no file currently
* exists and that files are neither encrypted nor compressed with an
* unsupported method */
for (znode = zlist; znode != NULL; znode = znode->nextfile) {
int zres;
/* convert slash to backslash, print filename and create the directories path */
slash2backslash(znode->filename);
printf("%s ", znode->filename);
mkpath(znode->filename);
/* if a dir, we good already */
if (znode->flags == ZIP_FLAG_ISADIR) goto OK;
/* file already exists? */
if (fileexists(znode->filename) != 0) {
kitten_puts(10, 3, "ERROR: File already exists");
r = 1;
continue;
}
/* uncompress */
zres = zip_unzip(fd, znode, znode->filename);
if (zres != 0) {
kitten_printf(10, 4, "ERROR: unzip failure (%d)", zres);
puts("");
continue;
}
OK:
kitten_puts(10, 0, "OK");
}
 
zip_freelist(&zlist);
fclose(fd);
return(r);
}
/pkg/unzip.h
0,0 → 1,14
/*
* simple unzip tool that unzips the content of a zip archive to current directory
* returns 0 on success
*
* this file is part of pkg (SvarDOS)
* copyright (C) 2021 Mateusz Viste
*/
 
#ifndef unzip_h
#define unzip_h
 
int unzip(const char *zipfile);
 
#endif