This file is indexed.

/usr/src/WrapITK/Tcl/itkTclAppInit.cxx is in libinsighttoolkit3-dev 3.20.1-1.

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

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
/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    itkTclAppInit.cxx
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) Insight Software Consortium. All rights reserved.
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#include "itkLightObject.h"
#include "itkTclConfigure.h"

#include <sys/stat.h>
#include <string.h>

#ifndef ITK_TCL_NO_TK
#  include <tk.h>
#else
#  include <tcl.h>
#endif

// Include the list of modules that the user has selected to build
#include "itkTclModules.h"

//----------------------------------------------------------------------------
// Definitions related to build tree locations:
//   ITK_TCL_EXE_DIR  = Location of this executable.
//   ITK_TCL_LIB_DIR  = Location of the pkgIndex.tcl file for ITK.
#if defined(CMAKE_INTDIR)
# define ITK_TCL_EXE_DIR ITK_TCL_EXE_DIR_BUILD "/" CMAKE_INTDIR
# define ITK_TCL_LIB_DIR WrapITK_BINARY_DIR "/Tcl/" CMAKE_INTDIR
#else
# define ITK_TCL_EXE_DIR ITK_TCL_EXE_DIR_BUILD
# define ITK_TCL_LIB_DIR WrapITK_BINARY_DIR "/Tcl"
#endif

// ITK_TCL_EXE_NAME = Name of this executable.
#if defined(_WIN32)
# define ITK_TCL_EXE_NAME ITK_TCL_EXE_NAME_ROOT ".exe"
#else
# define ITK_TCL_EXE_NAME ITK_TCL_EXE_NAME_ROOT
#endif


//----------------------------------------------------------------------------
int itkTclAppInit(Tcl_Interp* interp);
bool itkTclAppInitCheckSameExecutable(Tcl_Interp* interp);

//----------------------------------------------------------------------------
/** Program entry point.  */
int main(int argc, char** argv)
{
  std::ios::sync_with_stdio();
#ifndef ITK_TCL_NO_TK
  Tk_Main(argc, argv, &itkTclAppInit);
#else
  Tcl_Main(argc, argv, &itkTclAppInit);
#endif
  return 0;
}

//----------------------------------------------------------------------------
/** Main application initialization function.  */
int itkTclAppInit(Tcl_Interp* interp)
{
  // Initialize Tcl.
  if(Tcl_Init(interp) != TCL_OK) { return TCL_ERROR; }
  
#ifndef ITK_TCL_NO_TK
  // Initialize Tk.
  if(Tk_Init(interp) != TCL_OK) { return TCL_ERROR; }
#endif
  
  if(itkTclAppInitCheckSameExecutable(interp))
    {
    // Running from build tree, load the pkgIndex.tcl file from it.
    char pkgIndexScript[] = "source {" ITK_TCL_LIB_DIR "/pkgIndex.tcl}\n";
    if(Tcl_GlobalEval(interp, pkgIndexScript) != TCL_OK) { return TCL_ERROR; }
    }
  else
    {
    // Not running from build tree, load the pkgIndex.tcl file if
    // there is one next to the exectuable.  If it does not exist,
    // just assume the user has configured TCLLIBPATH correctly.
    char pkgIndexScript[] =
      "set itkTclAppInit_pkgIndex_tcl \\\n"
      "  [file join [file dirname [info nameofexecutable]] tcl pkgIndex.tcl]\n"
      "if {[file exists $itkTclAppInit_pkgIndex_tcl]} {\n"
      "  source $itkTclAppInit_pkgIndex_tcl\n"
      "}\n"
      "unset itkTclAppInit_pkgIndex_tcl";
    if(Tcl_GlobalEval(interp, pkgIndexScript) != TCL_OK) { return TCL_ERROR; }
    }
  
  // Initialize the built-in packages.
  for (unsigned int i; i < NumITKModules; i++)
    {
    if( ModuleInitializers[i](interp) != TCL_OK ) 
      {
      return TCL_ERROR;
      }
    }
  
  // Initialize all ITK Tcl packages.
  static char initScript[] = "package require InsightToolkit " ITK_VERSION_STRING;
  if(Tcl_GlobalEval(interp, initScript) != TCL_OK) { return TCL_ERROR; }
  
  // Allow users to have an initialization file for interactive mode.
  static char rcFileNameVariable[] = "tcl_rcFileName";
  static char rcFileNameValue[] = "~/.itktclrc";
  Tcl_SetVar(interp, rcFileNameVariable, rcFileNameValue, TCL_GLOBAL_ONLY);
  
  return TCL_OK;
}

//----------------------------------------------------------------------------
bool itkTclAppInitCheckSameExecutable(Tcl_Interp* interp)
{
  // Get the name of the actual executable.
  char nameScript[] = "info nameofexecutable";
  if(Tcl_GlobalEval(interp, nameScript) != TCL_OK) { return TCL_ERROR; }
  std::string nameOfExecutable = Tcl_GetStringResult(interp);
  
  // Get the name of the executable in the build tree.
  std::string buildExecutable = ITK_TCL_EXE_DIR "/" ITK_TCL_EXE_NAME;
  
  const char* file1 = nameOfExecutable.c_str();
  const char* file2 = buildExecutable.c_str();
  
#if defined(_WIN32)
  struct stat fileStat1, fileStat2;
  if (stat(file1, &fileStat1) == 0 && stat(file2, &fileStat2) == 0)
    {
    HANDLE hFile1, hFile2;
    
    hFile1 = CreateFile(file1, GENERIC_READ, FILE_SHARE_READ, NULL,
                        OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
    hFile2 = CreateFile(file2, GENERIC_READ, FILE_SHARE_READ, NULL,
                        OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
    if( hFile1 == INVALID_HANDLE_VALUE || hFile2 == INVALID_HANDLE_VALUE)
      {
      if(hFile1 != INVALID_HANDLE_VALUE)
        {
        CloseHandle(hFile1);
        }
      if(hFile2 != INVALID_HANDLE_VALUE)
        {
        CloseHandle(hFile2);
        }
      return false;
      }
    
    BY_HANDLE_FILE_INFORMATION fiBuf1;
    BY_HANDLE_FILE_INFORMATION fiBuf2;
    GetFileInformationByHandle( hFile1, &fiBuf1 );
    GetFileInformationByHandle( hFile2, &fiBuf2 );
    CloseHandle(hFile1);
    CloseHandle(hFile2);
    return (fiBuf1.nFileIndexHigh == fiBuf2.nFileIndexHigh &&
            fiBuf1.nFileIndexLow == fiBuf2.nFileIndexLow);
    }
  return false;
#else
  struct stat fileStat1, fileStat2;
  if (stat(file1, &fileStat1) == 0 && stat(file2, &fileStat2) == 0)
    {
    // see if the files are the same file
    // check the device inode and size
    if(memcmp(&fileStat2.st_dev, &fileStat1.st_dev, sizeof(fileStat1.st_dev)) == 0 && 
       memcmp(&fileStat2.st_ino, &fileStat1.st_ino, sizeof(fileStat1.st_ino)) == 0 &&
       fileStat2.st_size == fileStat1.st_size 
      ) 
      {
      return true;
      }
    }
  return false;
#endif
}