This file is indexed.

/usr/share/xcrysden/Tcl/scriptingMakeMovie.tcl is in xcrysden-data 1.5.53-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
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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
#############################################################################
# Author:                                                                   #
# ------                                                                    #
#  Anton Kokalj                                  Email: Tone.Kokalj@ijs.si  #
#  Department of Physical and Organic Chemistry  Phone: x 386 1 477 3523    #
#  Jozef Stefan Institute                          Fax: x 386 1 477 3811    #
#  Jamova 39, SI-1000 Ljubljana                                             #
#  SLOVENIA                                                                 #
#                                                                           #
# Source: $XCRYSDEN_TOPDIR/Tcl/scriptingMakeMovie.tcl
# ------                                                                    #
# Copyright (c) 1996-2003 by Anton Kokalj                                   #
#############################################################################


# ------------------------------------------------------------------------
#****c* Scripting/scripting::makeMovie
#
# NAME
# scripting::makeMovie
#
# PURPOSE

# This namespace provide the scripting interface for making
# MPEG/Animated-GIF movies. The scripting::makeMovie namespace
# interface is kind of state machine. The "init" command initializes
# the process, and then the movie creation is encapsulated between
# "begin" and "end" commands. Every movie frame is created within the
# "begin" and "end" commands with "makeFrame" command. One can create
# several movies within one scripting file. Make sure the sequence of
# makeMovie calls will have the following order:
#
# init
# begin
#   makeFrame
#   makeFrame
#   ...
# end
#
# init
# begin
#   makeFrame
#   makeFrame
#   ...
# end
#
#
# COMMANDS

# -- scripting::makeMovie::init

# Initializes the movie creation process. It must be called before
# making movie. One passes several configuration options to init call.


#
# -- scripting::makeMovie::begin

# Marks the begining of movie creation.

#
# -- scripting::makeMovie::makeFrame

# Makes one movie frame, that is, saves (i.e. prints to file) the
# content of the currently displayed object.

#
# -- scripting::makeMovie::end

# Finishes the movie creation and encodes the movie.
#
#****
# ------------------------------------------------------------------------

namespace eval scripting::makeMovie {
    variable movie

    set movie(makeMovie) 0
    set movie(movieFile) ""
    set movie(notificationMovie) ""
}


# ------------------------------------------------------------------------
#****f* Scripting/scripting::makeMovie::init
#
# NAME
# scripting::makeMovie::init
#
# USAGE
# scripting::makeMovie::init -option value ?-option value? ...
#
# PURPOSE

# This proc initializes the movie creation processes. One can pass several
# configuration options, which determine the technical details of the
# movie.

#
# ARGUMENTS
# args -- various configuration "-option value" pairs
#
# OPTIONS
# ------------------------------------------------------------------------
#  OPTION               ALLOWED-VALUES + DESCRIPTION
# ------------------------------------------------------------------------
#
#  -gif_transp          0|1 --> make oblique|transparent animated-GIF
#
#  -gif_minimize        0|1 --> don't-minimize|minimize animateg-GIF
#
#  -gif_global_colormap 0|1 --> don't-use|use global colormap for animated-GIF
#
#  -movieformat         avi|mpeg|gif --> create AVI|MPEG|Animated-GIF
#
#  -dir                 tmp|pwd --> put temporary (i.e. frame) files to 
#                                   scratch(tmp) or current working
#                                   directory(pwd) 
#
#  -frameformat         PPM|PNG|JPEG --> format of the frame-files 
#
#  -firstframe          positive-integer --> repeat first frame n-times
#
#  -lastframe           positive-integer --> repeat first frame n-times
#
#  -delay               positive-integer --> time dalay between frames 
#                                            in 1/100 sec
#  -loop                repeat in movie animation number of times (0=forever)
#
#  -save_to_file        file --> if specified the movie will be saved to file
#                                otherwise the filename will be queried
# 
#
# RETURN VALUE
# Undefined.
#
# EXAMPLE
# scripting::makeMovie::init \
#    -movieformat mpeg \
#    -dir         tmp \
#    -frameformat PPM \
#    -firstframe  10 \
#    -lastframe   10 \
#    -delay       0
#
#****
# ------------------------------------------------------------------------

