This file is indexed.

/usr/bin/nesdoc is in tinyos-tools 1.4.2-3.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#!/usr/bin/perl
# -*- perl -*-

# Copyright (c) 2002-2005 Intel Corporation
# All rights reserved.
#
# This file is distributed under the terms in the attached INTEL-LICENSE     
# file. If you do not find these files, copies can be found by writing to
# Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, 
# 94704.  Attention:  Intel License Inquiry.

# The new nesdoc implementation. When run with a TinyOS 1.x setup, just runs
# the old nesdoc except if the -new option is given.
#
# The new nesdoc implementation is based on the XML dump facilities in nesC
# 1.2 (version 1.2.1 of the nesC compiler is required). Documenation
# generation is broken into two phases:
# - nesdoc data collection: nesdoc information for all interfaces and 
#   components is saved to a nesdoc repository, which is just a collection
#   of XML files. See archive.py for more details.
# - HTML generation from the XML files: once a repository is complete,
#   you run nesdoc with the -html option to generate HTML files for
#   each interface and component, along with an index. See genhtml.py
#   for details.
#
# Differences between the old and new nesdocs (summary):
# - the new nesdoc is currently only targeted at generating API documentation;
#   it doesn't generate HTML files describing applications
# - the old nesdoc does not support generic components or interfaces
# - the per-component HTML files, the index and wiring graphs are hopefully
#   more readable
# - information on module implementations is not included (it should not
#   be part of an API documentation)


$prefix = "/usr";
$exec_prefix = "${prefix}";
$libprogs = "${prefix}/lib/x86_64-linux-gnu/tinyos";
$python = "/usr/bin/python2";

$tosdir = `ncc -print-tosdir`;
chomp($tosdir);

# If using a TinyOS 1.x tree, assume old-style nesdoc except if there is a
# -new argument somewhere.
if (-d "$tosdir/platform" && !grep /^-new$/, @ARGV) {
    # nesdoc for TinyOS 1.x, support old style docs
    if ($#ARGV < 1) {
	&fail("Usage: nesdoc <documentation directory> <options and nesC files>");
    }

    $docdir = shift @ARGV;

    unshift @ARGV, "-docdir=$docdir";
    unshift @ARGV, "-fsyntax-only";
    unshift @ARGV, "$exec_prefix/bin/ncc";

    exec @ARGV;
    fail("Couldn't execute $ARGV[0]");
}

# nesdoc for TinyOS 2.x 
# parse arguments
$target = `ncc -print-target`;
chomp $target;
for ($i = 0; $i <= $#ARGV; $i++) {
    $strip = 0;
    $_ = $ARGV[$i];
    if (/^-/) {
	if (/^-topdir=(.*)/) {
            push @archive_args, "--topdir=$1";
	    $strip = 1;
	}
	elsif (/^--version$/) {
	    $print_version = 1;
	    $strip = 1;
	}
	elsif (/^-v$/) {
	    $verbose = 1;
	}
	elsif (/^-target=(.*)/) {
	    $target = $1;
	}
	elsif (/^-o/) {
	    ($i, $docdir) = extractarg($i);
	    $strip = 1;
	}
	elsif (/^-html$/) {
	    $genhtml = 1;
	    $strip = 1;
	}
	elsif (/^-preserve$/) {
	    $preserve = 1;
	    $strip = 1;
	}
	elsif (/^-app$/) {
	    $app = 1;
	    $strip = 1;
	}
	elsif (/^-quiet$/) {
	    $quiet = 1;
	    $strip = 1;
	}
    }
    push @ncc_args, $_ if !$strip;
}

if ($print_version) {
    print "nesdoc: 1.4.2\n";
    exit 0;
}

fail("No documentation directory specified") if !defined $docdir;
$docdir = "$docdir/$target";

if (defined $ENV{PYTHONPATH}) {
    $ENV{PYTHONPATH} = "$libprogs:$PYTHONPATH";
}
else {
    $ENV{PYTHONPATH} = "$libprogs";
}

if ($genhtml) {
    push @html_args, $python;
    push @html_args, "$libprogs/nesdoc/genhtml.py";
    push @html_args, "--quiet" if $quiet;
    push @html_args, $docdir;
    execorfail(@html_args);
}

# Collecting nesdoc data. Run ncc, then process the results with
# nesdoc-archive

unshift @ncc_args, "-fsyntax-only";
unshift @ncc_args, "-fnesc-dump=wiring" if $app;
unshift @ncc_args, "-fnesc-dump=interfacedefs";
unshift @ncc_args, "-fnesc-dump=components(wiring)";
unshift @ncc_args, "-fnesc-dump=interfaces";
unshift @ncc_args, "-fnesc-dump=functions(!global())";
unshift @ncc_args, "-fnesc-dump=referenced(interfaces,components,functions)";
unshift @ncc_args, "$exec_prefix/bin/ncc";

print STDERR join(' ', @ncc_args), "\n" if $verbose;

pipe FORARCHIVE, FORNCC;

if (!($pid = fork())) {
    close STDOUT;
    open STDOUT, ">&FORNCC";
    execorfail(@ncc_args);
}
fail("fork failed") if $pid < 0;
close STDIN;
open STDIN, "<&FORARCHIVE";
# Top of TinyOS tree is a default "topdir" (for package emulation)
$toscontainer = `dirname $tosdir`;
chomp $toscontainer;
push @archive_args, "--topdir=$toscontainer";
push @archive_args, "--preserve" if $preserve;
push @archive_args, "--app" if $app;
push @archive_args, "--quiet" if $quiet;
push @archive_args, "$docdir";
unshift @archive_args, "$libprogs/nesdoc/archive.py";
unshift @archive_args, $python;

print STDERR join(' ', @archive_args), "\n" if $verbose;

fail("Couldn't create directory $docdir") if system("mkdir -p \"$docdir\"");
execorfail(@archive_args);

sub fail {
    print STDERR "$_[0]\n";
    exit 2;
}

sub execorfail {
    exec @_;
    fail("Couldn't execute $_[0]");
}

sub usage {
    fail(<<EOM
Usage: nesdoc -o <documentation directory> <ncc options and nesC files>
         Compile specified files and archive the resulting nesdoc
	 information in <documentation directory>
         Note: This does not generate the nesdoc html pages.

       nesdoc -o <documentation directory> -html
	 Generate nesdoc html pages from archived nesdoc information.

       nesdoc -o <documentation directory> -app <ncc options and nesC file>
         Compile specified nesC application and generate a wiring graph
	 for the whole program in the current directory.
EOM
)
}

sub extractarg {
    local ($i) = @_;

    if (length($ARGV[$i]) == 2) {
	$arg = $ARGV[++$i];
    }
    else {
	$arg = substr($ARGV[$i], 2);
    }
    return ($i, $arg);
}