This file is indexed.

/usr/share/tcltk/combat0.8/orb.tcl is in tcl-combat 0.8.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
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
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
#
# ======================================================================
# This file is part of Combat/Tcl, a Tcl CORBA Object Request Broker
#
# Please visit the Combat Web site at http://www.fpx.de/Combat/ for
# more information.
#
# Copyright (c) Frank Pilhofer, combat@fpx.de
#
# ======================================================================
#
# CVS Version Tag: $Id: orb.tcl,v 1.16 2008-11-14 02:06:58 Owner Exp $
#
# ----------------------------------------------------------------------
# The ORB
# ----------------------------------------------------------------------
#

namespace eval Combat {
    namespace eval CORBA {
	variable ORB_conn_cond

	itcl::class ORB {
	    private common requests
	    private common callbacks
	    private common reqid 0
	    private common reqids_timer
	    private common reqids_timedout
	    private common reqids_completed
	    private common fake_asyncs
	    private common objprocid 0
	    public common refs_fwd
	    public common refs_rev
	    public common initial_pseudo_references
	    public common initial_references
	    public common default_init_ref ""
	    public common iiop_serverports
	    public common iiop_servers
	    public common ior_template
	    public common hostname

	    #
	    # send_request and receive_reply are low-level functions
	    # that process a single GIOP request/response.
	    #
	    # They are encapsulated by the higher-level functions
	    # invoke_sync, invoke_async, get_async_reply and
	    # poll_async_reply, which transparently perform a retry
	    # upon LOCATION_FORWARD etc.
	    #

	    private proc send_request {rid response object operation rtype \
			plevel params values {exceptions {}}} {
		incr plevel
		set conn [$object connect]

		if {$response} {
		    set id [$conn send_request $response $object \
			    $operation $plevel $params $values {} \
			    "::Combat::CORBA::ORB::callback $rid"]
		} else {
		    set id [$conn send_request $response $object \
			    $operation $plevel $params $values]
		}

		if {$response} {
		    $conn ref
		    set requests($rid) [list $object $operation $conn $id \
			    $rtype $params $values $exceptions -1]
		} else {
		    set requests($rid) [list $object {} {} $id {} \
			    {} {} {} 0]
		}

		#
		# trigger callback if !response_expected
		#

		if {!$response} {
		    after 0 "::Combat::CORBA::ORB::callback $rid 0"
		}
	    }

	    private proc receive_reply {rid plevel} {
		if {![info exists requests($rid)]} {
		    ::corba::throw [list IDL:omg.org/CORBA/BAD_PARAM:1.0 \
			    [list minor 0 completion_status COMPLETED_MAYBE]]
		}

		set data $requests($rid)
		set object    [lindex $data 0]
		set operation [lindex $data 1]
		set conn      [lindex $data 2]
		set connid    [lindex $data 3]
		set rtype     [lindex $data 4]
		set params    [lindex $data 5]
		set values    [lindex $data 6]
		set exceptions [lindex $data 7]
		set status    [lindex $data 8]

		if {$status != -1} {
		    # This invocation has already completed
		    set res [lindex $data 9]
		    unset requests($rid)
		    return [list $status $res]
		}

		incr plevel

		if {[catch {
		    set res [$conn receive_reply $connid $rtype $plevel \
				 $params $values $exceptions]
		} oops]} {
		    #
		    # This should only occur when the request was canceled.
		    #

		    set res [list -1]
		}

		$conn deref

		set status [lindex $res 0]
		switch -- $status {
		    0 -
		    1 -
		    2 {
			# After a successful method invocation, we set a
			# flag that allows the object to reuse its entire
			# set of profiles after disconnecting
			$object configure -reset_profile 1
		    }
		    3 { # LOCATION_FORWARD
			#
			# A LOCATION_FORWARD is also indicated, without a
			# new IOR, upon receiving a CloseConnection message.
			#
			if {[llength $res] == 2} {
			    $object forward [lindex $res 1]
			} else {
			    $object next_profile
			}
		    }
		    4 { # LOCATION_FORWARD_PERM
			$object forward [lindex $res 1] 1
		    }
		    5 { # NEEDS_ADDRESSING_MODE
			$object configure -AddressingDisposition [lindex $res 1]
		    }
		}

		#
		# Resend request
		#

		if {$status == 3 || $status == 4 || $status == 5} {
		    unset requests($rid)

		    if {[catch {
			send_request $rid 1 $object $operation $rtype \
			    $plevel $params $values $exceptions
		    } res]} {
			#
			# Re-sending the request has failed, e.g., because we
			# have run out of forwarding addresses.  Re-instate the
			# request data so that a future receive_reply will
			# return the appropriate exception.
			#

			set requests($rid) [list $object $operation $conn $connid \
						$rtype $params $values $exceptions \
						2 $res]

			return 2
		    }

		    return 0
		}

		if {$status != -1} {
		    unset requests($rid)
		}

		return $res
	    }

	    #
	    # Synchronous invocation of requests
	    #

	    public proc invoke_sync {response object operation rtype \
			plevel params values {exceptions {}} {timeout 0}} {
		incr plevel
		set rid [incr reqid]
		send_request $rid $response $object $operation $rtype \
		    $plevel $params $values $exceptions
		#
		# oneway ?
		#

		if {!$response} {
		    unset requests($rid)
		    return
		}

		#
		# Set up id mapping
		#

		set reqids_completed($rid) 0

		#
		# Set up timeout
		#

		if {$timeout} {
		    set reqids_timer($rid) [after $timeout "::Combat::CORBA::ORB::timeout $reqid"]
		}

		#
		# wait for reply
		#

		vwait [itcl::scope reqids_completed($rid)]

		if {![info exists reqids_completed($rid)]} {
		    ::corba::throw [list IDL:omg.org/CORBA/BAD_INV_ORDER:1.0 \
					[list minor 0 completion_status COMPLETED_MAYBE]]
		}

		#
		# Handle timeout
		#

		if {[info exists reqids_timedout($rid)]} {
		    unset reqids_timedout($rid)
		    unset reqids_completed($rid)
		    ::corba::throw [list IDL:omg.org/CORBA/TIMEOUT:1.0 \
			    [list minor 0 completion_status COMPLETED_MAYBE]]
		}

		#
		# Get reply
		#

		set res [receive_reply $rid $plevel]

		#
		# Clean up
		#

		unset reqids_completed($rid)

		#
		# Evaluate response
		#

		set status [lindex $res 0]
		switch -- $status {
		    0 { # NO_EXCEPTION
			return [lindex $res 1]
		    }
		    1 { # USER_EXCEPTION
			error [lindex $res 1]
		    }
		    2 { # SYSTEM_EXCEPTION
			error [lindex $res 1]
		    }
		    default {
			::corba::throw [list IDL:omg.org/CORBA/INTERNAL:1.0 \
				[list minor 0 completion_status COMPLETED_NO \
				debug "status is $status"]]
		    }
		}

		::corba::throw [list IDL:omg.org/CORBA/INTERNAL:1.0 \
			[list minor 0 completion_status COMPLETED_NO]]
	    }

	    #
	    # Asynchronous invocation
	    #

	    public proc invoke_async {response object operation rtype \
		    plevel params values {exceptions {}} {callback {}} \
		    {timeout 0}} {
		incr plevel
		set rid [incr reqid]
		set reqids_completed($rid) 0

		send_request $rid $response $object $operation $rtype \
		    $plevel $params $values $exceptions

		if {$callback != ""} {
		    set callbacks($rid) $callback
		}

		if {$timeout} {
		    set reqids_timer($rid) [after $timeout "::Combat::CORBA::ORB::timeout $reqid"]
		}

		return $reqid
	    }

	    public proc fake_async {status result {callback {}}} {
		incr reqid
		set fake_asyncs($reqid) [list $status $result $callback]

		if {$callback != ""} {
		    set callbacks($reqid) $callback
		    after 0 "::Combat::CORBA::ORB::callback $reqid $status"
		}

		return $reqid
	    }

	    public proc get_async_reply {rid plevel} {
		incr plevel

		#
		# See if the request has already timed out
		#

		if {[info exists reqids_timedout($rid)]} {
		    unset reqids_timedout($rid)
		    ::corba::throw [list IDL:omg.org/CORBA/TIMEOUT:1.0 \
			    [list minor 0 completion_status COMPLETED_MAYBE]]
		}

		if {[info exists fake_asyncs($rid)]} {
		    set res $fake_asyncs($rid)
		    unset fake_asyncs($rid)
		    set status [lindex $res 0]

		    switch -- $status {
			0 { # NO_EXCEPTION
			    return [lindex $res 1]
			}
			1 { # USER_EXCEPTION
			    error [lindex $res 1]
			}
			2 { # SYSTEM_EXCEPTION
			    error [lindex $res 1]
			}
		    }

		    error "oops"
		}

		if {![info exists reqids_completed($rid)]} {
		    ::corba::throw [list IDL:omg.org/CORBA/BAD_PARAM:1.0 \
			    [list minor 0 completion_status COMPLETED_MAYBE]]
		}

		#
		# wait for reply
		#

		if {!$reqids_completed($rid)} {
		    vwait [itcl::scope reqids_completed($rid)]
		}

		if {![info exists reqids_completed($rid)]} {
		    ::corba::throw [list IDL:omg.org/CORBA/BAD_INV_ORDER:1.0 \
					[list minor 0 completion_status COMPLETED_MAYBE]]
		}

		#
		# Handle timeout
		#

		if {[info exists reqids_timedout($rid)]} {
		    unset reqids_timedout($rid)
		    unset reqids_completed($rid)
		    ::corba::throw [list IDL:omg.org/CORBA/TIMEOUT:1.0 \
			    [list minor 0 completion_status COMPLETED_MAYBE]]
		}

		#
		# Get reply
		#

		set res [receive_reply $rid $plevel]

		#
		# Clean up
		#

		unset reqids_completed($rid)

		#
		# Evaluate response
		#

		set status [lindex $res 0]
		switch -- $status {
		    0 { # NO_EXCEPTION
			return [lindex $res 1]
		    }
		    1 { # USER_EXCEPTION
			error [lindex $res 1]
		    }
		    2 { # SYSTEM_EXCEPTION
			error [lindex $res 1]
		    }
		    default {
			::corba::throw [list IDL:omg.org/CORBA/INTERNAL:1.0 \
				[list minor 0 completion_status COMPLETED_NO \
				debug "status is $status"]]
		    }
		}

		::corba::throw [list IDL:omg.org/CORBA/INTERNAL:1.0 \
			[list minor 0 completion_status COMPLETED_NO]]
	    }

	    public proc poll_async_reply {rid} {
		#
		# reqids_completed($rid) exists for all outstanding remote
		# requests.
		#

		if {[info exists reqids_completed($rid)]} {
		    return $reqids_completed($rid)
		}

		#
		# We should only get here for fake async requests, which
		# are always ready.
		#

		if {![info exists fake_async($rid)]} {
		    ::corba::throw [list IDL:omg.org/CORBA/BAD_PARAM:1.0 \
			    [list minor 0 completion_status COMPLETED_MAYBE]]
		}

		return 1
	    }

	    public proc cancel_async_request {rid} {
		if {[info exists reqids_timedout($rid)]} {
		    unset reqids_timedout($rid)
		    unset reqids_completed($rid)
		    return
		}

		if {[info exists fake_asyncs($rid)]} {
		    unset $fake_asyncs($rid)
		    return
		}

		if {![info exists reqids_completed($rid)]} {
		    ::corba::throw [list IDL:omg.org/CORBA/BAD_PARAM:1.0 \
			    [list minor 0 completion_status COMPLETED_MAYBE]]
		}

		#
		# Cancel timeout
		#

		if {[info exists reqids_timer($rid)] && \
			![info exists reqids_timedout($rid)]} {
		    after cancel $reqids_timer($rid)
		    unset reqids_timer($rid)
		}

		#
		# Clean up
		#

		set data $requests($rid)
		unset requests($rid)

		if {[info exists reqids_completed($rid)]} {
		    unset reqids_completed($rid)
		}

		if {[info exists callbacks($rid)]} {
		    unset callbacks($rid)
		}

		#
		# Inform the connection that this request is canceled
		#

		set conn [lindex $data 2]
		set connid [lindex $data 3]
		$conn cancel_request $connid
		$conn deref
	    }

	    #
	    # Incoming invocation from GIOP
	    #

	    public proc invoke {response_expected \
		    conn request_id object_key \
		    operation decoder contexts} {

		#
		# gotta hand this over to an object adapter
		#

		::Combat::PortableServer::RootPOA::invoke $response_expected \
			$conn $request_id $object_key \
			$operation $decoder $contexts
	    }

	    public proc locate {conn request_id object_key} {
		#
		# gotta hand this over to an object adapter
		#

		::Combat::PortableServer::RootPOA::locate \
			$conn $request_id $object_key
	    }

	    #
	    # Callback from GIOP connection
	    #

	    public proc callback {rid status} {
		#
		# Transparently try again in case of LOCATION_FORWARD,
		# LOCATION_FORWARD_PERM or NEEDS_ADDRESSING_MODE. This
		# retry is performed by receive_reply.
		#

		if {$status == 3 || $status == 4 || $status == 5} {
		    if {[receive_reply $rid 0] == 0} {
			#
			# Ok, forwarded the request.
			#

			return
		    }

		    #
		    # Forwarding the request has failed.  Fall through and
		    # act as if the request has completed.
		    #
		}

		#
		# This request has completed
		#

		set reqids_completed($rid) 1
		set ::Combat::CORBA::ORB_conn_cond 1

		#
		# Cancel timeout
		#

		if {[info exists reqids_timer($rid)] && \
			![info exists reqids_timedout($rid)]} {
		    after cancel $reqids_timer($rid)
		    unset reqids_timer($rid)
		}

		#
		# Call user callback
		#

		if {[info exists callbacks($rid)]} {
		    set callback $callbacks($rid)
		    unset callbacks($rid)
		    uplevel #0 "$callback $rid"
		}
	    }

	    #
	    # Callback from "after" upon timeout
	    #

	    public proc timeout {rid} {
		#
		# Forget everything we ever knew about this request
		#

		set reqids_timedout($rid) 1
		set reqids_completed($rid) 1
		set data $requests($rid)
		unset requests($rid)
		unset reqids_timer($rid)

		#
		# Inform the connection that this request is canceled
		#

		set conn [lindex $data 2]
		set connid [lindex $data 3]
		$conn cancel_request $connid
		$conn deref

		#
		# Call this request's callback so that it learns about it
		#

		if {[info exists callbacks($rid)]} {
		    set callback $callbacks($rid)
		    unset callbacks($rid)
		    uplevel #0 "$callback $rid"
		}

		set ::Combat::CORBA::ORB_conn_cond 1
	    }

	    #
	    # Object Reference Handling
	    #

	    public proc MakeObjProc {obj} {
		incr objprocid
		set ref "_combat_obj_$objprocid"
		uplevel #0 proc $ref {args} \{ \
			eval ::Combat::CORBA::ORB::object_invoke $obj \$args \
			\}
		set refs_fwd($ref) $obj
		set refs_rev($obj) $ref
		return $ref
	    }

