This file is indexed.

/usr/bin/nescc-ncg is in nescc 1.3.5-1.1.

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
#!/usr/bin/perl

# This file is part of the nesC compiler.
#    Copyright (C) 2002 Intel Corporation
#
# The attached "nesC" software is provided to you under the terms and
# conditions of the GNU General Public License Version 2 as published by the
# Free Software Foundation.
#
# nesC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with nesC; see the file COPYING.  If not, write to
# the Free Software Foundation, 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.

$prefix = "/usr";
$exec_prefix = "${prefix}";
$nescc = "$exec_prefix/bin/nescc";
$NCDIR = "${prefix}/lib/x86_64-linux-gnu/ncc";

push @INC, "$NCDIR";

for ($i = 0; $i <= $#ARGV; $i++) {
    $_ = $ARGV[$i];

    if (/^-/) {
	if (/^-java-classname=(.*)$/) {
	    $java_classname = $1;
	}
	elsif (/^-java-extends=(.*)$/) {
	    $java_extends = $1;
	}
	elsif (/^-python-classname=(.*)$/) {
	    $python_classname = $1;
	}
	elsif (/^-python-extends=(.*)$/) {
	    $python_extends = $1;
	}
	elsif (/^-c-prefix=(.*)$/) {
	    $c_prefix = $1;
	}
	elsif (/^-o/) {
	    ($i, $ofile) = &extractarg($i);
	}
	elsif (/^-nescc=(.*)$/) {
	    $nescc = $1;
	}
	# pass ncc options on through
	# (yes, -o was captured above. This is "generic" code)
	elsif (/^-[oILxubV]/) {
	    # pass option and arg through unchanged
	    $opt = substr $_, 1, 1;
	    ($i, $arg) = &extractarg($i);
	    push @args, "-$opt$arg";
	}
	elsif ($i < $#ARGV &&
	       (/^--param$/ || /^-idirafter$/ || /^-include$/ || /^-imacros$/ ||
		/^-iprefix$/ || /^-iwithprefix$/ || /^-iwithprefixbefore$/ ||
		/^-isystem$/ || /^-imultilib$/ || /^-isysroot$/ ||
		/^-Xpreprocessor$/ || /^-Xlinker$/)) {
	    # convert argument filename which is in next arg
	    push @args, $_;
	    push @args, $ARGV[++$i];
	}
	else {
	    push @args, $_;
	    $verbose = 1 if /^-v$/;
	}
    }
    else {
	if (!defined($target)) {
	    $target = $_;
	}
	elsif (!defined($cfile)) {
	    $cfile = $_;
	}
	else {
	    $csts = 1;
	    if (/^\w+$/) {
		$cst_names{$_} = 1;
	    }
	    else {
		$cst_files{$_} = 1;
	    }
	}
    }
}
&usage("no target specified") if !defined($target);
&usage("no nesC file specified") if !defined($cfile);
&usage("no constants requested") if !$csts;

unshift @args, "-fsyntax-only";
unshift @args, "-fnesc-csts";
unshift @args, "$nescc";
push @args, "-x";
push @args, "nesc";
push @args, $cfile;

print STDERR join(" ", @args), "\n" if $verbose;
open(NESC, '-|', @args) or die "$args[0] not found";
@allcsts = <NESC>;
close NESC;

foreach (@allcsts) {
    die "invalid nesC output" if !/(\w+) "(.*)" (\w+) (.*)/;
    $name = $1;
    $path = $2;
    $val = $4;
    $path =~ /([^\/\\]+)$/;
    $file = $1;
    $csts{$name} = $val if ($cst_names{$name} || $cst_files{$file});
}

if ($?) {
    print STDERR "failed to parse nesC file $cfile\n";
    exit 1;
}

if (!-f "$NCDIR/gencst$target.pm") {
    print STDERR "Unknown tool $target\n";
    exit 2;
}

if ($ofile) {
    close STDOUT;
    if (!open STDOUT, ">$ofile") {
	print STDERR "failed to create $ofile\n";
	exit 1;
    }
}

require "gencst$target.pm";
&gen($classname, %csts);
$completed = 1;

sub usage()
{
    my ($error) = @_;

    print STDERR "$error\n\n" if $error;

    print STDERR "Usage: $0 [options] tool nesC-file filenames-or-constant-names...\n";
    print STDERR "  general options are\n";
    print STDERR "    -I dir                            Add include directory\n\n";
    print STDERR "    -target=NCC-TARGET                Select mote architecture\n";
    print STDERR "                                      (default is ncc's, use pc with tossim)\n";
    print STDERR "  target specific options are\n";
    print STDERR "    java:\n";
    print STDERR "      -java-classname=FULL-CLASS-NAME Select class name (required)\n";
    print STDERR "      -java-extends=CLASS-NAME        Select class to extend\n";
    print STDERR "                                      (default net.tinyos.message.Message)\n";
    print STDERR "    python:\n";
    print STDERR "      -python-classname=FULL-CLASS-NAME Select class name (required)\n";
    print STDERR "      -python-extends=CLASS-NAME        Select class to extend\n";
    print STDERR "                                      (default tinyos.message.Message)\n";
    print STDERR "    C:\n";
    print STDERR "      -c-prefix=PREFIX                  Add a prefix to constant names\n";

    exit 2;
}

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

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

sub END() {
    unlink $ofile unless !$ofile || $completed;
}