Subversion Repositories SvarDOS

Compare Revisions

Ignore whitespace Rev 220 → Rev 221

/pkginst/kprintf0.c
File deleted
/pkginst/fdinst.c
File deleted
/pkginst/build.bat
File deleted
/pkginst/Makefile
0,0 → 1,65
#
# pkginst Makefile -- requires OpenWatcom (wmake)
# Copyright (C) 2021 Mateusz Viste
#
 
CFLAGS = -0 -ml -os -wx -we -d0 -i=zlib\ -DNOREPOS -DNOLZMA
LDFLAGS = -ml -lr -fe=pkginst.exe
LIBS = zlib\zlib_l.lib
 
all: pkginst.exe
 
pkginst.exe: main.obj crc32.obj fileexst.obj getdelim.obj helpers.obj inf.obj kprintf.obj libunzip.obj loadconf.obj lsm.obj parsecmd.obj pkginst.obj pkgrem.obj readenv.obj rtrim.obj showinst.obj
wcl $(LDFLAGS) $(LIBS) *.obj
 
main.obj: main.c
wcc $(CFLAGS) main.c
 
crc32.obj: crc32.c
wcc $(CFLAGS) crc32.c
 
fileexst.obj: fileexst.c
wcc $(CFLAGS) fileexst.c
 
getdelim.obj: getdelim.c
wcc $(CFLAGS) getdelim.c
 
helpers.obj: helpers.c
wcc $(CFLAGS) helpers.c
 
inf.obj: inf.c
wcc $(CFLAGS) inf.c
 
kprintf.obj: kprintf.c
wcc $(CFLAGS) kprintf.c
 
libunzip.obj: libunzip.c
wcc $(CFLAGS) libunzip.c
 
loadconf.obj: loadconf.c
wcc $(CFLAGS) loadconf.c
 
lsm.obj: lsm.c
wcc $(CFLAGS) lsm.c
 
parsecmd.obj: parsecmd.c
wcc $(CFLAGS) parsecmd.c
 
pkginst.obj: pkginst.c
wcc $(CFLAGS) pkginst.c
 
pkgrem.obj: pkgrem.c
wcc $(CFLAGS) pkgrem.c
 
readenv.obj: readenv.c
wcc $(CFLAGS) readenv.c
 
rtrim.obj: rtrim.c
wcc $(CFLAGS) rtrim.c
 
showinst.obj: showinst.c
wcc $(CFLAGS) showinst.c
 
clean: .symbolic
del *.obj
del pkginst.exe
/pkginst/fdnpkg.h
0,0 → 1,19
/*
* This file is part of FDNPKG
* Copyright (C) 2012-2016 Mateusz Viste
*/
 
#ifndef FDNPKG_H_SENTINEL
#define FDNPKG_H_SENTINEL
 
/* flags used by FDNPKG */
#define PKGINST_NOSOURCE 1
#define PKGINST_SKIPLINKS 2
#define PKGINST_UPDATE 4
 
struct flist_t {
struct flist_t *next;
char fname[2]; /* this must be the last item in the structure, it will be expanded to fit the filename */
};
 
#endif
/pkginst/kprintf.c
0,0 → 1,24
/*
* This file provides dummy functions that simulate kitten-enabled routines
* without actually having kitten.
*
* Copyright (C) 2015-2016 Mateusz Viste
*/
 
#include <stdio.h> /* vprintf() */
#include <stdarg.h> /* va_list, va_start()... */
 
#include "kprintf.h"
 
void kitten_printf(short x, short y, char *fmt, ...) {
va_list args;
va_start(args, fmt);
vprintf(fmt, args);
va_end(args);
x = y;
}
 
void kitten_puts(short x, short y, char *fmt) {
x = y;
puts(fmt);
}
/pkginst/main.c
0,0 → 1,174
/*
* FDINST - lightweigth FreeDOS package installer
* Copyright (C) 2015-2017 Mateusz Viste
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
 
 
#include <stdio.h> /* printf() */
#include <stdlib.h> /* malloc() and friends */
#include <string.h> /* strcasecmp() */
 
