Browse Source

Patch from Anthony Towns for Task: debian/control support

keep-around/43e990ab3f4cc50982f8dbc32e3465ca7c827876
Randolph Chung 21 years ago
parent
commit
90bd68efac
  1. 2
      Makefile
  2. 200
      data.c
  3. 23
      data.h
  4. 18
      debian/changelog
  5. 4
      macros.h
  6. 87
      slangui.c
  7. 3
      slangui.h
  8. 54
      tasksel.c
  9. 11
      util.c
  10. 5
      util.h

2
Makefile

@ -2,7 +2,7 @@ PROGRAM=tasksel
VERSION=\"1.0\"
CC=gcc
CFLAGS=-g -Wall #-Os
DEFS=-DVERSION=$(VERSION) -DPACKAGE=\"$(PROGRAM)\" -DLOCALEDIR=\"/usr/share/locale\" #-DDEBUG
DEFS=-DVERSION=$(VERSION) -DPACKAGE=\"$(PROGRAM)\" -DLOCALEDIR=\"/usr/share/locale\" -DDEBUG
LIBS=-lslang #-lccmalloc -ldl
OBJS=tasksel.o slangui.o data.o util.o strutl.o
LANGS=cs de hu ja sv pl ru

200
data.c

@ -1,4 +1,4 @@
/* $Id: data.c,v 1.8 2000/02/06 22:12:32 tausq Exp $ */
/* $Id: data.c,v 1.9 2001/04/24 06:35:07 tausq Exp $ */
/* data.c - encapsulates functions for reading a package listing like dpkg's available file
* Internally, packages are stored in a binary tree format to faciliate search operations
*/
@ -15,6 +15,7 @@
#include "macros.h"
#define PACKAGEFIELD "Package: "
#define TASKFIELD "Task: "
#define DEPENDSFIELD "Depends: "
#define RECOMMENDSFIELD "Recommends: "
#define SUGGESTSFIELD "Suggests: "
@ -33,6 +34,10 @@ static struct package_t **_packages_enumbuf = NULL;
static int _packages_enumcount = 0;
static void *_packages_root = NULL;
static struct task_t **_tasks_enumbuf = NULL;
static int _tasks_enumcount = 0;
static void *_tasks_root = NULL;
/* private functions */
static int packagecompare(const void *p1, const void *p2)
{
@ -53,6 +58,39 @@ static void packages_walk_enumerate(const void *nodep, const VISIT order, const
}
}
static void tasks_walk_enumerate(const void *nodep, const VISIT order, const int depth)
{
/* adds nodep to list of nodes if we haven't visited this node before */
struct task_t *datap = *(struct task_t **)nodep;
if (order == leaf || order == postorder) {
_tasks_enumcount++;
_tasks_enumbuf[_tasks_enumcount - 1] = datap;
}
}
static int taskcompare(const struct task_t *l, const struct task_t *r)
{
return strcmp(l->name, r->name);
}
static void tasks_walk_delete(const void *nodep, const VISIT order, const int depth)
{
/* deletes memory associated with nodep */
struct task_t *datap = *(struct task_t **)nodep;
int i;
if (order == leaf || order == endorder) {
tdelete((void *)datap, &_tasks_root, taskcompare);
if (datap->name) FREE(datap->name);
if (datap->prettyname) FREE(datap->prettyname);
if (datap->packages) {
for (i = 0; i < datap->packagescount; i++) FREE(datap->packages[i]);
FREE(datap->packages);
}
FREE(datap);
}
}
static void packages_walk_delete(const void *nodep, const VISIT order, const int depth)
{
/* deletes memory associated with nodep */
@ -118,7 +156,75 @@ static const char *filterdescription(const char *descin)
return descin;
}
static void addpackage(struct packages_t *pkgs,
static struct task_t *addtask(
struct tasks_t *tasks,
const char *taskname,
const char *package)
{
struct task_t t = {0}, *task;
void *result;
t.name = (char*)taskname;
result = tfind(&t, &tasks->tasks, taskcompare);
if (result) {
task = *(struct task_t**)result;
} else {
int space = 1;
char *c;
task = NEW(struct task_t);
task->name = STRDUP(taskname);
task->task_pkg = NULL;
task->packages = MALLOC(sizeof(char*)*10);
task->packagesmax = 10;
task->packagescount = 0;
task->selected = 0;
c = task->prettyname = STRDUP(taskname);
/* Prettify name */
while (c[0]) {
if (c[0] == '-') {
c[0] = ' ';
space=1;
}
else if (space) {
c[0] = toupper(c[0]);
space=0;
}
c++;
}
/* Keep track of the longest name. */
if (tasks->maxnamelen < (c - task->prettyname))
tasks->maxnamelen = c - task->prettyname;
tsearch(task, &tasks->tasks, taskcompare);
tasks->count++;
}
{
char const *pch;
if (*package == '\0') return task;
for (pch = package; *pch; pch++) {
if ('a' <= *pch && *pch <= 'z') continue;
if ('0' <= *pch && *pch <= '9') continue;
if (*pch == '+' || *pch == '-' || *pch == '.') continue;
return task;
}
}
if (task->packagescount >= task->packagesmax) {
ASSERT(task->packagescount == task->packagesmax);
task->packagesmax *= 2;
task->packages = REALLOC(task->packages, task->packagesmax * sizeof(char*));
}
task->packages[task->packagescount++] = STRDUP(package);
return task;
}
static struct package_t *addpackage(
struct packages_t *pkgs,
const char *name, const char *dependsdesc,
const char *recommendsdesc, const char *suggestsdesc,
const char *shortdesc, const char *longdesc,
@ -166,6 +272,8 @@ static void addpackage(struct packages_t *pkgs,
p = tsearch((void *)node, &pkgs->packages, packagecompare);
VERIFY(p != NULL);
pkgs->count++;
return node;
}
/* public functions */
@ -187,8 +295,7 @@ struct package_t *packages_find(const struct packages_t *pkgs, const char *name)
struct package_t **packages_enumerate(const struct packages_t *packages)
{
/* Converts the packages binary tree into a array. Do not modify the returned array! It
* is a static variable managed by this module */
/* Converts a packages binary tree into an array */
_packages_enumbuf = MALLOC(sizeof(struct package_t *) * packages->count);
if (_packages_enumbuf == NULL)
@ -200,21 +307,48 @@ struct package_t **packages_enumerate(const struct packages_t *packages)
return _packages_enumbuf;
}
void packages_readlist(struct packages_t *taskpkgs, struct packages_t *pkgs)
struct task_t **tasks_enumerate(const struct tasks_t *tasks)
{
/* Converts the tasks binary tree into an array. */
_tasks_enumbuf = MALLOC(sizeof(struct task_t *) * tasks->count);
if (_tasks_enumbuf == NULL)
DIE("Cannot allocate memory for enumeration buffer");
memset(_tasks_enumbuf, 0, sizeof(struct task_t *) * tasks->count);
_tasks_enumcount = 0;
twalk((void *)tasks->tasks, tasks_walk_enumerate);
ASSERT(_tasks_enumcount == tasks->count);
return _tasks_enumbuf;
}
static void walktasks(const void *t, const VISIT which, const int depth)
{
struct task_t *task = *(struct task_t**)t;
int i;
if (which == postorder || which == leaf) {
fprintf(stderr, "Task %s:\n", task->prettyname);
for (i = 0; i < task->packagescount; i++) {
fprintf(stderr, " %s\n", task->packages[i]);
}
}
}
void packages_readlist(struct tasks_t *tasks, struct packages_t *pkgs)
{
/* Populates internal data structures with information from an available
* file */
FILE *f;
char buf[BUF_SIZE];
char *name, *shortdesc, *longdesc;
char *dependsdesc, *recommendsdesc, *suggestsdesc, *prioritydesc;
char *dependsdesc, *recommendsdesc, *suggestsdesc, *prioritydesc, *taskdesc;
priority_t priority;
VERIFY(taskpkgs != NULL); VERIFY(pkgs != NULL);
VERIFY(pkgs != NULL); VERIFY(tasks != NULL);
/* Initialization */
memset(taskpkgs, 0, sizeof(struct packages_t));
memset(pkgs, 0, sizeof(struct packages_t));
memset(tasks, 0, sizeof(struct tasks_t));
if ((f = fopen(AVAILABLEFILE, "r")) == NULL) PERROR(AVAILABLEFILE);
while (!feof(f)) {
@ -222,7 +356,7 @@ void packages_readlist(struct packages_t *taskpkgs, struct packages_t *pkgs)
CHOMP(buf);
if (MATCHFIELD(buf, PACKAGEFIELD)) {
/*DPRINTF("Package = %s\n", FIELDDATA(buf, PACKAGEFIELD)); */
name = shortdesc = longdesc = dependsdesc = recommendsdesc = suggestsdesc = NULL;
name = shortdesc = longdesc = taskdesc = dependsdesc = recommendsdesc = suggestsdesc = NULL;
priority = PRIORITY_UNKNOWN;
name = STRDUP(FIELDDATA(buf, PACKAGEFIELD));
@ -234,7 +368,10 @@ void packages_readlist(struct packages_t *taskpkgs, struct packages_t *pkgs)
CHOMP(buf);
if (buf[0] == 0) break;
if (MATCHFIELD(buf, DEPENDSFIELD)) {
if (MATCHFIELD(buf, TASKFIELD)) {
taskdesc = STRDUP(FIELDDATA(buf, TASKFIELD));
VERIFY(taskdesc != NULL);
} else if (MATCHFIELD(buf, DEPENDSFIELD)) {
dependsdesc = STRDUP(FIELDDATA(buf, DEPENDSFIELD));
VERIFY(dependsdesc != NULL);
} else if (MATCHFIELD(buf, RECOMMENDSFIELD)) {
@ -275,31 +412,58 @@ void packages_readlist(struct packages_t *taskpkgs, struct packages_t *pkgs)
}
}
if (strncmp(name, "task-", 5) != 0) {
addpackage(pkgs, name, NULL, NULL, NULL, shortdesc,
NULL, priority, 0);
if (strncmp(name, "task-", 5) == 0)
addpackage(taskpkgs, name, dependsdesc, recommendsdesc, suggestsdesc,
filterdescription(shortdesc), longdesc, priority, 1);
} else {
struct package_t *p;
struct task_t *t;
int i;
p = addpackage(pkgs, name, dependsdesc, recommendsdesc,
suggestsdesc, filterdescription(shortdesc),
longdesc, priority, 0);
t = addtask(tasks, name+5, "");
t->task_pkg = p;
for (i = 0; i < p->dependscount; i++) {
addtask(tasks, name+5, p->depends[i]);
}
}
if (taskdesc != NULL) {
char **ts;
int tscount;
int i;
tscount = splitlinkdesc(taskdesc, &ts);
for (i = 0; i < tscount; i++) {
addtask(tasks, ts[i], name);
FREE(ts[i]);
}
FREE(ts);
}
if (name != NULL) FREE(name);
if (dependsdesc != NULL) FREE(dependsdesc);
if (recommendsdesc != NULL) FREE(recommendsdesc);
if (suggestsdesc != NULL) FREE(suggestsdesc);
if (taskdesc != NULL) FREE(taskdesc);
if (shortdesc != NULL) FREE(shortdesc);
if (longdesc != NULL) FREE(longdesc);
}
};
fclose(f);
twalk(tasks->tasks, walktasks);
}
void packages_free(struct packages_t *taskpkgs, struct packages_t *pkgs)
void packages_free(struct tasks_t *tasks, struct packages_t *pkgs)
{
/* Frees up memory allocated by packages_readlist */
_packages_root = taskpkgs->packages;
twalk(taskpkgs->packages, packages_walk_delete);
_tasks_root = tasks->tasks;
twalk(tasks->tasks, tasks_walk_delete);
_packages_root = pkgs->packages;
twalk(pkgs->packages, packages_walk_delete);
if (_packages_enumbuf != NULL) FREE(_packages_enumbuf);
_packages_enumbuf = NULL;
}

23
data.h

@ -1,4 +1,4 @@
/* $Id: data.h,v 1.4 2000/02/06 22:12:32 tausq Exp $ */
/* $Id: data.h,v 1.5 2001/04/24 06:35:07 tausq Exp $ */
#ifndef _DATA_H
#define _DATA_H
@ -32,12 +32,29 @@ struct packages_t {
void *packages;
};
struct task_t {
char *name;
char *prettyname;
struct package_t *task_pkg;
char **packages;
int packagescount;
int packagesmax;
int selected;
};
struct tasks_t {
int count;
int maxnamelen;
void *tasks;
};
/* Reads in a list of package and package descriptions */
void packages_readlist(struct packages_t *taskpackages, struct packages_t *packages);
void packages_readlist(struct tasks_t *tasks, struct packages_t *packages);
/* free memory allocated to store packages */
void packages_free(struct packages_t *taskpackages, struct packages_t *packages);
void packages_free(struct tasks_t *tasks, struct packages_t *packages);
struct package_t *packages_find(const struct packages_t *packages, const char *name);
struct package_t **packages_enumerate(const struct packages_t *packages);
struct task_t **tasks_enumerate(const struct tasks_t *tasks);
#endif

18
debian/changelog

@ -1,3 +1,21 @@
tasksel (1.1-1) unstable; urgency=low
* Support "Task:" headers to include a package in a task.
.
Syntax is:
Package: foo
Task: bar, baz, quux
.
Note that tasks still require a task-* package in order to have a
description. Frontends could conceivably treat a task-foo package
being installed as meaning "automatically install new packages with
a Task: foo field, but don't worry about old packages that weren't
installed", similar to dselect's Standard handling, I think.
.
Patch thanks to Anthony Towns <aj@azure.humbug.org.au>
-- Randolph Chung <tausq@debian.org> Mon, 23 Apr 2001 23:34:57 -0700
tasksel (1.0-10) frozen unstable; urgency=low
* Release manager: needed for potato boot-floppies

4
macros.h

@ -1,4 +1,4 @@
/* $Id: macros.h,v 1.2 1999/11/23 05:39:27 tausq Exp $ */
/* $Id: macros.h,v 1.3 2001/04/24 06:35:07 tausq Rel $ */
#ifndef _MACROS_H
#define _MACROS_H
@ -22,6 +22,7 @@
#define ABORT abort()
#define STRDUP(s) safe_strdup(s)
#define MALLOC(sz) safe_malloc(sz)
#define REALLOC(x,sz) safe_realloc(x,sz)
#define FREE(p) safe_free((void **)&p);
#else
#define DPRINTF(fmt, arg...)
@ -30,6 +31,7 @@
#define ABORT exit(255)
#define STRDUP(s) (s ? strdup(s) : NULL)
#define MALLOC(sz) malloc(sz)
#define REALLOC(x,sz) realloc(x,sz)
#define FREE(p) if (p) free(p)
#endif

87
slangui.c

@ -1,4 +1,4 @@
/* $Id: slangui.c,v 1.19 2000/05/07 21:15:18 tausq Exp $ */
/* $Id: slangui.c,v 1.20 2001/04/24 06:35:07 tausq Exp $ */
/* slangui.c - SLang user interface routines */
/* TODO: the redraw code is a bit broken, also this module is using way too many
* global vars */
@ -15,6 +15,8 @@
#include "strutl.h"
#include "macros.h"
#define TASK_PKG(t,f,d) ((t)->task_pkg ? (t)->task_pkg->f : (d))
/* Slang object number mapping */
#define DEFAULTOBJ 0
#define SHADOWOBJ 2 /* must be 2 due to slang weirdness */
@ -61,13 +63,14 @@ static struct _chooserinfo_t _chooserinfo = {3, 3, 0, 0, 0, 0, 0};
static int _resizing = 0;
static int _initialized = 0;
static struct packages_t *_packages = NULL;
static struct packages_t *_taskpackages = NULL;
static struct package_t **_taskpackagesary = NULL;
static struct tasks_t *_tasks = NULL;
static struct task_t **_tasksary = NULL;
void ui_init(int argc, char * const argv[], struct packages_t *taskpkgs, struct packages_t *pkgs)
void ui_init(int argc, char * const argv[], struct tasks_t *tasks, struct packages_t *pkgs)
{
_taskpackages = taskpkgs;
_taskpackagesary = packages_enumerate(taskpkgs);
_tasks = tasks;
_tasksary = tasks_enumerate(tasks);
_packages = pkgs;
SLang_set_abort_signal(tasksel_signalhandler);
@ -166,7 +169,7 @@ int ui_eventloop(void)
if (_chooserinfo.index > 0)
_chooserinfo.index--;
else
_chooserinfo.index = _taskpackages->count - 1;
_chooserinfo.index = _tasks->count - 1;
ui_redrawcursor(_chooserinfo.index);
break;
@ -177,7 +180,7 @@ int ui_eventloop(void)
case SL_KEY_DOWN:
ui_clearcursor(_chooserinfo.index);
if (_chooserinfo.index < _taskpackages->count - 1)
if (_chooserinfo.index < _tasks->count - 1)
_chooserinfo.index++;
else
_chooserinfo.index = 0;
@ -194,8 +197,8 @@ int ui_eventloop(void)
case SL_KEY_NPAGE:
ui_clearcursor(_chooserinfo.index);
_chooserinfo.index += _chooserinfo.height;
if (_chooserinfo.index >= _taskpackages->count - 1)
_chooserinfo.index = _taskpackages->count - 1;
if (_chooserinfo.index >= _tasks->count - 1)
_chooserinfo.index = _tasks->count - 1;
ui_redrawcursor(_chooserinfo.index);
break;
@ -222,12 +225,12 @@ int ui_eventloop(void)
break;
case 'A': case 'a':
for (i = 0; i < _taskpackages->count; i++) _taskpackagesary[i]->selected = 1;
for (i = 0; i < _tasks->count; i++) _tasksary[i]->selected = 1;
ui_drawscreen();
break;
case 'N': case 'n':
for (i = 0; i < _taskpackages->count; i++) _taskpackagesary[i]->selected = 0;
for (i = 0; i < _tasks->count; i++) _tasksary[i]->selected = 0;
ui_drawscreen();
break;
@ -331,7 +334,7 @@ int ui_drawscreen(void)
_("Select task packages to install"));
for (i = _chooserinfo.topindex; i < _chooserinfo.topindex + _chooserinfo.height; i++)
if (i < _taskpackages->count) ui_drawchooseritem(i);
if (i < _tasks->count) ui_drawchooseritem(i);
ui_vscrollbar(_chooserinfo.rowoffset, _chooserinfo.coloffset + _chooserinfo.width - 1, _chooserinfo.height, 0);
@ -549,40 +552,39 @@ void ui_dialog(int row, int col, int height, int width, char *title,
void ui_drawchooseritem(int index)
{
char buf[1024];
ASSERT(_taskpackages != NULL);
if (index >= _taskpackages->count)
DIE("Index out of bounds: %d >= %d", index, _taskpackages->count);
ASSERT(_tasks != NULL);
if (index >= _tasks->count)
DIE("Index out of bounds: %d >= %d", index, _tasks->count);
if (index < _chooserinfo.topindex) return;
SLsmg_set_color(CHOOSEROBJ);
SLsmg_gotorc(_chooserinfo.rowoffset + index - _chooserinfo.topindex,
_chooserinfo.coloffset + 1);
snprintf(buf, 1024, "[%c] %s",
(_taskpackagesary[index]->selected == 0 ? ' ' : '*'),
_taskpackagesary[index]->prettyname);
(_tasksary[index]->selected == 0 ? ' ' : '*'),
_tasksary[index]->prettyname);
/* I fear the 1 below is an off-by-one error somewhere -- Joeyh */
SLsmg_write_nstring(buf, _chooserinfo.width - 1);
SLsmg_gotorc(_chooserinfo.rowoffset + index - _chooserinfo.topindex,
_chooserinfo.coloffset + _taskpackages->maxnamelen + 7);
SLsmg_write_nstring(_taskpackagesary[index]->shortdesc, _chooserinfo.width -
_taskpackages->maxnamelen - 7);
_chooserinfo.coloffset + _tasks->maxnamelen + 7);
SLsmg_write_nstring(TASK_PKG(_tasksary[index], shortdesc, "(no description)"), _chooserinfo.width - _tasks->maxnamelen - 7);
}
void ui_toggleselection(int index)
{
ASSERT(_taskpackages != NULL);
if (index >= _taskpackages->count)
DIE("Index out of bounds: %d >= %d", index, _taskpackages->count);
ASSERT(_tasks != NULL);
if (index >= _tasks->count)
DIE("Index out of bounds: %d >= %d", index, _tasks->count);
if (_taskpackagesary[index]->selected == 0)
_taskpackagesary[index]->selected = 1;
if (_tasksary[index]->selected == 0)
_tasksary[index]->selected = 1;
else
_taskpackagesary[index]->selected = 0;
_tasksary[index]->selected = 0;
SLsmg_set_color(CHOOSEROBJ);
SLsmg_gotorc(_chooserinfo.rowoffset + index - _chooserinfo.topindex, _chooserinfo.coloffset + 1);
if (_taskpackagesary[index]->selected == 0)
if (_tasksary[index]->selected == 0)
SLsmg_write_string("[ ]");
else
SLsmg_write_string("[*]");
@ -596,7 +598,7 @@ void ui_redrawchooser(void)
{
int i;
for (i = _chooserinfo.topindex; i < _chooserinfo.topindex + _chooserinfo.height; i++)
if (i < _taskpackages->count) ui_drawchooseritem(i);
if (i < _tasks->count) ui_drawchooseritem(i);
}
void ui_redrawcursor(int index)
@ -613,10 +615,10 @@ void ui_redrawcursor(int index)
ui_vscrollbar(_chooserinfo.rowoffset, _chooserinfo.coloffset +
_chooserinfo.width - 1, _chooserinfo.height,
((double)index+1)/_taskpackages->count);
((double)index+1)/_tasks->count);
SLsmg_set_color(CURSOROBJ);
SLsmg_gotorc(_chooserinfo.rowoffset + index - _chooserinfo.topindex, _chooserinfo.coloffset + 2);
SLsmg_write_string(_taskpackagesary[index]->selected == 0 ? " " : "*");
SLsmg_write_string(_tasksary[index]->selected == 0 ? " " : "*");
SLsmg_refresh();
}
@ -625,7 +627,7 @@ void ui_clearcursor(int index)
{
SLsmg_set_color(DIALOGOBJ);
SLsmg_gotorc(_chooserinfo.rowoffset + index - _chooserinfo.topindex, _chooserinfo.coloffset + 2);
SLsmg_write_string(_taskpackagesary[index]->selected == 0 ? " " : "*");
SLsmg_write_string(_tasksary[index]->selected == 0 ? " " : "*");
}
void ui_showhelp(void)
@ -647,7 +649,8 @@ void ui_showhelp(void)
void ui_showpackageinfo(void)
{
struct package_t *pkg, *deppkg;
struct package_t *deppkg;
struct task_t *tsk;
int i;
int width = COLUMNS - 10;
char buf[4096];
@ -656,14 +659,14 @@ void ui_showpackageinfo(void)
int bufleft;
int index = _chooserinfo.index;
ASSERT(_taskpackages != NULL);
ASSERT(_tasks != NULL);
_chooserinfo.whichwindow = DESCWINDOW;
if (index >= _taskpackages->count) DIE("Index out of bounds: %d >= %d", index, _taskpackages->count);
if (index >= _tasks->count) DIE("Index out of bounds: %d >= %d", index, _tasks->count);
pkg = _taskpackagesary[index];
ASSERT(pkg != NULL);
tsk = _tasksary[index];
ASSERT(tsk != NULL);
desc = reflowtext(width, pkg->longdesc);
desc = reflowtext(width, TASK_PKG(tsk,longdesc,"(no long description)"));
/* pack buf with package info */
snprintf(buf, sizeof(buf), _("Description:\n%s\n\nDependent packages:\n"), desc);
@ -671,15 +674,15 @@ void ui_showpackageinfo(void)
bufleft = sizeof(buf) - strlen(buf) - 1;
ASSERT(width < sizeof(shortbuf));
for (i = 0; i < pkg->dependscount; i++) {
deppkg = packages_find(_packages, pkg->depends[i]);
snprintf(shortbuf, sizeof(shortbuf), "%s - %s\n", pkg->depends[i],
for (i = 0; i < tsk->packagescount; i++) {
deppkg = packages_find(_packages, tsk->packages[i]);
snprintf(shortbuf, sizeof(shortbuf), "%s - %s\n", tsk->packages[i],
((deppkg && deppkg->shortdesc) ? deppkg->shortdesc : _("(no description available)")));
strncat(buf, shortbuf, bufleft);
bufleft = sizeof(buf) - strlen(buf) - 1;
}
ui_dialog(2, 2, ROWS-4, COLUMNS-4, pkg->name, buf, 0, SCROLLBAR_VERT);
ui_dialog(2, 2, ROWS-4, COLUMNS-4, tsk->name, buf, 0, SCROLLBAR_VERT);
_chooserinfo.whichwindow = CHOOSERWINDOW;
ui_drawscreen();
}

3
slangui.h

@ -3,8 +3,9 @@
#define _SLANGUI_H
struct packages_t;
struct tasks_t;
void ui_init(int argc, char * const argv[], struct packages_t *taskpkgs, struct packages_t *packages);
void ui_init(int argc, char * const argv[], struct tasks_t *tasks, struct packages_t *packages);
int ui_shutdown(void);
int ui_running(void);
void ui_resize(void);

54
tasksel.c

@ -1,4 +1,4 @@
/* $Id: tasksel.c,v 1.9 2000/05/07 22:03:36 polish Exp $ */
/* $Id: tasksel.c,v 1.10 2001/04/24 06:35:07 tausq Exp $ */
#include "tasksel.h"
#include <stdio.h>
@ -39,7 +39,7 @@ void help(void)
exit(0);
}
int doinstall(struct package_t **taskpkglist, int taskpkgcount,
int doinstall(struct task_t **tasklist, int taskcount,
struct package_t **pkglist, int pkgcount,
unsigned char queueinstalls, unsigned char testmode)
{
@ -60,9 +60,15 @@ int doinstall(struct package_t **taskpkglist, int taskpkgcount,
c++;
}
}
for (i = 0; i < taskpkgcount; i++) {
if (taskpkglist[i]->selected > 0) {
fprintf(todpkg, "%s install\n", taskpkglist[i]->name);
for (i = 0; i < taskcount; i++) {
if (tasklist[i]->selected > 0) {
int j;
if (tasklist[i]->task_pkg) {
fprintf(todpkg, "%s install\n", tasklist[i]->task_pkg->name);
}
for (j = 0; j < tasklist[i]->packagescount; j++) {
fprintf(todpkg, "%s install\n", tasklist[i]->packages[j]);
}
c++;
}
}
@ -82,11 +88,18 @@ int doinstall(struct package_t **taskpkglist, int taskpkgcount,
c++;
}
}
for (i = 0; i < taskpkgcount; i++) {
if (taskpkglist[i]->selected > 0) {
for (i = 0; i < taskcount; i++) {
if (tasklist[i]->selected > 0) {
int j;
/* TODO check buffer overflow; not likely, but still... */
strcat(buf, taskpkglist[i]->name);
if (tasklist[i]->task_pkg) {
strcat(buf, tasklist[i]->task_pkg->name);
strcat(buf, " ");
}
for (j = 0; j < tasklist[i]->packagescount; j++) {
strcat(buf, tasklist[i]->packages[j]);
strcat(buf, " ");
}
c++;
}
}
@ -110,8 +123,10 @@ int main(int argc, char * const argv[])
int i, c, r = 0;
unsigned char testmode = 0, queueinstalls = 0, installreqd = 0;
unsigned char installimp = 0, installstd = 0, noninteractive = 0;
struct packages_t taskpkgs, packages;
struct package_t **pkglist, **taskpkglist;
struct packages_t packages;
struct tasks_t tasks;
struct package_t **pkglist;
struct task_t **tasklist;
signal(SIGWINCH, tasksel_signalhandler);
@ -134,23 +149,21 @@ int main(int argc, char * const argv[])
}
}
packages_readlist(&taskpkgs, &packages);
packages_readlist(&tasks, &packages);
if (taskpkgs.count == 0) {
if (tasks.count == 0) {
fprintf(stderr, _("No task packages found on this system.\nDid you update your available file?"));
return 255;
}
if (noninteractive == 0) {
ui_init(argc, argv, &taskpkgs, &packages);
ui_init(argc, argv, &tasks, &packages);
ui_drawscreen();
r = ui_eventloop();
ui_shutdown();
}
taskpkglist = packages_enumerate(&taskpkgs);
pkglist = packages_enumerate(&packages);
if (installreqd || installimp || installstd) {
for (i = 0; i < packages.count; i++) {
if (installreqd && pkglist[i]->priority == PRIORITY_REQUIRED)
@ -162,13 +175,14 @@ int main(int argc, char * const argv[])
}
}
if (r == 0) r = doinstall(taskpkglist, taskpkgs.count,
pkglist,
(installreqd || installimp || installstd
tasklist = tasks_enumerate(&tasks);
if (r == 0) {
r = doinstall(tasklist, tasks.count,
pkglist, (installreqd || installimp || installstd
? packages.count : 0),
queueinstalls, testmode);
packages_free(&taskpkgs, &packages);
}
packages_free(&tasks, &packages);
return r;
}

11
util.c

@ -1,4 +1,4 @@
/* $Id: util.c,v 1.2 1999/11/23 05:39:27 tausq Exp $ */
/* $Id: util.c,v 1.3 2001/04/24 06:35:07 tausq Rel $ */
#include "util.h"
#include <string.h>
@ -39,6 +39,15 @@ void *safe_malloc(int size)
return p;
}
void *safe_realloc(void *x, size_t size)
{
void *p;
p = realloc(x, size);
_num_mallocs++;
if (p == NULL) DIE("Cannot reallocate %d bytes of memory", size);
return p;
}
void safe_free(void **p)
{
if (p == NULL || *p == NULL) {

5
util.h

@ -1,9 +1,12 @@
/* $Id: util.h,v 1.1 1999/11/21 22:01:04 tausq Exp $ */
/* $Id: util.h,v 1.2 2001/04/24 06:35:07 tausq Rel $ */
#ifndef _UTIL_H
#define _UTIL_H
#include <stdlib.h>
char *safe_strdup(const char *);
void *safe_malloc(int);
void *safe_realloc(void *, size_t);
void safe_free(void **);
void memleak_check(void);

Loading…
Cancel
Save