/pkginst/main.c |
---|
1,6 → 1,6 |
/* |
* FDINST - lightweigth FreeDOS package installer |
* Copyright (C) 2015-2017 Mateusz Viste |
* PKGINST - lightweigth SvarDOS package installer |
* Copyright (C) 2015-2021 Mateusz Viste |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the "Software"), |
73,10 → 73,9 |
} |
static int pkginst(char *file, int flags, char *dosdir, char *tempdir, struct customdirs *dirlist) { |
static int pkginst(const char *file, int flags, const char *dosdir, struct customdirs *dirlist) { |
char pkgname[32]; |
int t, lastpathdelim = -1, u = 0; |
char *buffmem1k; |
struct ziplist *zipfileidx; |
FILE *zipfilefd; |
for (t = 0; file[t] != 0; t++) { |
92,15 → 91,8 |
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(pkgname, file, flags, &zipfilefd, dosdir, dirlist, buffmem1k); |
free(buffmem1k); |
zipfileidx = pkginstall_preparepackage(pkgname, file, flags, &zipfilefd, dosdir, dirlist); |
if (zipfileidx != NULL) { |
int res = 0; |
if (pkginstall_installpackage(pkgname, dosdir, dirlist, zipfileidx, zipfilefd) != 0) res = 1; |
116,7 → 108,7 |
int main(int argc, char **argv) { |
int res, flags; |
enum ACTIONTYPES action; |
char *dosdir, *tempdir, *cfgfile; |
char *dosdir, *cfgfile; |
struct customdirs *dirlist; |
action = parsearg(argc, argv); |
130,7 → 122,7 |
} |
/* read all necessary environment variables */ |
if (readenv(&dosdir, &tempdir, cfgfile, 256) != 0) { |
if (readenv(&dosdir, cfgfile, 256) != 0) { |
free(cfgfile); |
return(1); |
} |
146,7 → 138,7 |
switch (action) { |
case ACTION_INSTALL: |
res = pkginst(argv[2], flags, dosdir, tempdir, dirlist); |
res = pkginst(argv[2], flags, dosdir, dirlist); |
break; |
case ACTION_REMOVE: |
res = pkgrem(argv[2], dosdir); |
/pkginst/pkginst.c |
---|
23,7 → 23,7 |
/* return 1 if fname looks like a link filename, 0 otherwise */ |
static int islinkfile(char *fname) { |
static int islinkfile(const char *fname) { |
char *link1 = "LINKS\\"; |
char *link2 = "links\\"; |
int x; |
36,7 → 36,7 |
/* validate a filename (8+3, no weird characters, etc). returns 0 on success, |
* nonzero otherwise. */ |
static int validfilename(char *fname) { |
static int validfilename(const char *fname) { |
int i, i2; |
char *validchars = "!#$%&'()-@^_`{}~"; |
int elemlen = 0; |
81,7 → 81,7 |
/* processes a link file - that is, reads the target inside, and overwrite |
* the file with new content */ |
static void processlinkfile(char *linkfile, char *dosdir, struct customdirs *dirlist, char *buff) { |
static void processlinkfile(const char *linkfile, const char *dosdir, const struct customdirs *dirlist, char *buff) { |
char origtarget[512]; |
int x; |
char *shortfile; |
156,7 → 156,7 |
/* find a filename in a flist linked list, and returns a pointer to it */ |
static struct flist_t *findfileinlist(struct flist_t *flist, char *fname) { |
static struct flist_t *findfileinlist(struct flist_t *flist, const char *fname) { |
while (flist != NULL) { |
if (strcmp(flist->fname, fname) == 0) return(flist); |
flist = flist->next; |
167,17 → 167,14 |
/* prepare a package for installation. this is mandatory before actually installing it! |
* returns a pointer to the zip file's index on success, NULL on failure. the **zipfd pointer is updated with a file descriptor to the open zip file to install. */ |
struct ziplist *pkginstall_preparepackage(const char *pkgname, const char *zipfile, int flags, FILE **zipfd, const char *dosdir, const struct customdirs *dirlist, char *buffmem1k) { |
char *fname; |
char *appinfofile; |
struct ziplist *pkginstall_preparepackage(const char *pkgname, const char *zipfile, int flags, FILE **zipfd, const char *dosdir, const struct customdirs *dirlist) { |
char fname[256]; |
char appinfofile[256]; |
int appinfopresence; |
char *shortfile; |
struct ziplist *ziplinkedlist = NULL, *curzipnode, *prevzipnode; |
struct flist_t *flist = NULL; |
fname = buffmem1k; |
appinfofile = buffmem1k + 512; |
sprintf(appinfofile, "appinfo\\%s.lsm", pkgname); /* Prepare the appinfo/xxxx.lsm filename string for later use */ |
/* check if not already installed, if already here, print a message "you might want to use update instead" |
295,7 → 292,7 |
/* install a package that has been prepared already. returns 0 on success, |
* or a negative value on error, or a positive value on warning */ |
int pkginstall_installpackage(char *pkgname, char *dosdir, struct customdirs *dirlist, struct ziplist *ziplinkedlist, FILE *zipfd) { |
int pkginstall_installpackage(const char *pkgname, const char *dosdir, const struct customdirs *dirlist, struct ziplist *ziplinkedlist, FILE *zipfd) { |
char *buff; |
char *fulldestfilename; |
char packageslst[64]; |
/pkginst/pkginst.h |
---|
9,7 → 9,7 |
#include "loadconf.h" /* required for struct customdirs */ |
int is_package_installed(const char *pkgname, const char *dosdir); |
struct ziplist *pkginstall_preparepackage(const char *pkgname, const char *localfile, int flags, FILE **zipfd, const char *dosdir, const struct customdirs *dirlist, char *buffmem1k); |
int pkginstall_installpackage(char *pkgname, char *dosdir, struct customdirs *dirlist, struct ziplist *ziplinkedlist, FILE *zipfd); |
struct ziplist *pkginstall_preparepackage(const char *pkgname, const char *localfile, int flags, FILE **zipfd, const char *dosdir, const struct customdirs *dirlist); |
int pkginstall_installpackage(const char *pkgname, const char *dosdir, const struct customdirs *dirlist, struct ziplist *ziplinkedlist, FILE *zipfd); |
#endif |
/pkginst/readenv.c |
---|
1,10 → 1,10 |
/* |
* This file is part of FDNPKG. |
* This file is part of pkginst (SvarDOS). |
* |
* Reads environment variables that will be used by FDNPKG and FDINST. |
* Reads environment variables that will be used by pkginst. |
* Returns 0 on success, non-zero otherwise. |
* |
* Copyright (C) 2012-2016 Mateusz Viste |
* Copyright (C) 2012-2021 Mateusz Viste |
*/ |
#include <stdio.h> /* snprintf() */ |
14,7 → 14,7 |
#include "readenv.h" |
int readenv(char **dosdir, char **tempdir, char *cfgfile, int cfgfilemaxlen) { |
int readenv(char **dosdir, char *cfgfile, int cfgfilemaxlen) { |
char *cfg; |
/* check if %DOSDIR% is set, and retrieve it */ |
25,14 → 25,6 |
return(-1); |
} |
/* check if %TEMP% is set, and retrieve it */ |
*tempdir = getenv("TEMP"); |
if (*tempdir == NULL) { |
kitten_puts(2, 0, "%TEMP% not set! You should make it point to a writeable directory."); |
kitten_puts(2, 1, "Example: SET TEMP=C:\\TEMP"); |
return(-2); |
} |
/* look for the FDNPKG.CFG env. variable */ |
cfg = getenv("FDNPKG.CFG"); |
cfgfilemaxlen -= 1; /* make room for the null terminator */ |
/pkginst/readenv.h |
---|
1,15 → 1,15 |
/* |
* This file is part of FDNPKG. |
* This file is part of pkginst (SvarDOS). |
* |
* Reads environment variables that will be used by FDNPKG and FDINST. |
* Reads environment variables that will be used by pkginst. |
* Returns 0 on success, non-zero otherwise. |
* |
* Copyright (C) 2012-2016 Mateusz Viste |
* Copyright (C) 2012-2021 Mateusz Viste |
*/ |
#ifndef READENV_H_SENTINEL |
#define READENV_H_SENTINEL |
int readenv(char **dosdir, char **tempdir, char *cfgfile, int cfgfilemaxlen); |
int readenv(char **dosdir, char *cfgfile, int cfgfilemaxlen); |
#endif |