#include "libunzip.h"
#include "pkginst.h"
#include "pkgrem.h"
#include "readenv.h"
#include "version.h"
 
 
enum ACTIONTYPES {
ACTION_INSTALL,
ACTION_REMOVE,
ACTION_HELP
};
 
 
static int showhelp(void) {
printf("FDINST v" PVER " Copyright (C) " PDATE " Mateusz Viste\n"
"\n"
"FDINST is a lightweigth package installer for FreeDOS. It is an alternative\n"
"to FDNPKG, when only basic, local install/remove actions are necessary. FDINST\n"
"is a 16-bit, 8086-compatible application running in real mode.\n"
"\n"
"Usage: FDINST install package.zip\n"
" FDINST remove package\n"
"\n"
"FDINST is published under the MIT license, and shares most of its source code\n"
"with FDNPKG to guarantee consistent behaviour of both tools. It also uses\n"
"FDNPKG's configuration file.\n"
);
return(1);
}
 
 
static enum ACTIONTYPES parsearg(int argc, char **argv) {
int extpos, i;
enum ACTIONTYPES res = ACTION_HELP;
/* I expect exactly 2 arguments (ie argc == 3) */
if (argc != 3) return(ACTION_HELP);
/* look for valid actions */
if (strcasecmp(argv[1], "install") == 0) {
res = ACTION_INSTALL;
} else if (strcasecmp(argv[1], "remove") == 0) {
res = ACTION_REMOVE;
}
/* the argument should never be empty */
if (argv[2][0] == 0) return(ACTION_INSTALL);
/* for 'install', validate that the extension is '.zip' */
if (res == ACTION_INSTALL) {
/* find where the file's extension starts */
extpos = 0;
for (i = 0; argv[2][i] != 0; i++) {
if (argv[2][i] == '.') extpos = i + 1;
}
if (extpos == 0) return(ACTION_HELP);
}
/* return the result */
return(res);
}
 
 
static int pkginst(char *file, int flags, char *dosdir, char *tempdir, struct customdirs *dirlist, char *mapdrv) {
char pkgname[32];
int t, lastpathdelim = -1, u = 0;
char *buffmem1k;
struct ziplist *zipfileidx;
FILE *zipfilefd;
for (t = 0; file[t] != 0; t++) {
if ((file[t] == '/') || (file[t] == '\\')) lastpathdelim = t;
}
/* copy the filename into pkgname (without path elements) */
for (t = lastpathdelim + 1; file[t] != 0; t++) pkgname[u++] = file[t];
pkgname[u] = 0; /* terminate the string */
/* truncate the file's extension (.zip) */
for (t = u; t > 0; t--) {
if (pkgname[t] == '.') {
pkgname[t] = 0;
break;
}
}
/* allocate some memory for pkginst_preparepackage() to do its job */
buffmem1k = malloc(1024);
if (buffmem1k == NULL) {
puts("ERROR: Out of memory");
return(1);
}
/* prepare the zip file and install it */
zipfileidx = pkginstall_preparepackage(NULL, pkgname, tempdir, file, flags, NULL, &zipfilefd, NULL, 0, NULL, dosdir, dirlist, buffmem1k, mapdrv);
free(buffmem1k);
if (zipfileidx != NULL) {
int res = 0;
if (pkginstall_installpackage(pkgname, dosdir, dirlist, zipfileidx, zipfilefd, mapdrv) != 0) res = 1;
fclose(zipfilefd);
return(res);
} else {
fclose(zipfilefd);
return(1);
}
}
 
 
int main(int argc, char **argv) {
int res, flags;
enum ACTIONTYPES action;
char *dosdir, *tempdir, *cfgfile;
struct customdirs *dirlist;
char *mapdrv = "";
 
action = parsearg(argc, argv);
if (action == ACTION_HELP) return(showhelp());
 
/* allocate some bits for cfg file's location */
cfgfile = malloc(256);
if (cfgfile == NULL) {
puts("ERROR: Out of memory");
return(1);
}
 
/* read all necessary environment variables */
if (readenv(&dosdir, &tempdir, cfgfile, 256) != 0) {
free(cfgfile);
return(1);
}
 
/* load configuration */
flags = 0;
dirlist = NULL;
if (loadconf(cfgfile, NULL, 0, NULL, NULL, &dirlist, &flags, NULL, NULL, &mapdrv) < 0) return(5);
 
/* free the cfgfile buffer, I won't need the config file's location any more */
free(cfgfile);
cfgfile = NULL;
 
switch (action) {
case ACTION_INSTALL:
res = pkginst(argv[2], flags, dosdir, tempdir, dirlist, mapdrv);
break;
case ACTION_REMOVE:
res = pkgrem(argv[2], dosdir, mapdrv);
break;
default:
res = showhelp();
break;
}
 
if (res != 0) return(1);
return(0);
}
/pkginst/pkgdb.h
0,0 → 1,34
/*
* Package database manipulation routines.
* This file is part of the FDNPKG project.
*
* Copyright (C) 2012-2017 Mateusz Viste
*/
 
#ifndef pkgdb_sentinel
#define pkgdb_sentinel
 
struct pkgrepo {
unsigned char repo;
char version[16];
unsigned long crc32zip;
unsigned long crc32zib;
struct pkgrepo *nextrepo;
};
 
struct pkgdb {
char name[9];
char *desc; /* the description of the package - will be strdup()ed when time will come */
struct pkgrepo *repolist;
struct pkgdb *nextpkg;
};
 
 
struct pkgdb *createdb(void);
void freedb(struct pkgdb **db);
struct pkgdb *findpkg(struct pkgdb *db, char *pkgname, struct pkgdb **lastmatch);
int loaddb(struct pkgdb *db, char *datafile, unsigned char repo, char **dbmsg);
int loaddb_fromcache(struct pkgdb *db, char *datafile, unsigned long crc32val, long maxcachetime);
void dumpdb(struct pkgdb *db, char *datafile, unsigned long crc32val);
 
#endif
/pkginst/pkginst.c
13,7 → 13,6
 
#include "crc32.h" /* all CRC32 related stuff */
#include "fdnpkg.h" /* PKGINST_NOSOURCE, PKGINST_SKIPLINKS... */
#include "http.h"
#include "helpers.h" /* slash2backslash(), strtolower() */
#include "fileexst.h"
#include "kprintf.h"
/pkginst/pkginst.h
6,7 → 6,6
#ifndef pkginst_sentinel
#define pkginst_sentinel
 
#include "pkgdb.h"
#include "loadconf.h" /* required for struct customdirs */
 
int is_package_installed(char *pkgname, char *dosdir, char *mapdrv);
/pkginst/version.h
0,0 → 1,10
/*
*/
 
#ifndef COMMON_H_SENTINEL
#define COMMON_H_SENTINEL
 
#define PVER "20210123"
#define PDATE "2012-2021"
 
#endif