This file is indexed.

/usr/bin/ncc 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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
#!/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.

# Configuration
$TOSDIR = "/usr/src/tinyos/tos";
$TOSDIR = $ENV{"TOSDIR"} if defined($ENV{"TOSDIR"});
$nescc = "/usr/bin/nescc";
$tossim = 0;
$is_tos_1 = 0;
$with_scheduler_flag = 1;

# Support platform directory renaming for 2.x
if (-d "$TOSDIR/platform") {
    $platform = "platform";
    $is_tos_1 = 1;
}
else {
    $platform = "platforms";
}

my $exeflag=0;
my $libs = "";

# Have fun with the arguments

for ($i = 0; $i <= $#ARGV; $i++) {
    $strip = 0;
    $_ = $ARGV[$i];
    if (/^-/) {
	if (/^-target=(.*)/) {
	    &fail("multiple targets specified") if defined($target);
	    $target = $1;
	    $strip = 1;
	}
	elsif (/^-tosdir=(.*)/) {
	    $TOSDIR = $1;
	    $strip = 1;
	}
	elsif (/^-tosscheduler=(.*)/) {
	    $scheduler = $1;
	    $strip = 1;
	}
	elsif (/^-nostdinc$/) {
	    $nostdinc = 1;
	}
	elsif (/^-board=(.*)/) {
	    push @boards, $1;
	    $strip = 1;
	}
	elsif (/^-print-tosdir$/) {
	    $print_tosdir = 1;
	    $strip = 1;
	}
	elsif (/^-print-target$/) {
	    $print_target = 1;
	    $strip = 1;
	}
	elsif (/^-print-platforms$/) {
	    $print_platforms = 1;
	    $strip = 1;
	}
	elsif (/^-g$/) {
	    $debugging = 1;
	}
	elsif (/^-v$/) {
	    $verbose = 1;
	}
	elsif (/^-tossim$/) {
	    $tossim = 1;
            $strip = 1;
	}
	elsif (/^-I/) {
	    ($i, $file) = &extractarg($i);
	    $strip = 1;
	    push @includes, $file;
	}
	elsif (/^-fnesc-cfile=(.*)/){
	    $appfilename=$1;
	}
	elsif (/^-o$/){
	    $exeflag=1;
	}
        elsif (/^-l/) {
            $libs = $libs . " " . $_;
        } 
	elsif (/^--version$/) {
	    $print_version = 1;
	}
    } elsif ($exeflag) {
	$exefilename =$_;
	$exeflag=0;
    }

    push @new_args, $_ if !$strip;
}

if ($print_version) {
    print "ncc: 1.4.2\n";
}

# Remove trailing / from TOSDIR, if any (it confuses the topdir stuff)
chop $TOSDIR if $TOSDIR =~ m!./$!;

if ($print_tosdir)
{
    print $TOSDIR, "\n";
    exit 0;
}

if ($print_platforms)
{
    print join(" ", all_platforms()), "\n";
    exit 0;
}

if ($tossim) {
  push @new_args, "-DTOSSIM";
}

if (!defined $target) {
    if (open DEFTARGET, "$TOSDIR/.default-platform") {
	$target = <DEFTARGET>;
	chomp $target;
    }
    else {
	$target = "mica";
    }
}

if (!defined $scheduler && !$is_tos_1) {
	$scheduler = "TinySchedulerC,TinySchedulerC.TaskBasic,TaskBasic,TaskBasic,runTask,postTask";
}

if ($print_target) {
    print $target, "\n";
    exit 0;
}

# First see if the directory for this platform was explicitly specified
foreach $dir (@includes) {
    if ($dir =~ m!/$target/?$! && -f "$dir/.platform") {
	$platform_def = "$dir/.platform";
	last;
    }
}

if (!-f $platform_def) {
    # Next, check if it's a "plain" platform
    if (-f "$TOSDIR/$platform/$target/.platform") {
	$platform_def = "$TOSDIR/$platform/$target/.platform";
    }
    else {
	# Finally, see if it's in a platform family
	opendir PLATFORMS, "$TOSDIR/$platform";
	foreach $dir (readdir PLATFORMS) {
	    if (-f "$TOSDIR/$platform/$dir/.family") {
		if (-f "$TOSDIR/$platform/$dir/$target/.platform") {
		    $platform_def = "$TOSDIR/$platform/$dir/$target/.platform";
		    $family_def = "$TOSDIR/$platform/$dir/.family";
		    last;
		}
	    }
	}
	closedir PLATFORMS;
    }
}

