summaryrefslogtreecommitdiffstats
path: root/fixprogs
blob: 61840cf810b7b4417dd3a9a97c9964a498df0097 (plain)
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
3
#!/usr/bin/perl
#
# fixprogs  - run through the list of entropy commands and
#             score out the losers
#

$entscale = 50; # divisor for optional entropy measurement

sub usage {
  return("Usage: $0 <command file>\n");
}

if (($#ARGV == -1) || ($#ARGV>1)) {
  die(&usage);
}

# 'undocumented' option - run ent (in second param) on the output
if ($#ARGV==1) {
  $entcmd=$ARGV[1]
} else {
  $entcmd = ""
};

$infilename = $ARGV[0];

if (!open(IN, "<".$infilename)) {
  die("Couldn't open input file");
}
$outfilename=$infilename.".out";
if (!open(OUT, ">$outfilename")) {
  die("Couldn't open output file $outfilename");
}
@infile=<IN>;

select(OUT); $|=1; select(STDOUT);

foreach (@infile) {
  if (/^\s*\#/ || /^\s*$/) {
    print OUT;
    next;
  }
  ($cmd, $path, $est) = /^\"([^\"]+)\"\s+([\w\/_-]+)\s+([\d\.\-]+)/o;
  @args = split(/ /, $cmd);
   if (! ($pid = fork())) {
     # child
     close STDIN; close STDOUT; close STDERR;
     open (STDIN,  "</dev/null");
     open (STDOUT, ">/dev/null");
     open (STDERR, ">/dev/null");
     exec $path @args;
     exit 1; # shouldn't be here
   }
   # parent
   waitpid ($pid, 0); $ret=$? >> 8;

  if ($ret != 0) {
    $path = "undef";
  } else {
    if ($entcmd ne "") {
      # now try to run ent on the command
      $mostargs=join(" ", splice(@args,1));
      print "Evaluating '$path $mostargs'\n";
      @ent = qx{$path $mostargs | $entcmd -b -t};
      @ent = grep(/^1,/, @ent);
      ($null, $null, $rate) = split(/,/, $ent[0]);
      $est = $rate / $entscale;		# scale the estimate back
    }
  }    
  print OUT "\"$cmd\" $path $est\n";
}

close(IN);
> * theDocument); STDMETHOD (NewDocument) (THIS_ IDispatch * theDocument); STDMETHOD (WindowActivate) (THIS_ IDispatch * theWindow); STDMETHOD (WindowDeactivate) (THIS_ IDispatch * theWindow); STDMETHOD (WorkspaceOpen) (THIS); STDMETHOD (WorkspaceClose) (THIS); STDMETHOD (NewWorkspace) (THIS); }; typedef CComObject < XApplicationEvents > XApplicationEventsObj; XApplicationEventsObj *m_pApplicationEventsObj; // This object handles events fired by the Application object class XDebuggerEvents : public XEventHandler < IDebuggerEvents, &IID_IDebuggerEvents, &LIBID_VisVim, XDebuggerEvents, &CLSID_DebuggerEvents > { public: // IDebuggerEvents method STDMETHOD (BreakpointHit) (THIS_ IDispatch * pBreakpoint); }; typedef CComObject < XDebuggerEvents > XDebuggerEventsObj; XDebuggerEventsObj *m_pDebuggerEventsObj; public: // ICommands methods STDMETHOD (VisVimDialog) (THIS); STDMETHOD (VisVimEnable) (THIS); STDMETHOD (VisVimDisable) (THIS); STDMETHOD (VisVimToggle) (THIS); STDMETHOD (VisVimLoad) (THIS); }; typedef CComObject < CCommands > CCommandsObj; //{{AFX_INSERT_LOCATION}} #endif // !defined(AFX_COMMANDS_H__AC726717_2977_11D1_B2F3_006008040780__INCLUDED)