	    public proc GetObjFromRef {ref} {
		if {$ref == "0"} {
		    return 0
		}
		if {![info exists refs_fwd($ref)]} {
		    ::corba::throw [list IDL:omg.org/CORBA/BAD_PARAM:1.0 \
			    [list minor 0 completion_status COMPLETED_NO]]
		}
		return $refs_fwd($ref)
	    }

	    public proc GetRefFromObj {obj} {
		if {$ref == "0"} {
		    return 0
		}
		if {![info exists refs_rev($obj)]} {
		    ::corba::throw [list IDL:omg.org/CORBA/BAD_PARAM:1.0 \
			    [list minor 0 completion_status COMPLETED_NO]]
		}
		return $refs_rev($obj)
	    }

	    public proc ReleaseRef {ref} {
		if {$ref == "0"} {
		    return
		}
		set obj [GetObjFromRef $ref]
		unset refs_fwd($ref)
		unset refs_rev($obj)
		itcl::delete object $obj
		uplevel #0 rename $ref \"\"
	    }

	    #
	    # Method invocation
	    #

	    public proc object_invoke {obj args} {
		set idx 0
		set async 0
		set callback ""
		set response 1
		set timeout 0

		while {$idx < [llength $args]} {
		    if {[lindex $args $idx] == "-async"} {
			set async 1
			incr idx
		    } elseif {[lindex $args $idx] == "-callback"} {
			incr idx
			set async 1
			set callback [lindex $args $idx]
			incr idx
		    } elseif {[lindex $args $idx] == "-timeout"} {
			incr idx
			set timeout [lindex $args $idx]
			incr idx
		    } else {
			break
		    }
		}

		if {!$timeout} {
		    set timeout [$obj cget -timeout]
		}

		set operation [lindex $args $idx]
		incr idx
		set values [lrange $args $idx end]

		if {$operation == ""} {
		    error "usage: $refs_rev($obj) op ?parameters ...?"
		}

		if {$operation == "_is_a" || \
			$operation == "_get_interface" || \
			$operation == "_non_existent" || \
			$operation == "_duplicate"} {
		    switch -- $operation {
			_is_a {
			    if {[llength $values] != 1} {
				error "usage: $refs_rev($obj) _is_a repoid"
			    }
			    if {!$async} {
				return [$obj _is_a [lindex $values 0]]
			    }
			    set theop "_is_a"
			    set rtype "boolean"
			    set params {{in string}}
			}
			_get_interface {
			    if {[llength $values] != 0} {
				error "usage: $refs_rev($obj) _get_interface"
			    }
			    if {!$async} {
				return [$obj _get_interface]
			    }
			    set theop "_interface"
			    set rtype "Object"
			    set params [list]
			}
			_non_existent {
			    if {[llength $values] != 0} {
				error "usage: $refs_rev($obj) _non_existent"
			    }
			    if {!$async} {
				return [$obj _non_existent]
			    }
			    set theop "_non_existent"
			    set rtype "boolean"
			    set params [list]
			}
			_duplicate {
			    return [corba::string_to_object \
				    [corba::object_to_string \
				    $refs_rev($obj)]]
			}
			default {
			    error "oops"
			}
		    }

		    if {$async} {
			return [invoke_async 1 $obj $theop $rtype 2 \
				$params $values {} $callback $timeout]
		    }

		    return [invoke_sync 1 $obj $theop $rtype 2 \
				$params $values {} $timeout]
		}

		if {$operation == "_is_equivalent"} {
		    if {[llength $values] != 1} {
			error "usage: $refs_rev($obj) _is_equivalent ref"
		    }
		    set otherobj [GetObjFromRef [lindex $values 0]]
		    if {[catch {
			set res [$obj _is_equivalent $otherobj]
		    } err]} {
			set status 2
			set res $err
		    } else {
			set status 0
		    }
		    if {$async} {
			return [fake_async $status $res $callback]
		    }
		    if {$status == 2} {
			error $res
		    }
		    return $res
		}

		if {![::Combat::SimpleTypeRepository::UpdateTypeInfoForObj $obj]} {
		    ::corba::throw [list IDL:omg.org/CORBA/INTF_REPOS:1.0 \
			    [list minor 0 completion_status COMPLETED_NO]]
		}

		set type [$obj cget -type_id]

		set opInfo [::Combat::SimpleTypeRepository::getOp \
			$type $operation]

		if {$opInfo == ""} {
		    set atInfo [::Combat::SimpleTypeRepository::getAttr \
			    $type $operation]
		} else {
		    set atInfo ""
		}

		if {$opInfo == "" && $atInfo == ""} {
		    if {![::Combat::SimpleTypeRepository::UpdateTypeInfoForObj $obj 1]} {
			::corba::throw [list IDL:omg.org/CORBA/INTF_REPOS:1.0 \
				[list minor 0 completion_status COMPLETED_NO]]
		    }
		    
		    set type [$obj cget -type_id]
		    set opInfo [::Combat::SimpleTypeRepository::getOp \
			    $type $operation]
		    set atInfo [::Combat::SimpleTypeRepository::getAttr \
			    $type $operation]
		    if {$opInfo == "" && $atInfo == ""} {
			error "error: $operation is neither operation nor attribute for $type"
		    }
		}

		if {$opInfo != ""} {
		    set rtype [lindex $opInfo 9]
		    set params [lindex $opInfo 15]
		    set exceptions [lindex $opInfo 17]

		    if {[llength $params] != [llength $values]} {
			error "error: operation $operation wants [llength $params] parameters, not [llength $values]"
		    }

		    if {[lindex $opInfo 11] == "OP_ONEWAY"} {
			set response 0
		    }

		    if {$async} {
			return [invoke_async $response $obj $operation \
				$rtype 2 $params $values $exceptions \
				$callback $timeout]
		    }

		    return [invoke_sync $response $obj $operation \
			    $rtype 2 $params $values $exceptions \
			    $timeout]
		}

		if {$atInfo != ""} {
		    set attype [lindex $atInfo 9]

		    if {[llength $values] == 0} {
			if {[llength $atInfo] > 13} {
			    set get_exceptions [lindex $atInfo 13]
			} else {
			    set get_exceptions [list]
			}
			if {$async} {
			    return [invoke_async 1 $obj _get_$operation \
				    $attype 0 {} {} $get_exceptions \
				    $callback $timeout]
			}
			return [invoke_sync 1 $obj _get_$operation \
				$attype 0 {} {} {} $timeout]
		    } elseif {[llength $values] == 1} {
			if {[lindex $atInfo 11] == "ATTR_READONLY"} {
			    error "error: attribute $operation is readonly"
			}
			if {[llength $atInfo] > 15} {
			    set set_exceptions [lindex $atInfo 15]
			} else {
			    set set_exceptions [list]
			}
			if {$async} {
			    return [invoke_async 1 $obj _set_$operation \
				    void 0 [list [list in $attype]] $values \
				    $set_exceptions $callback $timeout]
			}

			return [invoke_sync 1 $obj _set_$operation \
				void 0 [list [list in $attype]] $values \
				{} $timeout]
		    }

		    error "attribute get wants 0, attribute set 1 parameter"
		}

		error "oops, I should not be here."
	    }