# Use sim directory with tossim
$platform_def =~ s!\.platform$!sim/.platform! if $tossim;
$family_def =~ s!\.family$!sim/.family! if $tossim && $family_def;

if (!-f $platform_def) {
    print STDERR "Unknown target $target\n";
    print STDERR "Known targets for TinyOS directory $TOSDIR\n";
    print STDERR "and the specified include directories are:\n";

    @platforms = all_platforms();
    if (@platforms) {
	print STDERR "  ", join(" ", @platforms);
    }
    else {
	print STDERR "none.";
    }
    print STDERR "\n";
    exit 2;
}

# Setup sensor boards
push @includes, map "%T/sensorboards/$_", @boards unless $nostdinc;
unshift @new_args, map "-DBOARD_\U$_", @boards;
# Execute .sensor file in selected sensor board directories if it exists
$i = 0;
BOARD: while ($i <= $#boards) {
    $board = $boards[$i];

    # First check include path for a .sensor file for this board
    foreach $dir (@includes) {
	if ($dir =~ m!/$board/?$! && -f "$dir/.sensor") {
	    # Remove from @boards so that we don't add sensorboards/$board
	    # to the search path
	    splice @boards, $i, 1;
	    do "$dir/.sensor";
	    next BOARD;
	}
    }

    # If none found, check the standard sensorboards directory
    $bspec = &idir_subst("%T/sensorboards/$board/.sensor");
    do $bspec if -f $bspec;

    $i++;
}

# Setup platform
$platform_dir = $platform_def;
$platform_dir =~ s!/\.platform$!!;
push @includes, $platform_dir unless $nostdinc;
do $platform_def;
do $family_def if -f $family_def;
unshift @new_args, "-DPLATFORM_\U$target";

push @new_args, @opts;
if(!$is_tos_1) {
  unshift @new_args, "-fnesc-scheduler=$scheduler";
}

# old nesdoc: set the default topdir based on TOSDIR
my ($tosparent) = ($TOSDIR =~ m!^(.*)/.*?$!);
unshift @new_args, "-topdir=$tosparent";

unshift @new_args, "-fnesc-include=tos";
unshift @new_args, "$nescc";

if (!$nostdinc) {
    push @includes, map "%T/$platform/$_", @commonplatforms;
    push @includes, "%T/interfaces";
    push @includes, "%T/types";
    push @includes, "%T/system";
}


if ($tossim) {
  foreach $idir (@includes) {
    $idir = &idir_subst($idir);
    push @new_args, "-I$idir/sim";
  }
  $tossim_dir = &idir_subst("-I%T/lib/tossim");
  push @new_args, $tossim_dir;
}
foreach $idir (@includes) {
    $idir = &idir_subst($idir);
    push @new_args, "-I$idir";
}




print STDERR join(' ', @new_args), "\n" if $verbose;
exec @new_args;
print STDERR "Couldn't execute nescc\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 idir_subst {
    local ($idir) = @_;
    local $idx = 0;

    while (($idx = index $idir, "%", $idx) >= 0) {
	$char = substr $idir, $idx + 1, 1;
	$rep = 0;
	$rep = "%" if $char eq "%";
	$rep = $TOSDIR if $char eq "T";
	$rep = $target if $char eq "p";
	$rep = $platform_dir if $char eq "P";
	&fail("unknown include-path substitution %" . $char) if !$rep;
	substr($idir, $idx, 2) = $rep;
	$idx += length $rep;
    }
    return $idir;
}

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

sub push_platform {
    my ($p) = @_;

    push @platforms, $p unless grep $_ eq $p, @platforms;
}

sub all_platforms() {
  local(@platforms);

  foreach $dir (@includes) {
    push_platform($1) if -f "$dir/.platform" && $dir =~ m!/([^/]*)/?$!;
  }

  if (opendir PLATFORMS, "$TOSDIR/$platform") {
      foreach $d (readdir PLATFORMS) {
	  push_platform($d) if (-f "$TOSDIR/$platform/$d/.platform");
	  if (-f "$TOSDIR/$platform/$d/.family") {
	      if (opendir SUBPLATFORMS, "$TOSDIR/$platform/$d") {
		  foreach $subdir (readdir SUBPLATFORMS) {
		      push_platform($subdir) if (-f "$TOSDIR/$platform/$d/$subdir/.platform");
		  }
	      }
	      closedir SUBPLATFORMS;
	  }
      }
      closedir PLATFORMS;
  }

  return @platforms;
}