mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-21 00:07:36 +08:00
* Makefile.in: Throughout use parenthesis instead of braces where
appropriate. (DBXDIRS): Remove. (XSLTPROC): Define for symmetry. Use throughout. (clean): Drop removing cygwin-api.xml and doctool.*. (cygwin-api.xml): Drop rule. (doctool): Drop rule. (Makefile.dep): Add dependency to cygwin-api.xml. * cygwin-api.in.xml: Rename to cygwin-api.xml. Convert includes to XML XInclude style. * doctool.c: Remove. * doctool.txt: Remove. * faq-programming.xml: Drop reference to local utils.xml file. * path.xml: Moved from ../cygwin and converted to XML. * posix.xml: Ditto. * using.xml: Drop relative path from utils.xml include. * utils.xml: Moved from ../utils.
This commit is contained in:
parent
fbf2e44799
commit
6b31215816
@ -1,3 +1,23 @@
|
||||
2014-08-14 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* Makefile.in: Throughout use parenthesis instead of braces where
|
||||
appropriate.
|
||||
(DBXDIRS): Remove.
|
||||
(XSLTPROC): Define for symmetry. Use throughout.
|
||||
(clean): Drop removing cygwin-api.xml and doctool.*.
|
||||
(cygwin-api.xml): Drop rule.
|
||||
(doctool): Drop rule.
|
||||
(Makefile.dep): Add dependency to cygwin-api.xml.
|
||||
* cygwin-api.in.xml: Rename to cygwin-api.xml. Convert includes to
|
||||
XML XInclude style.
|
||||
* doctool.c: Remove.
|
||||
* doctool.txt: Remove.
|
||||
* faq-programming.xml: Drop reference to local utils.xml file.
|
||||
* path.xml: Moved from ../cygwin and converted to XML.
|
||||
* posix.xml: Ditto.
|
||||
* using.xml: Drop relative path from utils.xml include.
|
||||
* utils.xml: Moved from ../utils.
|
||||
|
||||
2014-08-13 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* new-features.xml: (ov-new1.7.33): Add new section.
|
||||
|
@ -12,16 +12,15 @@ SHELL = @SHELL@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
DBXDIRS = -d $(srcdir) -d $(srcdir)/../utils -d $(srcdir)/../cygwin
|
||||
|
||||
CC:=@CC@
|
||||
CC_FOR_TARGET:=@CC@
|
||||
|
||||
XSLTPROC:=xsltproc --xinclude
|
||||
XMLTO:=xmlto --skip-validation --with-dblatex
|
||||
|
||||
include $(srcdir)/../Makefile.common
|
||||
|
||||
FAQ_SOURCES:= $(wildcard ${srcdir}/faq*.xml)
|
||||
FAQ_SOURCES:= $(wildcard $(srcdir)/faq*.xml)
|
||||
|
||||
.SUFFIXES: .html .body
|
||||
|
||||
@ -36,46 +35,38 @@ all: Makefile Makefile.dep \
|
||||
cygwin-ug-net/cygwin-ug-net.pdf \
|
||||
cygwin-api/cygwin-api.pdf
|
||||
|
||||
Makefile: ${srcdir}/Makefile.in
|
||||
Makefile: $(srcdir)/Makefile.in
|
||||
/bin/sh ./config.status
|
||||
|
||||
clean:
|
||||
rm -f Makefile.dep
|
||||
rm -f doctool.exe doctool.o
|
||||
rm -f cygwin-api.xml
|
||||
rm -f *.html *.html.gz
|
||||
rm -Rf cygwin-api cygwin-ug cygwin-ug-net faq
|
||||
|
||||
install: all
|
||||
|
||||
cygwin-ug-net/cygwin-ug-net-nochunks.html.gz : cygwin-ug-net.xml
|
||||
-${XMLTO} html-nochunks -m $(srcdir)/cygwin.xsl $<
|
||||
-$(XMLTO) html-nochunks -m $(srcdir)/cygwin.xsl $<
|
||||
-cp cygwin-ug-net.html cygwin-ug-net/cygwin-ug-net-nochunks.html
|
||||
-rm -f cygwin-ug-net/cygwin-ug-net-nochunks.html.gz
|
||||
-gzip cygwin-ug-net/cygwin-ug-net-nochunks.html
|
||||
|
||||
cygwin-ug-net/cygwin-ug-net.html : cygwin-ug-net.xml cygwin.xsl
|
||||
-${XMLTO} html -o cygwin-ug-net/ -m $(srcdir)/cygwin.xsl $<
|
||||
-$(XMLTO) html -o cygwin-ug-net/ -m $(srcdir)/cygwin.xsl $<
|
||||
|
||||
cygwin-ug-net/cygwin-ug-net.pdf : cygwin-ug-net.xml fo.xsl
|
||||
-xsltproc --xinclude $(srcdir)/fo.xsl $< | fop -q -fo - $@
|
||||
-$(XSLTPROC) $(srcdir)/fo.xsl $< | fop -q -fo - $@
|
||||
|
||||
cygwin-api/cygwin-api.html : cygwin-api.xml cygwin.xsl
|
||||
-${XMLTO} html -o cygwin-api/ -m $(srcdir)/cygwin.xsl $<
|
||||
-$(XMLTO) html -o cygwin-api/ -m $(srcdir)/cygwin.xsl $<
|
||||
|
||||
cygwin-api/cygwin-api.pdf : cygwin-api.xml fo.xsl
|
||||
-xsltproc --xinclude $(srcdir)/fo.xsl $< | fop -q -fo - $@
|
||||
|
||||
cygwin-api.xml : cygwin-api.in.xml doctool Makefile.in
|
||||
-./doctool -m $(DBXDIRS) -s $(srcdir) -o $@ $<
|
||||
-$(XSLTPROC) $(srcdir)/fo.xsl $< | fop -q -fo - $@
|
||||
|
||||
faq/faq.html : $(FAQ_SOURCES)
|
||||
-${XMLTO} html -o faq -m $(srcdir)/cygwin.xsl $(srcdir)/faq.xml
|
||||
-$(XMLTO) html -o faq -m $(srcdir)/cygwin.xsl $(srcdir)/faq.xml
|
||||
-sed -i 's;</a><a name="id[0-9]*"></a>;</a>;g' faq/faq.html
|
||||
|
||||
doctool : doctool.c
|
||||
gcc -g $< -o $@
|
||||
|
||||
TBFILES = cygwin-ug-net.dvi cygwin-ug-net.rtf cygwin-ug-net.ps \
|
||||
cygwin-ug-net.pdf cygwin-ug-net.xml \
|
||||
cygwin-api.dvi cygwin-api.rtf cygwin-api.ps \
|
||||
@ -87,7 +78,7 @@ tarball : cygwin-docs.tar.bz2
|
||||
cygwin-docs.tar.bz2 : $(TBFILES) $(TBDEPS)
|
||||
find $(TBFILES) $(TBDIRS) \! -type d | sort | tar -T - -cf - | bzip2 > cygwin-docs.tar.bz2
|
||||
|
||||
Makefile.dep: cygwin-ug-net.xml
|
||||
Makefile.dep: cygwin-ug-net.xml cygwin-api.xml
|
||||
cd $(srcdir) && ./xidepend $^ > "${CURDIR}/$@"
|
||||
|
||||
-include Makefile.dep
|
||||
|
@ -1,34 +0,0 @@
|
||||
<?xml version="1.0" encoding='UTF-8'?>
|
||||
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V4.5//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
||||
|
||||
<book id="cygwin-api" xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
|
||||
<bookinfo>
|
||||
<date>1998-08-31</date>
|
||||
<title>Cygwin API Reference</title>
|
||||
DOCTOOL-INSERT-legal
|
||||
</bookinfo>
|
||||
|
||||
<toc></toc>
|
||||
|
||||
<chapter id="compatibility"><title>Compatibility</title>
|
||||
DOCTOOL-INSERT-std-susv4
|
||||
DOCTOOL-INSERT-std-bsd
|
||||
DOCTOOL-INSERT-std-gnu
|
||||
DOCTOOL-INSERT-std-solaris
|
||||
DOCTOOL-INSERT-std-deprec
|
||||
DOCTOOL-INSERT-std-notimpl
|
||||
DOCTOOL-INSERT-std-notes
|
||||
</chapter>
|
||||
|
||||
<chapter id="cygwin-functions"><title>Cygwin Functions</title>
|
||||
|
||||
<para>These functions are specific to Cygwin itself, and probably
|
||||
won't be found anywhere else. </para>
|
||||
|
||||
DOCTOOL-INSERT-func-
|
||||
|
||||
</chapter>
|
||||
|
||||
</book>
|
18
winsup/doc/cygwin-api.xml
Normal file
18
winsup/doc/cygwin-api.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding='UTF-8'?>
|
||||
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V4.5//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
||||
|
||||
<book id="cygwin-api" xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
|
||||
<bookinfo>
|
||||
<date>1998-08-31</date>
|
||||
<title>Cygwin API Reference</title>
|
||||
<xi:include href="legal.xml"/>
|
||||
</bookinfo>
|
||||
|
||||
<toc></toc>
|
||||
|
||||
<xi:include href="posix.xml"/>
|
||||
<xi:include href="path.xml"/>
|
||||
|
||||
</book>
|
@ -1,622 +0,0 @@
|
||||
/* doctool.c
|
||||
|
||||
Copyright 1998,1999,2000,2001,2006 Red Hat, Inc.
|
||||
|
||||
This file is part of Cygwin.
|
||||
|
||||
This software is a copyrighted work licensed under the terms of the
|
||||
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
||||
details. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <utime.h>
|
||||
|
||||
/* Building native in a cross-built directory is tricky. Be careful,
|
||||
and beware that you don't have the full portability stuff available to
|
||||
you (like libiberty) */
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* The list of extensions that may contain SGML snippets. We check
|
||||
both cases in case the file system isn't case sensitive enough. */
|
||||
|
||||
struct {
|
||||
char *upper;
|
||||
char *lower;
|
||||
int is_sgml;
|
||||
} extensions[] = {
|
||||
{ ".C", ".c", 0 },
|
||||
{ ".CC", ".cc", 0 },
|
||||
{ ".H", ".h", 0 },
|
||||
{ ".SGML", ".sgml", 1 },
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void
|
||||
show_help()
|
||||
{
|
||||
printf("Usage: doctool [-m] [-i] [-d dir] [-o outfile] [-s prefix] \\\n");
|
||||
printf(" [-b book_id] infile\n");
|
||||
printf(" -m means to adjust Makefile to include new dependencies\n");
|
||||
printf(" -i means to include internal snippets\n");
|
||||
printf(" -d means to recursively scan directory for snippets\n");
|
||||
printf(" -o means to output to file (else stdout)\n");
|
||||
printf(" -s means to suppress source dir prefix\n");
|
||||
printf(" -b means to change the <book id=\"book_id\">\n");
|
||||
printf("\n");
|
||||
printf("doctool looks for DOCTOOL-START and DOCTOOL-END lines in source,\n");
|
||||
printf("saves <foo id=\"bar\"> blocks, and looks for DOCTOOL-INSERT-bar\n");
|
||||
printf("commands to insert selected sections. IDs starting with int-\n");
|
||||
printf("are internal only, add- are added at the end of relevant sections\n");
|
||||
printf("or add-int- for both. Inserted sections are chosen by prefix,\n");
|
||||
printf("and sorted when inserted.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct Section {
|
||||
struct Section *next;
|
||||
struct OneFile *file;
|
||||
char *name;
|
||||
char internal;
|
||||
char addend;
|
||||
char used;
|
||||
char **lines;
|
||||
int num_lines;
|
||||
int max_lines;
|
||||
} Section;
|
||||
|
||||
typedef struct OneFile {
|
||||
struct OneFile *next;
|
||||
char *filename;
|
||||
int enable_scan;
|
||||
int used;
|
||||
Section *sections;
|
||||
} OneFile;
|
||||
|
||||
OneFile *file_list = 0;
|
||||
|
||||
char *output_name = 0;
|
||||
FILE *output_file = 0;
|
||||
|
||||
char *source_dir_prefix = "";
|
||||
char *book_id = 0;
|
||||
|
||||
int internal_flag = 0;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
char *
|
||||
has_string(char *line, char *string)
|
||||
{
|
||||
int i;
|
||||
while (*line)
|
||||
{
|
||||
for (i=0; line[i]; i++)
|
||||
{
|
||||
if (!string[i])
|
||||
return line;
|
||||
if (line[i] != string[i])
|
||||
break;
|
||||
}
|
||||
line++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
starts_with(char *line, char *string)
|
||||
{
|
||||
int i=0;
|
||||
while (1)
|
||||
{
|
||||
if (!string[i])
|
||||
return 1;
|
||||
if (!line[i] || line[i] != string[i])
|
||||
return 0;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifdef S_ISLNK
|
||||
#define STAT lstat
|
||||
#else
|
||||
#define STAT stat
|
||||
#endif
|
||||
|
||||
void
|
||||
scan_directory(dirname)
|
||||
char *dirname;
|
||||
{
|
||||
struct stat st;
|
||||
char *name;
|
||||
struct dirent *de;
|
||||
DIR *dir = opendir(dirname);
|
||||
if (!dir)
|
||||
return;
|
||||
while (de = readdir(dir))
|
||||
{
|
||||
if (strcmp(de->d_name, ".") == 0
|
||||
|| strcmp(de->d_name, "..") == 0)
|
||||
continue;
|
||||
|
||||
name = (char *)malloc(strlen(dirname)+strlen(de->d_name)+3);
|
||||
strcpy(name, dirname);
|
||||
strcat(name, "/");
|
||||
strcat(name, de->d_name);
|
||||
|
||||
STAT(name, &st);
|
||||
|
||||
if (S_ISDIR(st.st_mode) && strcmp(de->d_name, "CVS") != 0)
|
||||
{
|
||||
scan_directory(name);
|
||||
}
|
||||
|
||||
else if (S_ISREG(st.st_mode))
|
||||
{
|
||||
char *dot = strrchr(de->d_name, '.');
|
||||
int i;
|
||||
|
||||
if (dot)
|
||||
{
|
||||
for (i=0; extensions[i].upper; i++)
|
||||
if (strcmp(dot, extensions[i].upper) == 0
|
||||
|| strcmp(dot, extensions[i].lower) == 0)
|
||||
{
|
||||
OneFile *one = (OneFile *)malloc(sizeof(OneFile));
|
||||
one->next = file_list;
|
||||
file_list = one;
|
||||
one->filename = name;
|
||||
one->enable_scan = ! extensions[i].is_sgml;
|
||||
one->used = 0;
|
||||
one->sections = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir (dir);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void
|
||||
scan_file(OneFile *one)
|
||||
{
|
||||
FILE *f = fopen(one->filename, "r");
|
||||
int enabled = ! one->enable_scan;
|
||||
char line[1000], *tag=0, *id=0, *tmp;
|
||||
int taglen = 0;
|
||||
Section *section = 0;
|
||||
Section **prev_section_ptr = &(one->sections);
|
||||
|
||||
if (!f)
|
||||
{
|
||||
perror(one->filename);
|
||||
return;
|
||||
}
|
||||
|
||||
while (fgets(line, 1000, f))
|
||||
{
|
||||
if (one->enable_scan)
|
||||
{
|
||||
/* source files have comment-embedded docs, check for them */
|
||||
if (has_string(line, "DOCTOOL-START"))
|
||||
enabled = 1;
|
||||
if (has_string(line, "DOCTOOL-END"))
|
||||
enabled = 0;
|
||||
}
|
||||
if (!enabled)
|
||||
continue;
|
||||
|
||||
/* DOCTOOL-START
|
||||
|
||||
<sect1 id="dt-tags">
|
||||
this is the doctool tags section.
|
||||
</sect1>
|
||||
|
||||
DOCTOOL-END */
|
||||
|
||||
if (!tag && line[0] == '<')
|
||||
{
|
||||
tag = (char *)malloc(strlen(line)+1);
|
||||
id = (char *)malloc(strlen(line)+1);
|
||||
if (sscanf(line, "<%s id=\"%[^\"]\">", tag, id) == 2)
|
||||
{
|
||||
if (strcmp(tag, "book") == 0 || strcmp(tag, "BOOK") == 0)
|
||||
{
|
||||
/* Don't want to "scan" these */
|
||||
return;
|
||||
}
|
||||
taglen = strlen(tag);
|
||||
section = (Section *)malloc(sizeof(Section));
|
||||
/* We want chunks within single files to appear in that order */
|
||||
section->next = 0;
|
||||
section->file = one;
|
||||
*prev_section_ptr = section;
|
||||
prev_section_ptr = &(section->next);
|
||||
section->internal = 0;
|
||||
section->addend = 0;
|
||||
section->used = 0;
|
||||
section->name = id;
|
||||
if (starts_with(section->name, "add-"))
|
||||
{
|
||||
section->addend = 1;
|
||||
section->name += 4;
|
||||
}
|
||||
if (starts_with(section->name, "int-"))
|
||||
{
|
||||
section->internal = 1;
|
||||
section->name += 4;
|
||||
}
|
||||
section->lines = (char **)malloc(10*sizeof(char *));
|
||||
section->num_lines = 0;
|
||||
section->max_lines = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
free(tag);
|
||||
free(id);
|
||||
tag = id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (tag && section)
|
||||
{
|
||||
if (section->num_lines >= section->max_lines)
|
||||
{
|
||||
section->max_lines += 10;
|
||||
section->lines = (char **)realloc(section->lines,
|
||||
section->max_lines * sizeof (char *));
|
||||
}
|
||||
section->lines[section->num_lines] = (char *)malloc(strlen(line)+1);
|
||||
strcpy(section->lines[section->num_lines], line);
|
||||
section->num_lines++;
|
||||
|
||||
if (line[0] == '<' && line[1] == '/'
|
||||
&& memcmp(line+2, tag, taglen) == 0
|
||||
&& (isspace(line[2+taglen]) || line[2+taglen] == '>'))
|
||||
{
|
||||
/* last line! */
|
||||
tag = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
Section **
|
||||
enumerate_matching_sections(char *name_prefix, int internal, int addend, int *count_ret)
|
||||
{
|
||||
Section **rv = (Section **)malloc(12*sizeof(Section *));
|
||||
int count = 0, max=10, prefix_len = strlen(name_prefix);
|
||||
OneFile *one;
|
||||
int wildcard = 0;
|
||||
|
||||
if (name_prefix[strlen(name_prefix)-1] == '-')
|
||||
wildcard = 1;
|
||||
|
||||
for (one=file_list; one; one=one->next)
|
||||
{
|
||||
Section *s;
|
||||
for (s=one->sections; s; s=s->next)
|
||||
{
|
||||
int matches = 0;
|
||||
if (wildcard)
|
||||
{
|
||||
if (starts_with(s->name, name_prefix))
|
||||
matches = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strcmp(s->name, name_prefix) == 0)
|
||||
matches = 1;
|
||||
}
|
||||
if (s->internal <= internal
|
||||
&& s->addend == addend
|
||||
&& matches
|
||||
&& ! s->used)
|
||||
{
|
||||
s->used = 1;
|
||||
if (count >= max)
|
||||
{
|
||||
max += 10;
|
||||
rv = (Section **)realloc(rv, max*sizeof(Section *));
|
||||
}
|
||||
rv[count++] = s;
|
||||
rv[count] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count_ret)
|
||||
*count_ret = count;
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define ID_CHARS "~@$%&()_-+[]{}:."
|
||||
|
||||
void include_section(char *name, int addend);
|
||||
|
||||
char *
|
||||
unprefix(char *fn)
|
||||
{
|
||||
int l = strlen(source_dir_prefix);
|
||||
if (memcmp(fn, source_dir_prefix, l) == 0)
|
||||
{
|
||||
fn += l;
|
||||
while (*fn == '/' || *fn == '\\')
|
||||
fn++;
|
||||
return fn;
|
||||
}
|
||||
return fn;
|
||||
}
|
||||
|
||||
void
|
||||
parse_line(char *line, char *filename)
|
||||
{
|
||||
char *cmd = has_string(line, "DOCTOOL-INSERT-");
|
||||
char *sname, *send, *id, *save;
|
||||
if (!cmd)
|
||||
{
|
||||
if (book_id
|
||||
&& (starts_with(line, "<book") || starts_with(line, "<BOOK")))
|
||||
{
|
||||
cmd = strchr(line, '>');
|
||||
if (cmd)
|
||||
{
|
||||
cmd++;
|
||||
fprintf(output_file, "<book id=\"%s\">", book_id);
|
||||
fputs(cmd, output_file);
|
||||
return;
|
||||
}
|
||||
}
|
||||
fputs(line, output_file);
|
||||
return;
|
||||
}
|
||||
if (cmd != line)
|
||||
fwrite(line, cmd-line, 1, output_file);
|
||||
save = (char *)malloc(strlen(line)+1);
|
||||
strcpy(save, line);
|
||||
line = save;
|
||||
|
||||
sname = cmd + 15; /* strlen("DOCTOOL-INSERT-") */
|
||||
for (send = sname;
|
||||
*send && isalnum(*send) || strchr(ID_CHARS, *send);
|
||||
send++);
|
||||
id = (char *)malloc(send-sname+2);
|
||||
memcpy(id, sname, send-sname);
|
||||
id[send-sname] = 0;
|
||||
include_section(id, 0);
|
||||
|
||||
fprintf(output_file, "<!-- %s -->\n", unprefix(filename));
|
||||
|
||||
fputs(send, output_file);
|
||||
free(save);
|
||||
}
|
||||
|
||||
int
|
||||
section_sort(const void *va, const void *vb)
|
||||
{
|
||||
Section *a = *(Section **)va;
|
||||
Section *b = *(Section **)vb;
|
||||
int rv = strcmp(a->name, b->name);
|
||||
if (rv)
|
||||
return rv;
|
||||
return a->internal - b->internal;
|
||||
}
|
||||
|
||||
void
|
||||
include_section(char *name, int addend)
|
||||
{
|
||||
Section **sections, *s;
|
||||
int count, i, l;
|
||||
|
||||
sections = enumerate_matching_sections(name, internal_flag, addend, &count);
|
||||
|
||||
qsort(sections, count, sizeof(sections[0]), section_sort);
|
||||
for (i=0; i<count; i++)
|
||||
{
|
||||
s = sections[i];
|
||||
s->file->used = 1;
|
||||
fprintf(output_file, "<!-- %s -->\n", unprefix(s->file->filename));
|
||||
for (l=addend; l<s->num_lines-1; l++)
|
||||
parse_line(s->lines[l], s->file->filename);
|
||||
if (!addend)
|
||||
{
|
||||
include_section(s->name, 1);
|
||||
parse_line(s->lines[l], s->file->filename);
|
||||
}
|
||||
}
|
||||
|
||||
free(sections);
|
||||
}
|
||||
|
||||
void
|
||||
parse_sgml(FILE *in, char *input_name)
|
||||
{
|
||||
static char line[1000];
|
||||
while (fgets(line, 1000, in))
|
||||
{
|
||||
parse_line(line, input_name);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void
|
||||
fix_makefile(char *output_name)
|
||||
{
|
||||
FILE *in, *out;
|
||||
char line[1000];
|
||||
int oname_len = strlen(output_name);
|
||||
OneFile *one;
|
||||
int used_something = 0;
|
||||
struct stat st;
|
||||
struct utimbuf times;
|
||||
|
||||
stat("Makefile", &st);
|
||||
|
||||
in = fopen("Makefile", "r");
|
||||
if (!in)
|
||||
{
|
||||
perror("Makefile");
|
||||
return;
|
||||
}
|
||||
|
||||
out = fopen("Makefile.new", "w");
|
||||
if (!out)
|
||||
{
|
||||
perror("Makefile.new");
|
||||
return;
|
||||
}
|
||||
|
||||
while (fgets(line, 1000, in))
|
||||
{
|
||||
if (starts_with(line, output_name)
|
||||
&& strcmp(line+oname_len, ": \\\n") == 0)
|
||||
{
|
||||
/* this is the old dependency */
|
||||
while (fgets(line, 1000, in))
|
||||
{
|
||||
if (strcmp(line+strlen(line)-2, "\\\n"))
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
fputs(line, out);
|
||||
}
|
||||
fclose(in);
|
||||
|
||||
for (one=file_list; one; one=one->next)
|
||||
if (one->used)
|
||||
{
|
||||
used_something = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (used_something)
|
||||
{
|
||||
fprintf(out, "%s:", output_name);
|
||||
for (one=file_list; one; one=one->next)
|
||||
if (one->used)
|
||||
fprintf(out, " \\\n\t%s", one->filename);
|
||||
fprintf(out, "\n");
|
||||
}
|
||||
|
||||
fclose(out);
|
||||
|
||||
times.actime = st.st_atime;
|
||||
times.modtime = st.st_mtime;
|
||||
utime("Makefile.new", ×);
|
||||
|
||||
if (rename("Makefile", "Makefile.old"))
|
||||
return;
|
||||
if (rename("Makefile.new", "Makefile"))
|
||||
rename("Makefile.old", "Makefile");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int i;
|
||||
OneFile *one;
|
||||
FILE *input_file;
|
||||
int fix_makefile_flag = 0;
|
||||
|
||||
while (argc > 1 && argv[1][0] == '-')
|
||||
{
|
||||
if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0)
|
||||
{
|
||||
show_help();
|
||||
}
|
||||
else if (strcmp(argv[1], "-i") == 0)
|
||||
{
|
||||
internal_flag = 1;
|
||||
}
|
||||
else if (strcmp(argv[1], "-m") == 0)
|
||||
{
|
||||
fix_makefile_flag = 1;
|
||||
}
|
||||
else if (strcmp(argv[1], "-d") == 0 && argc > 2)
|
||||
{
|
||||
scan_directory(argv[2]);
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
else if (strcmp(argv[1], "-o") == 0 && argc > 2)
|
||||
{
|
||||
output_name = argv[2];
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
else if (strcmp(argv[1], "-s") == 0 && argc > 2)
|
||||
{
|
||||
source_dir_prefix = argv[2];
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
else if (strcmp(argv[1], "-b") == 0 && argc > 2)
|
||||
{
|
||||
book_id = argv[2];
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
for (one=file_list; one; one=one->next)
|
||||
{
|
||||
scan_file(one);
|
||||
}
|
||||
|
||||
input_file = fopen(argv[1], "r");
|
||||
if (!input_file)
|
||||
{
|
||||
perror(argv[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (output_name)
|
||||
{
|
||||
output_file = fopen(output_name, "w");
|
||||
if (!output_file)
|
||||
{
|
||||
perror(output_name);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
output_file = stdout;
|
||||
output_name = "<stdout>";
|
||||
}
|
||||
|
||||
parse_sgml(input_file, argv[1]);
|
||||
|
||||
if (output_file != stdout)
|
||||
fclose(output_file);
|
||||
|
||||
if (fix_makefile_flag)
|
||||
fix_makefile(output_name);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,146 +0,0 @@
|
||||
Doctool
|
||||
|
||||
DJ Delorie <dj@cygnus.com>
|
||||
|
||||
These are the instructions for using doctool. Yes, I should have
|
||||
written them *in* DocBook, but hey, I was in a hurry.
|
||||
|
||||
OK, doctool is a program that gathers snippets of a docbook document and
|
||||
puts them all together in the right order. There are three
|
||||
places that it gets snippets from:
|
||||
|
||||
1. The document that you tell it you want "finished"
|
||||
|
||||
2. blocks of SGML in *.sgml files
|
||||
|
||||
3. comments in source code
|
||||
|
||||
The first of these is the template file, which is to say, it's a
|
||||
normal SGML file (sort of). This file is the first one read, and
|
||||
includes such things as your <book> tags etc. It contains commands to
|
||||
doctool to tell it where to put the other parts.
|
||||
|
||||
The second, the *.sgml files, contain one or more blocks of SGML.
|
||||
To work with doctool, each of these snippets must begin and end
|
||||
with matching tags, must have an id="" attribute, and the start/end
|
||||
tags must begin at the beginning of the line. For example:
|
||||
|
||||
<foo id="frob-45">
|
||||
stuff goes here
|
||||
</foo>
|
||||
<bar id="frob-48">
|
||||
stuff goes here
|
||||
</bar>
|
||||
|
||||
In this example, the file contains two snippets, one marked by "foo"
|
||||
and one barked by "bar", with id's "from-45" and "from-48". Note that
|
||||
I made up the foo and bar tags. You'd usually use a <sect1> tag or
|
||||
something useful like that. Stuff outside the blocks is ignored.
|
||||
|
||||
The third is simply an encapsulation of the second in comments, like this:
|
||||
|
||||
/* DOCTOOL-START
|
||||
<foo id="frob-45">
|
||||
stuff goes here
|
||||
</foo>
|
||||
DOCTOOL-END */
|
||||
|
||||
The DOCTOOL-START and DOCTOOL-END things are special. Doctool uses
|
||||
those to know which parts of which comments are useful, and which
|
||||
parts are the useless source code stuff ;-)
|
||||
|
||||
|
||||
OK, so now we've got all these snippets of SGML floating around. What
|
||||
do we do with them? Well, inside the template document (#1 in our
|
||||
list up there) you'd put text snippets that said "ok, put them
|
||||
here". Each text snippet looks like this:
|
||||
|
||||
DOCTOOL-INSERT-frob-
|
||||
|
||||
Note that the "frob-" part tells doctool to pull in all the snippets
|
||||
with IDs that start with "frob-", in alphabetical (well, asciibetical
|
||||
at the moment) order. So, by saying "DOCTOOL-INSERT-frob-" you'd get
|
||||
all the "frob-*" snippets, like "frob-45" and "frob-48".
|
||||
|
||||
If you just said DOCTOOL-INSERT-frob, it inserts the snippet named
|
||||
"frob" and no others.
|
||||
|
||||
Note that no snippet will ever be inserted more than once, no matter
|
||||
how many DOCTOOL-INSERTs you have.
|
||||
|
||||
There's two other tricks doctool has. If it finds a snippet with an ID
|
||||
like "int-*" (i.e. int-frob-45) that means that snippet of documentation
|
||||
is for the "internal" version only. The "int-" is discarded, and if
|
||||
the -i option is given to doctool, this snippet is treated as if the
|
||||
int- wasn't there. Without the -i, the int-* snippets are ignored
|
||||
completely.
|
||||
|
||||
If a snippet has "add-" on it, like "add-frob-45", that's an addendum.
|
||||
Each time a snippet named without the add- is found, doctool looks for
|
||||
an addendum with exactly that same name (i.e. frob-45 looks for
|
||||
add-frob-45). If it finds any, it puts them just before the last line
|
||||
of the non-add snippet (so that it's *inside* the main snippet's
|
||||
block, not after it). Example:
|
||||
|
||||
<sect1 id="frob-45">
|
||||
some text
|
||||
</sect1>
|
||||
<sect1 id="add-frob-45">
|
||||
more text
|
||||
</sect1>
|
||||
|
||||
This would yield:
|
||||
|
||||
<sect1 id="frob-45">
|
||||
some text
|
||||
more text
|
||||
</sect1>
|
||||
|
||||
You should use the same outermost tags as the main snippet, but only
|
||||
because it sets the proper nesting rules for what's enclosed.
|
||||
|
||||
You can use add- and int- at the same time, but always do add-int- and
|
||||
not int-add- (i.e. "add-int-frob-45").
|
||||
|
||||
|
||||
OK, now for doctool command line options.
|
||||
|
||||
-m tells doctool to "fix" the Makefile (not makefile) to include the
|
||||
extra dependencies needed by the file you're generating. You need to
|
||||
manually include dependencies on the Makefile itself and the template
|
||||
file; doctool only includes the snippet files (sources etc) that it
|
||||
actually pulled content from. Note: this isn't perfect! Someone can
|
||||
come along and add a new snippet to a source file, and doctool would
|
||||
never know. Sometimes, it's best to just rebuild the docs all the
|
||||
time.
|
||||
|
||||
-i means to include snippets with the "int-" prefix on their IDs. Use
|
||||
with -b to make internal and public versions from the same sources.
|
||||
|
||||
"-d dir" tells doctool to scan all the files in that directory (and
|
||||
subdirectories, recursively) for files that might contain snippets of
|
||||
SGML. These include *.c, *.cc, *.h, and *.sgml. The idea is that
|
||||
most of the documentation would be in a *.sgml file named after the
|
||||
source (i.e. foo.c -> foo.sgml) but some commentary within the source
|
||||
might be useful in the docs as well. SGML files (*.sgml) do not need
|
||||
the DOCTOOL-START/END tags but the others do.
|
||||
|
||||
-o sets the output file. Without -o, the file goes to stdout (ick).
|
||||
|
||||
-s tells doctool to supress a "source directory prefix". What this
|
||||
means is that, in the generated output doctool puts comments that say
|
||||
where each snippet comes from (for debugging), which includes the full
|
||||
path sometimes, but if you use -s, you can tell doctool to cut off
|
||||
that prefix. For example,
|
||||
/usr/people/dj/src/cygnus/latest/devo/winsup/foo.c might get shortened
|
||||
to winsup/foo.c if you gave "-s
|
||||
/usr/people/dj/src/cygnus/latest/devo/". Cygnus makefiles could
|
||||
just use -s $(srcdir) most of the time.
|
||||
|
||||
-b changes the ID for the <book> tag. db2html uses the <book> tag's
|
||||
ID as the default subdirectory name and/or html file name to create
|
||||
the book with. You'd need this to generate two books (internal vs
|
||||
public) from the same source.
|
||||
|
||||
The only other thing you'd add to the command line is the ONE template
|
||||
file you want to pull in.
|
@ -937,8 +937,7 @@ info would not be compatible with gdb).
|
||||
|
||||
<para>Yes. You can use the <literal>strace.exe</literal> utility to run other cygwin
|
||||
programs with various debug and trace messages enabled. For information
|
||||
on using <literal>strace</literal>, see the Cygwin User's Guide or the file
|
||||
<literal>winsup/utils/utils.sgml</literal> in the Cygwin sources.
|
||||
on using <literal>strace</literal>, see the Cygwin User's Guide.
|
||||
</para>
|
||||
</answer></qandaentry>
|
||||
|
||||
|
190
winsup/doc/path.xml
Normal file
190
winsup/doc/path.xml
Normal file
@ -0,0 +1,190 @@
|
||||
<?xml version="1.0" encoding='UTF-8'?>
|
||||
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook V4.5//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
||||
|
||||
<chapter id="cygwin-functions" xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<title>Cygwin Functions</title>
|
||||
|
||||
<para>These functions are specific to Cygwin itself, and probably
|
||||
won't be found anywhere else. </para>
|
||||
|
||||
<sect1 id="func-cygwin-conv-path">
|
||||
<title>cygwin_conv_path</title>
|
||||
|
||||
<funcsynopsis><funcprototype>
|
||||
<funcdef>extern "C" ssize_t
|
||||
<function>cygwin_conv_path</function></funcdef>
|
||||
<paramdef>cygwin_conv_path_t <parameter>what</parameter></paramdef>
|
||||
<paramdef>const void * <parameter>from</parameter></paramdef>
|
||||
<paramdef>void * <parameter>to</parameter></paramdef>
|
||||
<paramdef>size_t <parameter>size</parameter></paramdef>
|
||||
</funcprototype></funcsynopsis>
|
||||
|
||||
<para>Use this function to convert POSIX paths in
|
||||
<parameter>from</parameter> to Win32 paths in <parameter>to</parameter>
|
||||
or, vice versa, Win32 paths in <parameter>from</parameter> to POSIX paths
|
||||
in <parameter>to</parameter>. <parameter>what</parameter>
|
||||
defines the direction of this conversion and can be any of the below
|
||||
values.</para>
|
||||
|
||||
<programlisting>
|
||||
CCP_POSIX_TO_WIN_A /* from is char *posix, to is char *win32 */
|
||||
CCP_POSIX_TO_WIN_W, /* from is char *posix, to is wchar_t *win32 */
|
||||
CCP_WIN_A_TO_POSIX, /* from is char *win32, to is char *posix */
|
||||
CCP_WIN_W_TO_POSIX, /* from is wchar_t *win32, to is char *posix */
|
||||
</programlisting>
|
||||
|
||||
<para>You can additionally or the following values to
|
||||
<parameter>what</parameter>, to define whether you want the resulting
|
||||
path in <parameter>to</parameter> to be absolute or if you want to keep
|
||||
relative paths in relative notation. Creating absolute paths is the
|
||||
default.</para>
|
||||
|
||||
<programlisting>
|
||||
CCP_ABSOLUTE = 0, /* Request absolute path (default). */
|
||||
CCP_RELATIVE = 0x100 /* Request to keep path relative. */
|
||||
</programlisting>
|
||||
|
||||
<para><parameter>size</parameter> is the size of the buffer pointed to
|
||||
by <parameter>to</parameter> in bytes. If <parameter>size</parameter>
|
||||
is 0, <function>cygwin_conv_path</function> just returns the required
|
||||
buffer size in bytes. Otherwise, it returns 0 on success, or -1 on
|
||||
error and errno is set to one of the below values.</para>
|
||||
|
||||
<programlisting>
|
||||
EINVAL what has an invalid value or from is NULL.
|
||||
EFAULT from or to point into nirvana.
|
||||
ENAMETOOLONG the resulting path is longer than 32K, or, in case
|
||||
of what == CCP_POSIX_TO_WIN_A, longer than MAX_PATH.
|
||||
ENOSPC size is less than required for the conversion.
|
||||
</programlisting>
|
||||
|
||||
<example>
|
||||
<title>Example use of cygwin_conv_path</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
#include <sys/cygwin.h>
|
||||
|
||||
/* Conversion from incoming Win32 path given as wchar_t *win32 to POSIX path.
|
||||
If incoming path is a relative path, stick to it. First ask how big
|
||||
the output buffer has to be and allocate space dynamically. */
|
||||
ssize_t size;
|
||||
char *posix;
|
||||
size = cygwin_conv_path (CCP_WIN_W_TO_POSIX | CCP_RELATIVE, win32, NULL, 0);
|
||||
if (size < 0)
|
||||
perror ("cygwin_conv_path");
|
||||
else
|
||||
{
|
||||
posix = (char *) malloc (size);
|
||||
if (cygwin_conv_path (CCP_WIN_W_TO_POSIX | CCP_RELATIVE, win32,
|
||||
posix, size))
|
||||
perror ("cygwin_conv_path");
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="func-cygwin-conv-path-list">
|
||||
<title>cygwin_conv_path_list</title>
|
||||
|
||||
<funcsynopsis><funcprototype>
|
||||
<funcdef>extern "C" ssize_t
|
||||
<function>cygwin_conv_path_list</function></funcdef>
|
||||
<paramdef>cygwin_conv_path_t <parameter>what</parameter></paramdef>
|
||||
<paramdef>const void * <parameter>from</parameter></paramdef>
|
||||
<paramdef>void * <parameter>to</parameter></paramdef>
|
||||
<paramdef>size_t <parameter>size</parameter></paramdef>
|
||||
</funcprototype></funcsynopsis>
|
||||
|
||||
<para>This is the same as <function>cygwin_conv_path</function>, but the
|
||||
input is treated as a path list in $PATH or %PATH% notation.</para>
|
||||
<para>If <parameter>what</parameter> is CCP_POSIX_TO_WIN_A or
|
||||
CCP_POSIX_TO_WIN_W, given a POSIX $PATH-style string (i.e. /foo:/bar)
|
||||
convert it to the equivalent Win32 %PATH%-style string (i.e. d:\;e:\bar).</para>
|
||||
<para>If <parameter>what</parameter> is CCP_WIN_A_TO_POSIX or
|
||||
CCP_WIN_W_TO_POSIX, given a Win32 %PATH%-style string (i.e. d:\;e:\bar)
|
||||
convert it to the equivalent POSIX $PATH-style string (i.e. /foo:/bar).</para>
|
||||
<para><parameter>size</parameter> is the size of the buffer pointed to by
|
||||
<parameter>to</parameter> in bytes.</para>
|
||||
|
||||
<para>See also <link linkend="func-cygwin-conv-path">cygwin_conv_path</link></para>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="func-cygwin-create-path">
|
||||
<title>cygwin_create_path</title>
|
||||
|
||||
<funcsynopsis><funcprototype>
|
||||
<funcdef>extern "C" void *
|
||||
<function>cygwin_create_path</function></funcdef>
|
||||
<paramdef>cygwin_conv_path_t <parameter>what</parameter></paramdef>
|
||||
<paramdef>const void * <parameter>from</parameter></paramdef>
|
||||
</funcprototype></funcsynopsis>
|
||||
|
||||
<para>This is equivalent to the <function>cygwin_conv_path</function>, except
|
||||
that <function>cygwin_create_path</function> does not take a buffer pointer
|
||||
for the result of the conversion as input. Rather it allocates the buffer
|
||||
itself using <function>malloc</function>(3) and returns a pointer to this
|
||||
buffer. In case of error it returns NULL and sets errno to one of the
|
||||
values defined for <function>cygwin_conv_path</function>. Additionally
|
||||
errno can be set to the below value.</para>
|
||||
|
||||
<programlisting>
|
||||
ENOMEM Insufficient memory was available.
|
||||
</programlisting>
|
||||
|
||||
<para>When you don't need the returned buffer anymore, use
|
||||
<function>free</function>(3) to deallocate it.</para>
|
||||
|
||||
<para>See also <link linkend="func-cygwin-conv-path">cygwin_conv_path</link></para>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="func-cygwin-posix-path-list-p">
|
||||
<title>cygwin_posix_path_list_p</title>
|
||||
|
||||
<funcsynopsis><funcprototype>
|
||||
<funcdef>extern "C" int
|
||||
<function>cygwin_posix_path_list_p</function></funcdef>
|
||||
<paramdef>const char *<parameter>path</parameter></paramdef>
|
||||
</funcprototype></funcsynopsis>
|
||||
|
||||
<para>This function tells you if the supplied
|
||||
<parameter>path</parameter> is a POSIX-style path (i.e. posix names,
|
||||
forward slashes, colon delimiters) or a Win32-style path (drive
|
||||
letters, reverse slashes, semicolon delimiters. The return value is
|
||||
true if the path is a POSIX path. Note that "_p" means "predicate", a
|
||||
lisp term meaning that the function tells you something about the
|
||||
parameter.</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="func-cygwin-split-path">
|
||||
<title>cygwin_split_path</title>
|
||||
|
||||
<funcsynopsis><funcprototype>
|
||||
<funcdef>extern "C" void
|
||||
<function>cygwin_split_path</function>
|
||||
</funcdef>
|
||||
<paramdef>const char * <parameter>path</parameter></paramdef>
|
||||
<paramdef>char * <parameter>dir</parameter></paramdef>
|
||||
<paramdef>char * <parameter>file</parameter></paramdef>
|
||||
</funcprototype></funcsynopsis>
|
||||
|
||||
<para>Split a path into the directory and the file portions. Both
|
||||
<parameter>dir</parameter> and <parameter>file</parameter> are
|
||||
expected to point to buffers of sufficient size. </para>
|
||||
|
||||
<example>
|
||||
<title>Example use of cygwin_split_path</title>
|
||||
<programlisting>
|
||||
char dir[200], file[100];
|
||||
cygwin_split_path("c:/foo/bar.c", dir, file);
|
||||
printf("dir=%s, file=%s\n", dir, file);
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
|
||||
</chapter>
|
1565
winsup/doc/posix.xml
Normal file
1565
winsup/doc/posix.xml
Normal file
File diff suppressed because it is too large
Load Diff
@ -16,6 +16,6 @@ knowledge of standard UNIX commands.</para>
|
||||
<xi:include href="cygwinenv.xml"/>
|
||||
<xi:include href="ntsec.xml"/>
|
||||
<xi:include href="cygserver.xml"/>
|
||||
<xi:include href="../utils/utils.xml"/>
|
||||
<xi:include href="utils.xml"/>
|
||||
<xi:include href="effectively.xml"/>
|
||||
</chapter>
|
||||
|
2104
winsup/doc/utils.xml
Normal file
2104
winsup/doc/utils.xml
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user