	    #
	    # corba::dii ?-async? ref spec args
	    #
	    # spec: [list returntype opname params exceptions]
	    #

	    public proc dii_invoke {args} {
		set idx 0
		set async 0
		set callback ""
		set response 1
		set timeout 0

		while {$idx < [llength $args]} {
		    if {[lindex $args $idx] == "-async"} {
			set async 1
			incr idx
		    } elseif {[lindex $args $idx] == "-callback"} {
			incr idx
			set async 1
			set callback [lindex $args $idx]
			incr idx
		    } elseif {[lindex $args $idx] == "-timeout"} {
			incr idx
			set timeout [lindex $args $idx]
			incr idx
		    } else {
			break
		    }
		}

		set ref [lindex $args $idx]
		set obj [GetObjFromRef $ref]
		incr idx

		set spec [lindex $args $idx]
		incr idx

		if {$idx > [llength $args]} {
		    error "too few arguments to dii_invoke"
		}

		if {[llength $spec] < 3} {
		    error "illegal dii call specification"
		}

		set rtype [lindex $spec 0]
		set operation [lindex $spec 1]
		set params [lindex $spec 2]
		set exceptions [lindex $spec 3]
		set values [lrange $args $idx end]

		if {[llength $spec] == 4 && \
			([lindex $spec 3] == "OP_ONEWAY" || \
			[lindex $spec 4] == "oneway")} {
		    set response 0
		}

		if {!$timeout} {
		    set timeout [$obj cget -timeout]
		}

		if {$async} {
		    return [invoke_async $response $obj $operation \
			    $rtype 2 $params $values $exceptions \
			    $callback $timeout]
		}

		return [invoke_sync $response $obj $operation \
			$rtype 2 $params $values $exceptions \
			$timeout]
	    }
	}
    }
}