Subversion Repositories SvarDOS

Compare Revisions

Ignore whitespace Rev 237 → Rev 238

/pkginst/readenv.c
File deleted
/pkginst/readenv.h
File deleted
/pkginst/Makefile
9,7 → 9,7
 
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
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 rtrim.obj showinst.obj
wcl $(LDFLAGS) $(LIBS) *.obj
 
main.obj: main.c
51,9 → 51,6
pkgrem.obj: pkgrem.c
wcc $(CFLAGS) pkgrem.c
 
readenv.obj: readenv.c
wcc $(CFLAGS) readenv.c
 
rtrim.obj: rtrim.c
wcc $(CFLAGS) rtrim.c
 
/pkginst/loadconf.c
1,10 → 1,9
/*
* This file is part of FDNPKG.
* This file is part of pkginst (SvarDOS).
*
* Loads the list of repositories from the config file specified in %FDNPKG%.
* Returns the amount of repositories found (and loaded) on success, or -1 on failure.
* Loads the list of repositories from a config file.
*
* Copyright (C) 2012-2016 Mateusz Viste
* Copyright (C) 2012-2021 Mateusz Viste
*/
 
#include <stdio.h> /* printf(), fclose(), fopen()... */
16,7 → 15,6
#include "kprintf.h"
#include "loadconf.h"
#include "parsecmd.h"
#include "version.h"
 
 
void freeconf(struct customdirs **dirlist) {
24,16 → 22,13
/* free the linked list of custom dirs */
while (*dirlist != NULL) {
curpos = *dirlist;
if (curpos->name != NULL) free(curpos->name);
if (curpos->location != NULL) free(curpos->location);
*dirlist = (*dirlist)->next;
free(curpos);
}
*dirlist = NULL;
}
 
 
static int checkfordoubledirlist(struct customdirs *dirlist) {
static int checkfordoubledirlist(const struct customdirs *dirlist) {
struct customdirs *curpos;
for (; dirlist != NULL; dirlist = dirlist->next) {
for (curpos = dirlist->next; curpos != NULL; curpos = curpos->next) {
49,7 → 44,7
 
 
/* validates dirlist entries: check that they are absolute paths and are not using restricted names */
static int validatedirlist(struct customdirs *dirlist) {
static int validatedirlist(const struct customdirs *dirlist) {
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) {
83,21 → 78,11
 
/* add (and allocates) a new custom dir entry to dirlist. Returns 0 on success,
or non-zero on failure (failures happen on out of memory events). */
static int addnewdir(struct customdirs **dirlist, char *name, char *location) {
static int addnewdir(struct customdirs **dirlist, const char *name, const char *location) {
struct customdirs *newentry;
newentry = malloc(sizeof(struct customdirs));
if (strlen(name) >= sizeof(newentry->name)) return(-2);
newentry = malloc(sizeof(struct customdirs) + strlen(location) + 1);
if (newentry == NULL) return(-1);
newentry->name = malloc(strlen(name) + 1);
if (newentry->name == NULL) {
free(newentry);
return(-1);
}
newentry->location = malloc(strlen(location) + 1);
if (newentry->location == NULL) {
free(newentry->name);
free(newentry);
return(-1);
}
strcpy(newentry->name, name);
strcpy(newentry->location, location);
newentry->next = *dirlist;
/pkginst/loadconf.h
8,9 → 8,9
#define loadrepolist_sentinel
 
struct customdirs {
char *name;
char *location;
struct customdirs *next;
char name[9];
char location[1]; /* extended at alloc time */
};
 
/* Loads the list of custom directories from the config file
/pkginst/main.c
1,5 → 1,5
/*
* PKGINST - lightweigth SvarDOS package installer
* PKGINST - SvarDOS package installer
* Copyright (C) 2015-2021 Mateusz Viste
*
* Permission is hereby granted, free of charge, to any person obtaining a
26,10 → 26,10
#include <stdlib.h> /* malloc() and friends */
#include <string.h> /* strcasecmp() */
 
#include "kprintf.h"
#include "libunzip.h"
#include "pkginst.h"
#include "pkgrem.h"
#include "readenv.h"
#include "version.h"
 
 
111,8 → 111,13
action = parsearg(argc, argv);
if (action == ACTION_HELP) return(showhelp());
 
/* read all necessary environment variables */
if (readenv(&dosdir) != 0) return(1);
/* read the DOSDIR environment variable */
dosdir = getenv("DOSDIR");
if (dosdir == NULL) {
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");
return(-1);
}
 
/* load configuration */
flags = 0;