Subversion Repositories SvarDOS

Compare Revisions

Ignore whitespace Rev 236 → Rev 237

/pkginst/loadconf.c
11,7 → 11,6
#include <string.h> /* strcasecmp() */
#include <stdlib.h> /* malloc(), free() */
 
#include "crc32.h" /* crc32() */
#include "fdnpkg.h" /* PKGINST_SKIPLINKS... */
#include "helpers.h" /* slash2backslash(), removeDoubleBackslashes()... */
#include "kprintf.h"
107,18 → 106,20
}
 
 
int loadconf(char *cfgfile, struct customdirs **dirlist, int *flags) {
int loadconf(const char *dosdir, struct customdirs **dirlist, int *flags) {
int bytebuff, parserstate = 0;
FILE *fd;
#define maxtok 16
char token[maxtok];
#define maxval 1024
#define maxval 256
char value[maxval];
char cfgfile[256];
int curtok = 0, curval = 0, nline = 1;
 
snprintf(cfgfile, sizeof(cfgfile), "%s\\cfg\\pkg.cfg", dosdir);
fd = fopen(cfgfile, "r");
if (fd == NULL) {
kitten_printf(7, 1, "Error: Could not open config file '%s'!", cfgfile);
kitten_printf(7, 1, "Error: Could not open config file (%s)!", cfgfile);
puts("");
return(-1);
}
/pkginst/loadconf.h
13,9 → 13,9
struct customdirs *next;
};
 
/* Loads the list of custom directories from the config file specified in %FDNPKG%.
/* Loads the list of custom directories from the config file
* Returns 0 on success, or -1 on failure. */
int loadconf(char *cfgfile, struct customdirs **dirlist, int *flags);
int loadconf(const char *dosdir, struct customdirs **dirlist, int *flags);
 
/* Free the memory allocated at configuration load. */
void freeconf(struct customdirs **dirlist);
/pkginst/main.c
41,18 → 41,15
 
 
static int showhelp(void) {
printf("FDINST v" PVER " Copyright (C) " PDATE " Mateusz Viste\n"
printf("PKGINST ver " 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"
"PKGINST is the package installer for SvarDOS.\n"
"\n"
"Usage: FDINST install package.zip\n"
" FDINST remove package\n"
"Usage: PKGINST install package.zip\n"
" PKGINST 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"
"PKGINST is published under the MIT license. It uses a PKGINST.CFG configuration\n"
"file located in the directory pointed by %%PKGCFG%%\n"
);
return(1);
}
73,7 → 70,7
}
 
 
static int pkginst(const char *file, int flags, const char *dosdir, struct customdirs *dirlist) {
static int pkginst(const char *file, int flags, const char *dosdir, const struct customdirs *dirlist) {
char pkgname[32];
int t, lastpathdelim = -1, u = 0;
struct ziplist *zipfileidx;
108,34 → 105,20
int main(int argc, char **argv) {
int res, flags;
enum ACTIONTYPES action;
char *dosdir, *cfgfile;
char *dosdir;
struct customdirs *dirlist;
 
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, cfgfile, 256) != 0) {
free(cfgfile);
return(1);
}
if (readenv(&dosdir) != 0) return(1);
 
/* load configuration */
flags = 0;
dirlist = NULL;
if (loadconf(cfgfile, &dirlist, &flags) < 0) return(5);
if (loadconf(dosdir, &dirlist, &flags) != 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, dirlist);
/pkginst/readenv.h
10,6 → 10,6
#ifndef READENV_H_SENTINEL
#define READENV_H_SENTINEL
 
int readenv(char **dosdir, char *cfgfile, int cfgfilemaxlen);
int readenv(char **dosdir);
 
#endif