proc scripting::makeMovie::init {args} {
    variable movie
    global   gifAnim
    
    if { $movie(makeMovie) } {
	error "makeMovie::init called within makeMovie::begin/makeMovie::end, should be called before makeMovie::begin"
    }

    # load defaults
    
    set gifAnim(gif_transp)          0
    set gifAnim(gif_minimize)        0
    set gifAnim(gif_global_colormap) 0
    set gifAnim(edit_param)          1
    set gifAnim(movie_format)        mpeg
    set gifAnim(temp_files_dir)      tmp
    set gifAnim(frame_files_format)  PPM
    set gifAnim(ntime_first_frame)   1
    set gifAnim(ntime_last_frame)    1
    set gifAnim(delay)               0
    set gifAnim(loop)                0
    
    set movie(movieFile)             ""
    
    set i 0
    foreach option $args {
	incr i
	
	if { $i%2 } {
            set tag $option
	} else {	    
            switch -glob -- $tag {
		"-gif_transp" -         
		"-gif_minimize" -       
		"-gif_global_colormap" -
		"-edit_param" {         
		    set tag [string trimleft $tag -]
		    switch $option {
			1 - on - yes { set gifAnim($tag) 1 }
			0 - off - no { set gifAnim($tag) 0 }
			default {
			    ErrorDialog "wrong value $option for $tag option, should be 0 or 1"
			}
		    }
		} 
		"-movieformat" {
		    set option [string tolower $option]
		    switch $option {
			mpeg - gif { set gifAnim(movie_format) $option }
			avi { set gifAnim(movie_format) mpeg }
			default {
			    ErrorDialog "wrong value $option for $tag option, should be \"mpeg\" or \"gif\""
			}
		    }
		} 

		"-dir" {
		    switch $option {
			tmp - pwd { set gifAnim(temp_files_dir) $option }
			default {
			    ErrorDialog "wrong value $option for $tag option, should be \"tmp\" or \"pwd\""
			}
		    }
		} 

		"-frameformat" { 
		    set option [string toupper $option]
		    switch $option {
			PPM - PNG - JPEG { set gifAnim(frame_files_format) $option }
			default {
			    ErrorDialog "wrong value $option for $tag option, should be \"PPM\" or \"JPEG\""
			}
		    }
		} 
		"-ntime_first_frame" - 
		"-firstframe" {
		    if { [nonnegativeInteger $option] } {
			set gifAnim(ntime_first_frame) $option
		    } else {
			ErrorDialog "expected integer, but got $option for $tag option"
		    }
		}
		"-ntime_last_frame" - 
		"-lastframe" {
		    if { [nonnegativeInteger $option] } {
			set gifAnim(ntime_last_frame) $option
		    } else {
			ErrorDialog "expected integer, but got $option for $tag option"
		    }
		}
		"-delay" -
		"-loop" {		    
		    if { [nonnegativeInteger $option] } {
			set elem [string trimleft $tag -]
			set gifAnim($elem) $option
		    } else {
			ErrorDialog "expected integer, but got $option for $tag option"
		    }
		}
		"-save_to_file" {
		    set movie(movieFile) $option
		}		
	    }
	}
    }
    if { $i%2 } {
	ErrorDialog "scripting::makeMovie::init called with an odd number of arguments !!!"
    }
}



# ------------------------------------------------------------------------
#****f* Scripting/scripting::makeMovie::begin
#
# NAME
# scripting::makeMovie::begin
#
# USAGE
# scripting::makeMovie::begin
#
# PURPOSE
#
# This proc marks the beginning of movie creation.
#
# RETURN VALUE
# Undefined.
#
# EXAMPLE
# scripting::makeMovie::begin
#
#****
# ------------------------------------------------------------------------


proc scripting::makeMovie::begin {} {
    variable movie
    global gifAnim

    set movie(makeMovie) 1
    
    if { $gifAnim(movie_format) == "mpeg" } {
	set fmt MPEG
    } else {
	set fmt Animated-GIF
    }
    set movie(notificationMovie) [DisplayUpdateWidget "Recording" "Recording $fmt movie."]
    set gifAnim(make_gifAnim) 0
    gifAnimMake .mesa
}



# ------------------------------------------------------------------------
#****f* Scripting/scripting::makeMovie::makeFrame
#
# NAME
# scripting::makeMovie::makeFrame
#
# USAGE
# scripting::makeMovie::makeFrame
#
# PURPOSE

# This proc makes one movie frame, that is, it flushes (i.e. prints
# to file) the content of the currently displayed object.

#
# WARNINGS

# Note that this proc should be called within scripting::makeMovie::begin 
# and scripting::makeMovie::end calls. The scripting::makeMovie::init
# should be called before "begin; makeFrame; ...; end" sequence.

#
# RETURN VALUE
# Undefined.
#
# EXAMPLE
# scripting::makeMovie::makeFrame
#
#****
# ------------------------------------------------------------------------

proc scripting::makeMovie::makeFrame {} {
    variable movie

    if { $movie(makeMovie) } {
	gifAnimPrintCurrent .mesa
    } else {
	error "makeMovie::makeFrame called outside makeMovie::begin/makeMovie::end"
    }
}


# ------------------------------------------------------------------------
#****f* Scripting/scripting::makeMovie::end
#
# NAME
# scripting::makeMovie::end
#
# USAGE
# scripting::makeMovie::end
#
# PURPOSE
# This proc finishes the movie creation and encodes the movie.
#
# RETURN VALUE
# Undefined.
#
# EXAMPLE
# scripting::makeMovie::end
#
#****
# ------------------------------------------------------------------------

proc scripting::makeMovie::end {} {
    variable movie
    global gifAnim

    if { [winfo exists $movie(notificationMovie)] } {
	destroy $movie(notificationMovie)
    }
    if { $gifAnim(filelist) == "" } { return }

    if { $movie(makeMovie) } {
	if { $movie(movieFile) == "" } {
	    gifAnimMake .mesa
	} else {
	    gifAnimMake .mesa {} {} $movie(movieFile)
	}
	set movie(makeMovie) 0
    } else {
	error "makeMovie::end called before makeMovie::begin"
    }
}