| 1 |
/*
|
| 2 |
Magpie - reference librarian for Debian systems
|
| 3 |
Copyright (C) 2000 Bear Giles <bgiles@coyotesong.com>
|
| 4 |
|
| 5 |
This program is free software; you may redistribute it and/or
|
| 6 |
modify it under the terms of the GNU General Public License
|
| 7 |
as published by the Free Software Foundation; either version 2
|
| 8 |
of the license, or (at your option) any later version.
|
| 9 |
|
| 10 |
This program is distributed in the hope that it will be useful,
|
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 13 |
GNU General Public License for more details.
|
| 14 |
|
| 15 |
You should have received a copy of the GNU General Public License
|
| 16 |
along with this program; if not, write to the Free Software
|
| 17 |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
| 18 |
*/
|
| 19 |
|
| 20 |
static const char rcsid[] = "$Id: mod_texinfo.c,v 1.1.1.1 2003/08/01 00:11:17 djpig-guest Exp $";
|
| 21 |
|
| 22 |
/*****
|
| 23 |
This module kicks out the reference stacks in texinfo format.
|
| 24 |
*****/
|
| 25 |
#include <assert.h>
|
| 26 |
#include <stdio.h>
|
| 27 |
#include <string.h>
|
| 28 |
#include <unistd.h>
|
| 29 |
#include <stdlib.h>
|
| 30 |
#include <ctype.h>
|
| 31 |
#include <sys/wait.h>
|
| 32 |
#include "magpie.h"
|
| 33 |
|
| 34 |
#define OUTPUT_DIR "texi"
|
| 35 |
|
| 36 |
extern int mkdir (const char *, mode_t);
|
| 37 |
|
| 38 |
extern char timestamp[];
|
| 39 |
|
| 40 |
static int cnt_s[CNT_SECTIONS];
|
| 41 |
static int cnt_sc[CNT_SECTIONS][CNT_CATEGORIES];
|
| 42 |
static int cnt_scp[CNT_SECTIONS][CNT_CATEGORIES][CNT_PRIORITIES];
|
| 43 |
|
| 44 |
/*+
|
| 45 |
Comparison function for sorting by section, category, priority,
|
| 46 |
name, version
|
| 47 |
+*/
|
| 48 |
static int cmp_s_c_p (const void *p, const void *q)
|
| 49 |
{
|
| 50 |
struct package_info *pp = *((struct package_info **) p);
|
| 51 |
struct package_info *qq = *((struct package_info **) q);
|
| 52 |
int r;
|
| 53 |
|
| 54 |
assert (pp->name);
|
| 55 |
assert (qq->name);
|
| 56 |
|
| 57 |
r = pp->section - qq->section;
|
| 58 |
if (r)
|
| 59 |
return r;
|
| 60 |
|
| 61 |
r = pp->category - qq->category;
|
| 62 |
if (r)
|
| 63 |
return r;
|
| 64 |
|
| 65 |
r = pp->priority - qq->priority;
|
| 66 |
if (r)
|
| 67 |
return r;
|
| 68 |
|
| 69 |
r = strcoll (pp->name, qq->name);
|
| 70 |
if (r)
|
| 71 |
return r;
|
| 72 |
|
| 73 |
return -strcoll (pp->version, qq->version);
|
| 74 |
}
|
| 75 |
|
| 76 |
/*+
|
| 77 |
Write break in documentation, to make life easy on anyone who has too
|
| 78 |
look at raw text.
|
| 79 |
+*/
|
| 80 |
static void texi_break (FILE *fp)
|
| 81 |
{
|
| 82 |
fputs ("\n", fp);
|
| 83 |
fputs ("@c -----------------------------------------------------\n", fp);
|
| 84 |
fputs ("\n", fp);
|
| 85 |
}
|
| 86 |
|
| 87 |
/*+
|
| 88 |
Write the specified string, quoting any characters that will
|
| 89 |
confuse docbook.
|
| 90 |
+*/
|
| 91 |
static void texi_quote (FILE *fp, const char *s)
|
| 92 |
{
|
| 93 |
char ch;
|
| 94 |
while ((ch = *s++)) {
|
| 95 |
switch (ch) {
|
| 96 |
case '@': fputs ("@@", fp); break;
|
| 97 |
case '{': fputs ("@{", fp); break;
|
| 98 |
case '}': fputs ("@}", fp); break;
|
| 99 |
default: fputc (ch, fp);
|
| 100 |
}
|
| 101 |
}
|
| 102 |
}
|
| 103 |
|
| 104 |
/*+
|
| 105 |
Write a quick reference.
|
| 106 |
+*/
|
| 107 |
static void texi_quickref (FILE *fp, const char *name, const char *value)
|
| 108 |
{
|
| 109 |
fprintf (fp, "\n");
|
| 110 |
fprintf (fp, "@appendixsection Package %s\n\n", name);
|
| 111 |
texi_quote (fp, value);
|
| 112 |
fprintf (fp, "\n");
|
| 113 |
}
|
| 114 |
|
| 115 |
|
| 116 |
/*+
|
| 117 |
Write a quick reference.
|
| 118 |
+*/
|
| 119 |
static void texi_quickref_file (FILE *fp, const char *name, const char *value)
|
| 120 |
{
|
| 121 |
fprintf (fp, "\n");
|
| 122 |
fprintf (fp, "@appendixsection %s\n\n", name);
|
| 123 |
fprintf (fp, "@file{");
|
| 124 |
texi_quote (fp, value);
|
| 125 |
fprintf (fp, "}\n");
|
| 126 |
}
|
| 127 |
|
| 128 |
#if 0
|
| 129 |
/*+
|
| 130 |
Write a quick reference.
|
| 131 |
+*/
|
| 132 |
static void docbook_quickref_d (FILE *fp, const char *name, long value)
|
| 133 |
{
|
| 134 |
fputs ("\n", fp);
|
| 135 |
fputs ("<refsect1>\n", fp);
|
| 136 |
fputs ("<title>\n", fp);
|
| 137 |
docbook_quote (fp, name);
|
| 138 |
fputs ("</title>\n", fp);
|
| 139 |
fputs ("<para>\n", fp);
|
| 140 |
fprintf (fp, "%ld", value);
|
| 141 |
fputs ("</para>\n", fp);
|
| 142 |
fputs ("</refsect1>\n", fp);
|
| 143 |
}
|
| 144 |
#endif
|
| 145 |
|
| 146 |
/*+
|
| 147 |
Write a list of packages. There doesn't appear to be a way to
|
| 148 |
specify 'quiet reference.'
|
| 149 |
+*/
|
| 150 |
static void texi_list (FILE *fp,
|
| 151 |
const char *title, const struct package_list *d)
|
| 152 |
{
|
| 153 |
struct package_info *p;
|
| 154 |
struct package_list *q;
|
| 155 |
|
| 156 |
fputs ("\n", fp);
|
| 157 |
fprintf (fp, "@appendixsection %s\n\n", title);
|
| 158 |
|
| 159 |
fputs ("@itemize @bullet\n", fp);
|
| 160 |
|
| 161 |
while (d) {
|
| 162 |
q = d->down;
|
| 163 |
if (q) {
|
| 164 |
fputs ("@itemize @minus\n", fp);
|
| 165 |
while (q) {
|
| 166 |
fprintf (fp, "@c %s, line %d\n", __FILE__, __LINE__);
|
| 167 |
fputs ("@item\n", fp);
|
| 168 |
p = mp_lookup (q->name);
|
| 169 |
if (p && p->selected) {
|
| 170 |
fprintf (fp, "@ifhtml\n");
|
| 171 |
fprintf (fp, "@ref{%s}\n", q->name);
|
| 172 |
fprintf (fp, "@end ifhtml\n");
|
| 173 |
fprintf (fp, "@ifnothtml\n");
|
| 174 |
fprintf (fp, "@cite{%s}", q->name);
|
| 175 |
fprintf (fp, "@end ifnothtml\n");
|
| 176 |
}
|
| 177 |
else {
|
| 178 |
fprintf (fp, "@cite{%s}", q->name);
|
| 179 |
}
|
| 180 |
if (q->restriction) {
|
| 181 |
fputc (' ', fp);
|
| 182 |
texi_quote (fp, q->restriction);
|
| 183 |
}
|
| 184 |
if (p && (p->installed || p->unpacked)) {
|
| 185 |
fputs (" [", fp);
|
| 186 |
texi_quote (fp, p->version);
|
| 187 |
fputs ("] ", fp);
|
| 188 |
}
|
| 189 |
fputs (" ", fp);
|
| 190 |
if (p && p->summary) {
|
| 191 |
texi_quote (fp, p->summary);
|
| 192 |
}
|
| 193 |
fputs ("\n", fp);
|
| 194 |
if (p && p->selected) {
|
| 195 |
fprintf (fp, "@ifinfo\n");
|
| 196 |
fprintf (fp, "@ref{%s}\n", q->name);
|
| 197 |
fprintf (fp, "@end ifinfo\n");
|
| 198 |
}
|
| 199 |
q = q->down;
|
| 200 |
}
|
| 201 |
fputs ("@end itemize\n", fp);
|
| 202 |
}
|
| 203 |
else {
|
| 204 |
fprintf (fp, "@c %s, line %d\n", __FILE__, __LINE__);
|
| 205 |
fputs ("@item\n", fp);
|
| 206 |
p = mp_lookup (d->name);
|
| 207 |
if (p && p->selected) {
|
| 208 |
fprintf (fp, "@ifhtml\n");
|
| 209 |
fprintf (fp, "@ref{%s}\n", d->name);
|
| 210 |
fprintf (fp, "@end ifhtml\n");
|
| 211 |
fprintf (fp, "@ifnothtml\n");
|
| 212 |
fprintf (fp, "@cite{%s}", d->name);
|
| 213 |
fprintf (fp, "@end ifnothtml\n");
|
| 214 |
}
|
| 215 |
else {
|
| 216 |
fprintf (fp, "@cite{%s}", d->name);
|
| 217 |
}
|
| 218 |
if (d->restriction) {
|
| 219 |
fputc (' ', fp);
|
| 220 |
texi_quote (fp, d->restriction);
|
| 221 |
}
|
| 222 |
fputs (" ", fp);
|
| 223 |
if (p && (p->installed || p->unpacked)) {
|
| 224 |
fputs (" [", fp);
|
| 225 |
texi_quote (fp, p->version);
|
| 226 |
fputs ("] ", fp);
|
| 227 |
}
|
| 228 |
if (p && p->summary) {
|
| 229 |
texi_quote (fp, p->summary);
|
| 230 |
}
|
| 231 |
fputs ("\n", fp);
|
| 232 |
if (p && p->selected) {
|
| 233 |
fprintf (fp, "@ifinfo\n");
|
| 234 |
fprintf (fp, "@ref{%s}\n", d->name);
|
| 235 |
fprintf (fp, "@end ifinfo\n");
|
| 236 |
}
|
| 237 |
}
|
| 238 |
d = d->next;
|
| 239 |
}
|
| 240 |
fputs ("@end itemize\n", fp);
|
| 241 |
}
|
| 242 |
|
| 243 |
|
| 244 |
/*+
|
| 245 |
Write the information about the package in Texinfo format.
|
| 246 |
+*/
|
| 247 |
static int texi_dump_package (
|
| 248 |
struct package_info *p,
|
| 249 |
const char *filename)
|
| 250 |
{
|
| 251 |
FILE *fp;
|
| 252 |
char pathname[256];
|
| 253 |
int i;
|
| 254 |
|
| 255 |
sprintf (pathname, "%s/%s/%s.texi", OUTPUT_DIR, filename, p->name);
|
| 256 |
fp = fopen (pathname, "w");
|
| 257 |
if (!fp) {
|
| 258 |
sprintf (pathname, "fopen (%s/%s/%s.texi)",
|
| 259 |
OUTPUT_DIR, filename, p->name);
|
| 260 |
perror (pathname);
|
| 261 |
return 0;
|
| 262 |
}
|
| 263 |
|
| 264 |
fprintf (fp, "@node %s,,, Appendix\n", p->name);
|
| 265 |
fprintf (fp, "@comment package documentatation\n");
|
| 266 |
fprintf (fp, "\n");
|
| 267 |
|
| 268 |
/* write index information ... */
|
| 269 |
fputs ("@maindex ", fp);
|
| 270 |
texi_quote (fp, p->maintainer);
|
| 271 |
fputs ("\n", fp);
|
| 272 |
if (p->source) {
|
| 273 |
fputs ("@spindex ", fp);
|
| 274 |
texi_quote (fp, p->source->name);
|
| 275 |
fputs ("\n", fp);
|
| 276 |
}
|
| 277 |
// sections[p->section], priorities[p->priority]);
|
| 278 |
|
| 279 |
fputs ("\n", fp);
|
| 280 |
fputs ("@appendix ", fp);
|
| 281 |
texi_quote (fp, p->name);
|
| 282 |
fputs ("\n", fp);
|
| 283 |
|
| 284 |
fputs ("\n", fp);
|
| 285 |
fputs ("@appendixsection Name\n\n", fp);
|
| 286 |
texi_quote (fp, p->name);
|
| 287 |
fputs (" - ", fp);
|
| 288 |
texi_quote (fp, p->summary);
|
| 289 |
fputs ("\n", fp);
|
| 290 |
|
| 291 |
fputs ("\n", fp);
|
| 292 |
fputs ("@appendixsection Description\n\n", fp);
|
| 293 |
for (i = 0; i < p->desccnt; i++) {
|
| 294 |
texi_quote (fp, p->description[i]);
|
| 295 |
fputs ("\n", fp);
|
| 296 |
}
|
| 297 |
fputs ("\n", fp);
|
| 298 |
|
| 299 |
texi_quickref (fp, "Version", p->version);
|
| 300 |
|
| 301 |
texi_quickref (fp, "Maintainer", p->maintainer);
|
| 302 |
|
| 303 |
if (p->predepends)
|
| 304 |
texi_list (fp, "Predepends", p->predepends);
|
| 305 |
|
| 306 |
if (p->depends)
|
| 307 |
texi_list (fp, "Depends", p->depends);
|
| 308 |
|
| 309 |
if (p->r_depends)
|
| 310 |
texi_list (fp, "Required by", p->r_depends);
|
| 311 |
|
| 312 |
if (p->recommends)
|
| 313 |
texi_list (fp, "Recommends", p->recommends);
|
| 314 |
|
| 315 |
if (p->r_recommends)
|
| 316 |
texi_list (fp, "Recommended by", p->r_recommends);
|
| 317 |
|
| 318 |
if (p->suggests)
|
| 319 |
texi_list (fp, "Suggests", p->suggests);
|
| 320 |
|
| 321 |
if (p->r_suggests)
|
| 322 |
texi_list (fp, "Suggested by", p->r_suggests);
|
| 323 |
|
| 324 |
if (p->provides)
|
| 325 |
texi_list (fp, "Provides", p->provides);
|
| 326 |
|
| 327 |
if (p->enhances)
|
| 328 |
texi_list (fp, "Enhances", p->enhances);
|
| 329 |
|
| 330 |
texi_quickref (fp, "Architecture", architectures[p->architecture]);
|
| 331 |
|
| 332 |
if (p->filename)
|
| 333 |
texi_quickref_file (fp, "Filename", p->filename);
|
| 334 |
|
| 335 |
#if 0
|
| 336 |
if (p->size)
|
| 337 |
texi_quickref_d (fp, "Size", p->size);
|
| 338 |
|
| 339 |
if (p->installed_size)
|
| 340 |
docbook_quickref_d (fp, "Size", p->installed_size);
|
| 341 |
#endif
|
| 342 |
|
| 343 |
/* we don't show version info */
|
| 344 |
if (p->source)
|
| 345 |
texi_quickref (fp, "Source", p->source->name);
|
| 346 |
|
| 347 |
if (p->origin)
|
| 348 |
texi_quickref (fp, "Origin", p->origin);
|
| 349 |
|
| 350 |
if (p->bugs)
|
| 351 |
texi_quickref (fp, "Bugs", p->bugs);
|
| 352 |
|
| 353 |
// also status, md5sum
|
| 354 |
fputs ("@page\n", fp);
|
| 355 |
fclose (fp);
|
| 356 |
|
| 357 |
return 1;
|
| 358 |
}
|
| 359 |
|
| 360 |
|
| 361 |
/*+
|
| 362 |
+*/
|
| 363 |
static void texi_group_by_section (FILE *fp)
|
| 364 |
{
|
| 365 |
int sidx, cidx, pidx;
|
| 366 |
int i;
|
| 367 |
struct package_info *p;
|
| 368 |
|
| 369 |
qsort (cache, cachecnt, sizeof cache[0], cmp_s_c_p);
|
| 370 |
|
| 371 |
fprintf (fp, "@node Group by Section,,, Top\n");
|
| 372 |
fprintf (fp, "@chapter Group by Section\n");
|
| 373 |
|
| 374 |
for (sidx = 0; sidx < CNT_SECTIONS; sidx++) {
|
| 375 |
if (cnt_s[sidx] == 0)
|
| 376 |
continue;
|
| 377 |
|
| 378 |
fprintf (fp, "Section '%s' (%d)\n",
|
| 379 |
sections[sidx], cnt_s[sidx]);
|
| 380 |
fprintf (fp, "@itemize @bullet\n");
|
| 381 |
|
| 382 |
for (cidx = 0; cidx < CNT_CATEGORIES; cidx++) {
|
| 383 |
if (cnt_sc[sidx][cidx] == 0)
|
| 384 |
continue;
|
| 385 |
|
| 386 |
fprintf (fp, "Category '%s' (%d)\n",
|
| 387 |
categories[cidx], cnt_sc[sidx][cidx]);
|
| 388 |
fprintf (fp, "@itemize @plus\n");
|
| 389 |
|
| 390 |
for (pidx = 0; pidx < CNT_PRIORITIES; pidx++) {
|
| 391 |
if (cnt_scp[sidx][cidx][pidx] == 0)
|
| 392 |
continue;
|
| 393 |
|
| 394 |
fprintf (fp, "Priority '%s' (%d)\n",
|
| 395 |
priorities[pidx], cnt_scp[sidx][cidx][pidx]);
|
| 396 |
fprintf (fp, "@ifnotinfo\n");
|
| 397 |
fprintf (fp, "@itemize @minus\n");
|
| 398 |
for (i = 0; i < cachecnt; i++) {
|
| 399 |
p = cache[i];
|
| 400 |
if (!p->selected)
|
| 401 |
continue;
|
| 402 |
if (p->section != sidx)
|
| 403 |
continue;
|
| 404 |
if (p->category != cidx)
|
| 405 |
continue;
|
| 406 |
if (p->priority != pidx)
|
| 407 |
continue;
|
| 408 |
|
| 409 |
fprintf (fp, "@cite{%s}: \n", p->name);
|
| 410 |
texi_quote (fp, p->summary);
|
| 411 |
fputs ("\n", fp);
|
| 412 |
}
|
| 413 |
fprintf (fp, "@end itemize\n");
|
| 414 |
fprintf (fp, "@end ifnotinfo\n");
|
| 415 |
|
| 416 |
fprintf (fp, "@ifinfo\n");
|
| 417 |
fprintf (fp, "@menu\n");
|
| 418 |
for (i = 0; i < cachecnt; i++) {
|
| 419 |
p = cache[i];
|
| 420 |
if (!p->selected)
|
| 421 |
continue;
|
| 422 |
if (p->section != sidx)
|
| 423 |
continue;
|
| 424 |
if (p->category != cidx)
|
| 425 |
continue;
|
| 426 |
if (p->priority != pidx)
|
| 427 |
continue;
|
| 428 |
|
| 429 |
fprintf (fp, "* %s:: ", p->name);
|
| 430 |
texi_quote (fp, p->summary);
|
| 431 |
fputs ("\n", fp);
|
| 432 |
}
|
| 433 |
fprintf (fp, "@end menu\n");
|
| 434 |
fprintf (fp, "@end ifinfo\n");
|
| 435 |
fprintf (fp, "\n");
|
| 436 |
}
|
| 437 |
fprintf (fp, "@end itemize\n");
|
| 438 |
}
|
| 439 |
fprintf (fp, "@end itemize\n");
|
| 440 |
}
|
| 441 |
}
|
| 442 |
|
| 443 |
|
| 444 |
/*+
|
| 445 |
Write the information about all selected packages in DocBook format.
|
| 446 |
+*/
|
| 447 |
static int texi_dump (
|
| 448 |
const char *filename,
|
| 449 |
const char *title)
|
| 450 |
{
|
| 451 |
FILE *fp;
|
| 452 |
int i;
|
| 453 |
struct package_info *p;
|
| 454 |
char pathname[256];
|
| 455 |
|
| 456 |
qsort (cache, cachecnt, sizeof cache[0], cmp_s_c_p);
|
| 457 |
|
| 458 |
memset (cnt_s, 0, sizeof cnt_s);
|
| 459 |
memset (cnt_sc, 0, sizeof cnt_sc);
|
| 460 |
memset (cnt_scp, 0, sizeof cnt_scp);
|
| 461 |
|
| 462 |
sprintf (pathname, "%s/%s", OUTPUT_DIR, filename);
|
| 463 |
mkdir (pathname, 0755);
|
| 464 |
|
| 465 |
for (i = 0; i < cachecnt; i++) {
|
| 466 |
p = cache[i];
|
| 467 |
if (!p->selected)
|
| 468 |
continue;
|
| 469 |
|
| 470 |
p->selected = texi_dump_package (p, filename);
|
| 471 |
if (!p->selected)
|
| 472 |
continue;
|
| 473 |
|
| 474 |
cnt_s[p->section]++;
|
| 475 |
cnt_sc[p->section][p->category]++;
|
| 476 |
cnt_scp[p->section][p->category][p->priority]++;
|
| 477 |
}
|
| 478 |
|
| 479 |
sprintf (pathname, "%s/%s.texi", OUTPUT_DIR, filename);
|
| 480 |
fp = fopen (pathname, "w");
|
| 481 |
fprintf (fp, "\
|
| 482 |
\\input texinfo @c -*-texinfo-*-\n\
|
| 483 |
@c %%** start of header\n\
|
| 484 |
@settitle %s\n\
|
| 485 |
@setchapternewpage odd\n\
|
| 486 |
@c %%** end of header\n\
|
| 487 |
\n\
|
| 488 |
@defindex ma\n\
|
| 489 |
@defindex sp\n\
|
| 490 |
\n\
|
| 491 |
@ifinfo\n\
|
| 492 |
This file contains information on software packages\n\
|
| 493 |
\n\
|
| 494 |
This file was automatically generated by magpie.\n\
|
| 495 |
@end ifinfo\n\
|
| 496 |
\n",
|
| 497 |
title);
|
| 498 |
|
| 499 |
fprintf (fp, "\
|
| 500 |
@node Top,,, (dir)\n\
|
| 501 |
@top\n\
|
| 502 |
@menu\n\
|
| 503 |
* Group by Section:: Packages grouped by section\n\
|
| 504 |
* Appendix:: All packages\
|
| 505 |
* Maintainer Index:: Packages listed by maintainer\n\
|
| 506 |
* Source Index:: Packages listed by source\n\
|
| 507 |
@end menu\n");
|
| 508 |
|
| 509 |
fprintf (fp, "\
|
| 510 |
\n\
|
| 511 |
@node Maintainer Index,,, Top\n\
|
| 512 |
@unnumbered Maintainer Index\n\
|
| 513 |
@printindex ma\n\
|
| 514 |
\n\
|
| 515 |
@node Source Index,,, Top\n\
|
| 516 |
@unnumbered Source Index\n\
|
| 517 |
@printindex sp\n\
|
| 518 |
\n");
|
| 519 |
|
| 520 |
texi_break (fp);
|
| 521 |
texi_group_by_section (fp);
|
| 522 |
|
| 523 |
texi_break (fp);
|
| 524 |
fputs ("@node Appendix,,, Top\n", fp);
|
| 525 |
fputs ("@appendix List of all packages\n", fp);
|
| 526 |
fputs ("@menu\n", fp);
|
| 527 |
for (i = 0; i < cachecnt; i++) {
|
| 528 |
p = cache[i];
|
| 529 |
if (p->selected) {
|
| 530 |
fprintf (fp, "* %s:: %s\n", p->name, p->summary);
|
| 531 |
}
|
| 532 |
}
|
| 533 |
fputs ("@end menu\n", fp);
|
| 534 |
|
| 535 |
texi_break (fp);
|
| 536 |
fputs ("@lowersections\n", fp);
|
| 537 |
fputs ("\n", fp);
|
| 538 |
for (i = 0; i < cachecnt; i++) {
|
| 539 |
p = cache[i];
|
| 540 |
if (p->selected) {
|
| 541 |
fprintf (fp, "@include %s/%s.texi\n", filename, p->name);
|
| 542 |
}
|
| 543 |
}
|
| 544 |
fputs ("@raisesections\n", fp);
|
| 545 |
fputs ("\n", fp);
|
| 546 |
|
| 547 |
texi_break (fp);
|
| 548 |
fputs ("\n", fp);
|
| 549 |
fputs ("@contents\n", fp);
|
| 550 |
fputs ("@bye\n", fp);
|
| 551 |
|
| 552 |
fclose (fp);
|
| 553 |
|
| 554 |
return 0;
|
| 555 |
}
|
| 556 |
|
| 557 |
|
| 558 |
static int texi_init (void)
|
| 559 |
{
|
| 560 |
int i;
|
| 561 |
struct package_info *p;
|
| 562 |
|
| 563 |
mkdir (OUTPUT_DIR, 0755);
|
| 564 |
|
| 565 |
/* select all packages */
|
| 566 |
for (i = 0; i < cachecnt; i++)
|
| 567 |
cache[i]->selected = 1;
|
| 568 |
texi_dump ("all", "All Packages");
|
| 569 |
|
| 570 |
/* select installed packages */
|
| 571 |
for (i = 0; i < cachecnt; i++) {
|
| 572 |
p = cache[i];
|
| 573 |
p->selected = p->installed || p->unpacked;
|
| 574 |
}
|
| 575 |
texi_dump ("installed", "Installed Packages");
|
| 576 |
|
| 577 |
/* select single packages */
|
| 578 |
for (i = 0; i < cachecnt; i++) {
|
| 579 |
cache[i]->selected = (i == 0);
|
| 580 |
}
|
| 581 |
texi_dump ("single", "Single Package");
|
| 582 |
|
| 583 |
return 0;
|
| 584 |
}
|
| 585 |
|
| 586 |
struct magpie_module mod_texinfo = {
|
| 587 |
version : MAGPIE_VERSION,
|
| 588 |
description : "Texinfo module",
|
| 589 |
init : texi_init
|
| 590 |
};
|