p4ruby 2020.1.2056123-x64-mingw32 → 2021.1.2265066-x64-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE.txt +451 -20
- data/README.md +14 -1
- data/ext/P4/clientprogressruby.cpp +0 -1
- data/ext/P4/clientuserruby.cpp +254 -1
- data/ext/P4/clientuserruby.h +26 -1
- data/ext/P4/extconf.rb +11 -11
- data/ext/P4/p4.cpp +100 -1
- data/ext/P4/p4clientapi.cpp +73 -0
- data/ext/P4/p4clientapi.h +13 -0
- data/ext/P4/p4specdata.cpp +29 -0
- data/ext/P4/p4specdata.h +2 -0
- data/ext/P4/specmgr.cpp +43 -35
- data/lib/2.6/P4.so +0 -0
- data/lib/2.7/P4.so +0 -0
- data/lib/3.0/P4.so +0 -0
- data/lib/P4/version.rb +1 -1
- data/lib/P4.rb +16 -0
- data/lib/P4.so +0 -0
- metadata +7 -6
data/ext/P4/clientuserruby.cpp
CHANGED
@@ -38,6 +38,7 @@
|
|
38
38
|
#include <ruby.h>
|
39
39
|
#include "undefdups.h"
|
40
40
|
#include <p4/clientapi.h>
|
41
|
+
#include <p4/strtable.h>
|
41
42
|
#include <p4/clientprog.h>
|
42
43
|
#include <p4/spec.h>
|
43
44
|
#include <p4/diff.h>
|
@@ -65,6 +66,19 @@ static const int CANCEL = 2;
|
|
65
66
|
* server, and converts the data to Ruby form for returning to the caller.
|
66
67
|
******************************************************************************/
|
67
68
|
|
69
|
+
class SSOShim : public ClientSSO {
|
70
|
+
public:
|
71
|
+
SSOShim(ClientUserRuby *ui) : ui(ui) {}
|
72
|
+
virtual ClientSSOStatus Authorize( StrDict &vars,
|
73
|
+
int maxLength,
|
74
|
+
StrBuf &result )
|
75
|
+
{
|
76
|
+
return ui->Authorize(vars, maxLength, result);
|
77
|
+
}
|
78
|
+
private:
|
79
|
+
ClientUserRuby *ui;
|
80
|
+
} ;
|
81
|
+
|
68
82
|
ClientUserRuby::ClientUserRuby(SpecMgr *s) {
|
69
83
|
specMgr = s;
|
70
84
|
debug = 0;
|
@@ -77,14 +91,22 @@ ClientUserRuby::ClientUserRuby(SpecMgr *s) {
|
|
77
91
|
rubyExcept = 0;
|
78
92
|
alive = 1;
|
79
93
|
track = false;
|
94
|
+
SetSSOHandler( new SSOShim( this ) );
|
95
|
+
|
96
|
+
ssoEnabled = 0;
|
97
|
+
ssoResultSet = 0;
|
98
|
+
ssoResult = Qnil;
|
99
|
+
ssoHandler = Qnil;
|
80
100
|
|
81
101
|
ID idP4 = rb_intern("P4");
|
82
102
|
ID idP4OH = rb_intern("OutputHandler");
|
83
103
|
ID idP4Progress = rb_intern("Progress");
|
104
|
+
ID idP4SSO = rb_intern("SSOHandler");
|
84
105
|
|
85
106
|
VALUE cP4 = rb_const_get_at(rb_cObject, idP4);
|
86
107
|
cOutputHandler = rb_const_get_at(cP4, idP4OH);
|
87
108
|
cProgress = rb_const_get_at(cP4, idP4Progress );
|
109
|
+
cSSOHandler = rb_const_get_at(cP4, idP4SSO);
|
88
110
|
}
|
89
111
|
|
90
112
|
void ClientUserRuby::Reset() {
|
@@ -719,8 +741,239 @@ void ClientUserRuby::GCMark() {
|
|
719
741
|
if (mergeResult != Qnil) rb_gc_mark( mergeResult);
|
720
742
|
if (handler != Qnil) rb_gc_mark( handler);
|
721
743
|
if (progress != Qnil) rb_gc_mark( progress );
|
722
|
-
rb_gc_mark(
|
744
|
+
if (ssoResult != Qnil) rb_gc_mark( ssoResult );
|
745
|
+
if (ssoHandler != Qnil) rb_gc_mark( ssoHandler );
|
746
|
+
rb_gc_mark( cOutputHandler );
|
723
747
|
rb_gc_mark( cProgress );
|
748
|
+
rb_gc_mark( cSSOHandler );
|
724
749
|
|
725
750
|
results.GCMark();
|
726
751
|
}
|
752
|
+
|
753
|
+
|
754
|
+
/*
|
755
|
+
* Set the Handler object. Double-check that it is either nil or
|
756
|
+
* an instance of OutputHandler to avoid future problems
|
757
|
+
*/
|
758
|
+
|
759
|
+
VALUE
|
760
|
+
ClientUserRuby::SetRubySSOHandler(VALUE h) {
|
761
|
+
if (P4RDB_CALLS) fprintf(stderr, "[P4] SetSSOHandler()\n");
|
762
|
+
|
763
|
+
if (Qnil != h && Qfalse == rb_obj_is_kind_of(h, cSSOHandler)) {
|
764
|
+
rb_raise(eP4, "Handler needs to be an instance of P4::SSOHandler");
|
765
|
+
return Qfalse;
|
766
|
+
}
|
767
|
+
|
768
|
+
ssoHandler = h;
|
769
|
+
alive = 1; // ensure that we don't drop out after the next call
|
770
|
+
|
771
|
+
return Qtrue;
|
772
|
+
}
|
773
|
+
|
774
|
+
|
775
|
+
// returns true if output should be reported
|
776
|
+
// false if the output is handled and should be ignored
|
777
|
+
static VALUE CallMethodSSO(VALUE data) {
|
778
|
+
VALUE *args = reinterpret_cast<VALUE *>(data);
|
779
|
+
return rb_funcall(args[0], (ID) rb_intern("authorize"), 2, args[1], args[2]);
|
780
|
+
}
|
781
|
+
|
782
|
+
ClientSSOStatus
|
783
|
+
ClientUserRuby::CallSSOMethod(VALUE vars, int maxLength, StrBuf &result) {
|
784
|
+
ClientSSOStatus answer = CSS_SKIP;
|
785
|
+
int excepted = 0;
|
786
|
+
result.Clear();
|
787
|
+
|
788
|
+
if (P4RDB_COMMANDS) fprintf(stderr, "[P4] CallSSOMethod\n");
|
789
|
+
|
790
|
+
// some wild hacks to satisfy the rb_protect method
|
791
|
+
|
792
|
+
VALUE args[3] = { ssoHandler, vars, INT2NUM( maxLength ) };
|
793
|
+
|
794
|
+
VALUE res = rb_protect(CallMethodSSO, (VALUE) args, &excepted);
|
795
|
+
|
796
|
+
if (excepted) { // exception thrown
|
797
|
+
alive = 0;
|
798
|
+
rb_jump_tag(excepted);
|
799
|
+
} else if( FIXNUM_P( res ) ) {
|
800
|
+
int a = NUM2INT(res);
|
801
|
+
if (P4RDB_COMMANDS)
|
802
|
+
fprintf(stderr, "[P4] CallSSOMethod returned %d\n", a);
|
803
|
+
|
804
|
+
if( a < CSS_PASS || a > CSS_SKIP )
|
805
|
+
rb_raise(eP4, "P4::SSOHandler::authorize returned out of range response");
|
806
|
+
answer = (ClientSSOStatus) a;
|
807
|
+
} else if( Qtrue == rb_obj_is_kind_of(res, rb_cArray) ) {
|
808
|
+
VALUE resval1 = rb_ary_shift(res);
|
809
|
+
Check_Type( resval1, T_FIXNUM );
|
810
|
+
int a = NUM2INT(resval1);
|
811
|
+
if( a < CSS_PASS || a > CSS_SKIP )
|
812
|
+
rb_raise(eP4, "P4::SSOHandler::authorize returned out of range response");
|
813
|
+
answer = (ClientSSOStatus) a;
|
814
|
+
|
815
|
+
VALUE resval2 = rb_ary_shift(res);
|
816
|
+
if( resval2 != Qnil )
|
817
|
+
{
|
818
|
+
Check_Type( resval2, T_STRING );
|
819
|
+
result.Set(StringValuePtr(resval2));
|
820
|
+
if (P4RDB_COMMANDS)
|
821
|
+
fprintf(stderr, "[P4] CallSSOMethod returned %d, %s\n", a, result.Text());
|
822
|
+
}
|
823
|
+
|
824
|
+
} else {
|
825
|
+
Check_Type( res, T_STRING );
|
826
|
+
answer = CSS_PASS;
|
827
|
+
|
828
|
+
result.Set(StringValuePtr(res));
|
829
|
+
if (P4RDB_COMMANDS)
|
830
|
+
fprintf(stderr, "[P4] CallSSOMethod returned %s\n", result.Text());
|
831
|
+
|
832
|
+
}
|
833
|
+
|
834
|
+
return answer;
|
835
|
+
}
|
836
|
+
|
837
|
+
ClientSSOStatus
|
838
|
+
ClientUserRuby::Authorize( StrDict &vars, int maxLength, StrBuf &strbuf )
|
839
|
+
{
|
840
|
+
ssoVars.Clear();
|
841
|
+
|
842
|
+
if( ssoHandler != Qnil )
|
843
|
+
{
|
844
|
+
ClientSSOStatus res = CallSSOMethod( specMgr->StrDictToHash(&vars), maxLength, strbuf );
|
845
|
+
if( res != CSS_SKIP )
|
846
|
+
return res;
|
847
|
+
if (P4RDB_COMMANDS)
|
848
|
+
fprintf(stderr, "[P4] Authorize skipped result from SSO Handler\n" );
|
849
|
+
}
|
850
|
+
|
851
|
+
if( !ssoEnabled )
|
852
|
+
return CSS_SKIP;
|
853
|
+
|
854
|
+
if( ssoEnabled < 0 )
|
855
|
+
return CSS_UNSET;
|
856
|
+
|
857
|
+
if( ssoResultSet )
|
858
|
+
{
|
859
|
+
strbuf.Clear();
|
860
|
+
VALUE resval = ssoResult;
|
861
|
+
|
862
|
+
//if( P4RDB_CALLS )
|
863
|
+
// std::cerr << "[P4] ClientSSO::Authorize(). Using supplied input"
|
864
|
+
// << std::endl;
|
865
|
+
|
866
|
+
if (Qtrue == rb_obj_is_kind_of(ssoResult, rb_cArray)) {
|
867
|
+
resval = rb_ary_shift(ssoResult);
|
868
|
+
}
|
869
|
+
|
870
|
+
if( resval != Qnil ) {
|
871
|
+
// Convert whatever's left into a string
|
872
|
+
ID to_s = rb_intern("to_s");
|
873
|
+
VALUE str = rb_funcall(resval, to_s, 0);
|
874
|
+
strbuf.Set(StringValuePtr(str));
|
875
|
+
}
|
876
|
+
|
877
|
+
return ssoResultSet == 2 ? CSS_FAIL
|
878
|
+
: CSS_PASS;
|
879
|
+
}
|
880
|
+
|
881
|
+
ssoVars.CopyVars( vars );
|
882
|
+
return CSS_EXIT;
|
883
|
+
}
|
884
|
+
|
885
|
+
VALUE
|
886
|
+
ClientUserRuby::EnableSSO( VALUE e )
|
887
|
+
{
|
888
|
+
if( e == Qnil )
|
889
|
+
{
|
890
|
+
ssoEnabled = 0;
|
891
|
+
return Qtrue;
|
892
|
+
}
|
893
|
+
|
894
|
+
if( e == Qtrue )
|
895
|
+
{
|
896
|
+
ssoEnabled = 1;
|
897
|
+
return Qtrue;
|
898
|
+
}
|
899
|
+
|
900
|
+
if( e == Qfalse )
|
901
|
+
{
|
902
|
+
ssoEnabled = -1;
|
903
|
+
return Qtrue;
|
904
|
+
}
|
905
|
+
|
906
|
+
return Qfalse;
|
907
|
+
}
|
908
|
+
|
909
|
+
VALUE
|
910
|
+
ClientUserRuby::SSOEnabled()
|
911
|
+
{
|
912
|
+
if( ssoEnabled == 1 )
|
913
|
+
{
|
914
|
+
return Qtrue;
|
915
|
+
}
|
916
|
+
else if( ssoEnabled == -1 )
|
917
|
+
{
|
918
|
+
return Qfalse;
|
919
|
+
}
|
920
|
+
else
|
921
|
+
{
|
922
|
+
return Qnil;
|
923
|
+
}
|
924
|
+
}
|
925
|
+
|
926
|
+
VALUE
|
927
|
+
ClientUserRuby::SetSSOPassResult( VALUE i )
|
928
|
+
{
|
929
|
+
ssoResultSet = 1;
|
930
|
+
return SetSSOResult( i );
|
931
|
+
}
|
932
|
+
|
933
|
+
VALUE
|
934
|
+
ClientUserRuby::GetSSOPassResult()
|
935
|
+
{
|
936
|
+
if( ssoResultSet == 1 )
|
937
|
+
{
|
938
|
+
return ssoResult;
|
939
|
+
}
|
940
|
+
else
|
941
|
+
{
|
942
|
+
return Qnil;
|
943
|
+
}
|
944
|
+
}
|
945
|
+
|
946
|
+
VALUE
|
947
|
+
ClientUserRuby::SetSSOFailResult( VALUE i )
|
948
|
+
{
|
949
|
+
ssoResultSet = 2;
|
950
|
+
return SetSSOResult( i );
|
951
|
+
}
|
952
|
+
|
953
|
+
VALUE
|
954
|
+
ClientUserRuby::GetSSOFailResult()
|
955
|
+
{
|
956
|
+
if( ssoResultSet == 2 )
|
957
|
+
{
|
958
|
+
return ssoResult;
|
959
|
+
}
|
960
|
+
else
|
961
|
+
{
|
962
|
+
return Qnil;
|
963
|
+
}
|
964
|
+
}
|
965
|
+
|
966
|
+
VALUE
|
967
|
+
ClientUserRuby::SetSSOResult( VALUE i )
|
968
|
+
{
|
969
|
+
if (P4RDB_CALLS) fprintf(stderr, "[P4] P4ClientSSO::SetResult()\n");
|
970
|
+
|
971
|
+
ssoResult = i;
|
972
|
+
return Qtrue;
|
973
|
+
}
|
974
|
+
|
975
|
+
VALUE
|
976
|
+
ClientUserRuby::GetSSOVars()
|
977
|
+
{
|
978
|
+
return specMgr->StrDictToHash( &ssoVars );
|
979
|
+
}
|
data/ext/P4/clientuserruby.h
CHANGED
@@ -42,7 +42,7 @@
|
|
42
42
|
class SpecMgr;
|
43
43
|
class ClientProgress;
|
44
44
|
|
45
|
-
class ClientUserRuby: public ClientUser, public KeepAlive {
|
45
|
+
class ClientUserRuby: public ClientUser, public ClientSSO, public KeepAlive {
|
46
46
|
public:
|
47
47
|
ClientUserRuby(SpecMgr *s);
|
48
48
|
|
@@ -101,6 +101,21 @@ public:
|
|
101
101
|
return progress;
|
102
102
|
}
|
103
103
|
|
104
|
+
// SSO handler support
|
105
|
+
|
106
|
+
virtual ClientSSOStatus Authorize( StrDict &vars, int maxLength, StrBuf &result );
|
107
|
+
VALUE EnableSSO( VALUE e );
|
108
|
+
VALUE SSOEnabled();
|
109
|
+
VALUE SetSSOPassResult( VALUE i );
|
110
|
+
VALUE GetSSOPassResult();
|
111
|
+
VALUE SetSSOFailResult( VALUE i );
|
112
|
+
VALUE GetSSOFailResult();
|
113
|
+
VALUE GetSSOVars();
|
114
|
+
VALUE SetRubySSOHandler( VALUE handler );
|
115
|
+
VALUE GetRubySSOHandler() {
|
116
|
+
return ssoHandler;
|
117
|
+
}
|
118
|
+
|
104
119
|
// override from KeepAlive
|
105
120
|
virtual int IsAlive() {
|
106
121
|
return alive;
|
@@ -112,6 +127,8 @@ private:
|
|
112
127
|
void ProcessOutput(const char * method, VALUE data);
|
113
128
|
void ProcessMessage(Error * e);
|
114
129
|
bool CallOutputMethod(const char * method, VALUE data);
|
130
|
+
VALUE SetSSOResult( VALUE i );
|
131
|
+
ClientSSOStatus CallSSOMethod(VALUE vars, int maxLength, StrBuf &result);
|
115
132
|
|
116
133
|
private:
|
117
134
|
StrBuf cmd;
|
@@ -124,10 +141,18 @@ private:
|
|
124
141
|
VALUE cOutputHandler;
|
125
142
|
VALUE progress;
|
126
143
|
VALUE cProgress;
|
144
|
+
VALUE cSSOHandler;
|
127
145
|
int debug;
|
128
146
|
int apiLevel;
|
129
147
|
int alive;
|
130
148
|
int rubyExcept;
|
131
149
|
bool track;
|
150
|
+
|
151
|
+
// SSO handler support
|
152
|
+
int ssoEnabled;
|
153
|
+
int ssoResultSet;
|
154
|
+
StrBufDict ssoVars;
|
155
|
+
VALUE ssoResult;
|
156
|
+
VALUE ssoHandler;
|
132
157
|
};
|
133
158
|
|
data/ext/P4/extconf.rb
CHANGED
@@ -425,6 +425,8 @@ def p4_cpu(os)
|
|
425
425
|
when :darwin, :linux
|
426
426
|
if cpu =~ /i686/
|
427
427
|
'x86'
|
428
|
+
elsif cpu =~ /universal/
|
429
|
+
'x86_64'
|
428
430
|
else
|
429
431
|
cpu
|
430
432
|
end
|
@@ -442,23 +444,19 @@ end
|
|
442
444
|
# directory name where we can download files from.
|
443
445
|
def p4_platform_label
|
444
446
|
case RbConfig::CONFIG["target_os"].downcase
|
445
|
-
when /nt|mswin|mingw/
|
447
|
+
when /nt|mswin|mingw|cygwin|msys/
|
446
448
|
# Ruby on windows is only MinGW via Rubyinstaller.org, though this may
|
447
449
|
# not work on all rubies.
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
end
|
454
|
-
when /darwin/
|
450
|
+
# There are too many permutations of Windows p4api, to automate.
|
451
|
+
raise 'Automatic fetching of p4api from perforce FTP is not supported on Windows'
|
452
|
+
when /darwin19|darwin[2-9][0-9]/
|
453
|
+
"macosx1015#{p4_cpu(:darwin)}"
|
454
|
+
when /darwin/
|
455
455
|
"darwin90#{p4_cpu(:darwin)}"
|
456
456
|
when /solaris/
|
457
457
|
"solaris10#{p4_cpu(:solaris)}"
|
458
458
|
when /linux/
|
459
|
-
"linux26#{p4_cpu(:linux)}"
|
460
|
-
when /cygwin/
|
461
|
-
raise 'cygwin is not supported for the --download-p4api option'
|
459
|
+
"linux26#{p4_cpu(:linux)}"
|
462
460
|
end
|
463
461
|
end
|
464
462
|
|
@@ -484,6 +482,8 @@ def filename
|
|
484
482
|
filename = 'p4api-openssl1.0.2.zip'
|
485
483
|
end
|
486
484
|
end
|
485
|
+
elsif RbConfig::CONFIG['target_os'].downcase =~ /darwin19|darwin[2-9][0-9]/
|
486
|
+
filename = 'p4api-openssl1.1.1.tgz'
|
487
487
|
else
|
488
488
|
filename = 'p4api.tgz'
|
489
489
|
if !openssl_number.to_s.empty?
|
data/ext/P4/p4.cpp
CHANGED
@@ -314,6 +314,25 @@ static VALUE p4_set_enviro_file( VALUE self, VALUE rbstr )
|
|
314
314
|
return Qtrue;
|
315
315
|
}
|
316
316
|
|
317
|
+
static VALUE p4_get_evar( VALUE self, VALUE var )
|
318
|
+
{
|
319
|
+
P4ClientApi *p4;
|
320
|
+
const StrPtr *val;
|
321
|
+
Data_Get_Struct( self, P4ClientApi, p4 );
|
322
|
+
val = p4->GetEVar( StringValuePtr( var ) );
|
323
|
+
if( !val ) return Qnil;
|
324
|
+
|
325
|
+
return P4Utils::ruby_string( val->Text() );
|
326
|
+
}
|
327
|
+
|
328
|
+
static VALUE p4_set_evar( VALUE self, VALUE var, VALUE val )
|
329
|
+
{
|
330
|
+
P4ClientApi *p4;
|
331
|
+
Data_Get_Struct( self, P4ClientApi, p4 );
|
332
|
+
p4->SetEVar( StringValuePtr( var ), StringValuePtr( val ) );
|
333
|
+
return Qtrue;
|
334
|
+
}
|
335
|
+
|
317
336
|
static VALUE p4_get_host( VALUE self )
|
318
337
|
{
|
319
338
|
P4ClientApi *p4;
|
@@ -642,7 +661,7 @@ static VALUE p4_run( VALUE self, VALUE args )
|
|
642
661
|
|
643
662
|
// Allocate storage on the stack so it's automatically reclaimed
|
644
663
|
// when we exit.
|
645
|
-
char **p4args =
|
664
|
+
char **p4args = RB_ALLOC_N( char *, argc + 1 );
|
646
665
|
|
647
666
|
// Copy the args across
|
648
667
|
for ( i = 0; i < argc; i++ )
|
@@ -808,6 +827,72 @@ static VALUE p4_set_progress( VALUE self, VALUE progress )
|
|
808
827
|
return p4->SetProgress( progress );
|
809
828
|
}
|
810
829
|
|
830
|
+
/*******************************************************************************
|
831
|
+
* SSO handler support
|
832
|
+
******************************************************************************/
|
833
|
+
static VALUE p4_get_enabled_sso( VALUE self )
|
834
|
+
{
|
835
|
+
P4ClientApi *p4;
|
836
|
+
Data_Get_Struct( self, P4ClientApi, p4 );
|
837
|
+
return p4->GetEnableSSO();
|
838
|
+
}
|
839
|
+
|
840
|
+
static VALUE p4_set_enable_sso( VALUE self, VALUE enable )
|
841
|
+
{
|
842
|
+
P4ClientApi *p4;
|
843
|
+
Data_Get_Struct( self, P4ClientApi, p4 );
|
844
|
+
return p4->SetEnableSSO( enable );
|
845
|
+
}
|
846
|
+
|
847
|
+
static VALUE p4_get_sso_vars( VALUE self )
|
848
|
+
{
|
849
|
+
P4ClientApi *p4;
|
850
|
+
Data_Get_Struct( self, P4ClientApi, p4 );
|
851
|
+
return p4->GetSSOVars();
|
852
|
+
}
|
853
|
+
|
854
|
+
static VALUE p4_get_sso_passresult( VALUE self )
|
855
|
+
{
|
856
|
+
P4ClientApi *p4;
|
857
|
+
Data_Get_Struct( self, P4ClientApi, p4 );
|
858
|
+
return p4->GetSSOPassResult();
|
859
|
+
}
|
860
|
+
|
861
|
+
static VALUE p4_set_sso_passresult( VALUE self, VALUE result )
|
862
|
+
{
|
863
|
+
P4ClientApi *p4;
|
864
|
+
Data_Get_Struct( self, P4ClientApi, p4 );
|
865
|
+
return p4->SetSSOPassResult( result );
|
866
|
+
}
|
867
|
+
|
868
|
+
static VALUE p4_get_sso_failresult( VALUE self )
|
869
|
+
{
|
870
|
+
P4ClientApi *p4;
|
871
|
+
Data_Get_Struct( self, P4ClientApi, p4 );
|
872
|
+
return p4->GetSSOFailResult();
|
873
|
+
}
|
874
|
+
|
875
|
+
static VALUE p4_set_sso_failresult( VALUE self, VALUE result )
|
876
|
+
{
|
877
|
+
P4ClientApi *p4;
|
878
|
+
Data_Get_Struct( self, P4ClientApi, p4 );
|
879
|
+
return p4->SetSSOFailResult( result );
|
880
|
+
}
|
881
|
+
static VALUE p4_get_ssohandler( VALUE self )
|
882
|
+
{
|
883
|
+
P4ClientApi *p4;
|
884
|
+
Data_Get_Struct( self, P4ClientApi, p4 );
|
885
|
+
return p4->GetSSOHandler();
|
886
|
+
}
|
887
|
+
|
888
|
+
static VALUE p4_set_ssohandler( VALUE self, VALUE handler )
|
889
|
+
{
|
890
|
+
P4ClientApi *p4;
|
891
|
+
Data_Get_Struct( self, P4ClientApi, p4 );
|
892
|
+
p4->SetSSOHandler( handler );
|
893
|
+
return Qtrue;
|
894
|
+
}
|
895
|
+
|
811
896
|
/*******************************************************************************
|
812
897
|
* P4::MergeData methods. Construction/destruction defined elsewhere
|
813
898
|
******************************************************************************/
|
@@ -1262,6 +1347,8 @@ void Init_P4()
|
|
1262
1347
|
rb_define_method( cP4, "set_env", RUBY_METHOD_FUNC(p4_set_env) , 2 );
|
1263
1348
|
rb_define_method( cP4, "enviro_file", RUBY_METHOD_FUNC(p4_get_enviro_file), 0);
|
1264
1349
|
rb_define_method( cP4, "enviro_file=", RUBY_METHOD_FUNC(p4_set_enviro_file), 1);
|
1350
|
+
rb_define_method( cP4, "evar", RUBY_METHOD_FUNC(p4_get_evar) , 1 );
|
1351
|
+
rb_define_method( cP4, "set_evar", RUBY_METHOD_FUNC(p4_set_evar) , 2 );
|
1265
1352
|
rb_define_method( cP4, "host", RUBY_METHOD_FUNC(p4_get_host) , 0 );
|
1266
1353
|
rb_define_method( cP4, "host=", RUBY_METHOD_FUNC(p4_set_host) , 1 );
|
1267
1354
|
rb_define_method( cP4, "ignore_file",RUBY_METHOD_FUNC(p4_get_ignore) , 0 );
|
@@ -1335,6 +1422,18 @@ void Init_P4()
|
|
1335
1422
|
rb_define_method( cP4, "progress", RUBY_METHOD_FUNC(p4_get_progress), 0);
|
1336
1423
|
rb_define_method( cP4, "progress=", RUBY_METHOD_FUNC(p4_set_progress), 1);
|
1337
1424
|
|
1425
|
+
// SSO handling
|
1426
|
+
rb_define_method( cP4, "loginsso", RUBY_METHOD_FUNC(p4_get_enabled_sso), 0);
|
1427
|
+
rb_define_method( cP4, "loginsso=", RUBY_METHOD_FUNC(p4_set_enable_sso), 1);
|
1428
|
+
rb_define_method( cP4, "ssovars", RUBY_METHOD_FUNC(p4_get_sso_vars), 0);
|
1429
|
+
rb_define_method( cP4, "ssopassresult", RUBY_METHOD_FUNC(p4_get_sso_passresult), 0);
|
1430
|
+
rb_define_method( cP4, "ssopassresult=", RUBY_METHOD_FUNC(p4_set_sso_passresult), 1);
|
1431
|
+
rb_define_method( cP4, "ssofailresult", RUBY_METHOD_FUNC(p4_get_sso_failresult), 0);
|
1432
|
+
rb_define_method( cP4, "ssofailresult=", RUBY_METHOD_FUNC(p4_set_sso_failresult), 1);
|
1433
|
+
rb_define_method( cP4, "ssohandler", RUBY_METHOD_FUNC(p4_get_ssohandler), 0);
|
1434
|
+
rb_define_method( cP4, "ssohandler=", RUBY_METHOD_FUNC(p4_set_ssohandler), 1);
|
1435
|
+
|
1436
|
+
|
1338
1437
|
// P4::MergeData class
|
1339
1438
|
cP4MD = rb_define_class_under( cP4, "MergeData", rb_cObject );
|
1340
1439
|
|
data/ext/P4/p4clientapi.cpp
CHANGED
@@ -37,6 +37,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
37
37
|
#include <ruby.h>
|
38
38
|
#include "undefdups.h"
|
39
39
|
#include <p4/clientapi.h>
|
40
|
+
#include <p4/strtable.h>
|
40
41
|
#include <p4/i18napi.h>
|
41
42
|
#include <p4/enviro.h>
|
42
43
|
#include <p4/hostenv.h>
|
@@ -142,6 +143,21 @@ P4ClientApi::GetEnviroFile()
|
|
142
143
|
return enviro->GetEnviroFile();
|
143
144
|
}
|
144
145
|
|
146
|
+
void
|
147
|
+
P4ClientApi::SetEVar( const char *var, const char *val )
|
148
|
+
{
|
149
|
+
StrRef sVar( var );
|
150
|
+
StrRef sVal( val );
|
151
|
+
client.SetEVar( sVar, sVal );
|
152
|
+
}
|
153
|
+
|
154
|
+
const StrPtr *
|
155
|
+
P4ClientApi::GetEVar( const char *var )
|
156
|
+
{
|
157
|
+
StrRef sVar( var );
|
158
|
+
return client.GetEVar( sVar );
|
159
|
+
}
|
160
|
+
|
145
161
|
void
|
146
162
|
P4ClientApi::SetApiLevel( int level )
|
147
163
|
{
|
@@ -699,6 +715,17 @@ P4ClientApi::SetProgress( VALUE progress ) {
|
|
699
715
|
return ui.SetProgress( progress );
|
700
716
|
}
|
701
717
|
|
718
|
+
VALUE
|
719
|
+
P4ClientApi::SetSSOHandler( VALUE h )
|
720
|
+
{
|
721
|
+
if ( P4RDB_COMMANDS )
|
722
|
+
fprintf( stderr, "[P4] Received SSO handler object\n" );
|
723
|
+
|
724
|
+
ui.SetRubySSOHandler( h );
|
725
|
+
|
726
|
+
return Qtrue;
|
727
|
+
}
|
728
|
+
|
702
729
|
|
703
730
|
void
|
704
731
|
P4ClientApi::GCMark()
|
@@ -760,3 +787,49 @@ P4ClientApi::Except( const char *func, Error *e )
|
|
760
787
|
e->Fmt( &m );
|
761
788
|
Except( func, m.Text() );
|
762
789
|
}
|
790
|
+
|
791
|
+
//
|
792
|
+
// SSO Handlers
|
793
|
+
//
|
794
|
+
|
795
|
+
VALUE
|
796
|
+
P4ClientApi::SetEnableSSO( VALUE e )
|
797
|
+
{
|
798
|
+
return ui.EnableSSO( e );
|
799
|
+
}
|
800
|
+
|
801
|
+
VALUE
|
802
|
+
P4ClientApi::GetEnableSSO()
|
803
|
+
{
|
804
|
+
return ui.SSOEnabled();
|
805
|
+
}
|
806
|
+
|
807
|
+
VALUE
|
808
|
+
P4ClientApi::GetSSOVars()
|
809
|
+
{
|
810
|
+
return ui.GetSSOVars();
|
811
|
+
}
|
812
|
+
|
813
|
+
VALUE
|
814
|
+
P4ClientApi::SetSSOPassResult( VALUE r )
|
815
|
+
{
|
816
|
+
return ui.SetSSOPassResult( r );
|
817
|
+
}
|
818
|
+
|
819
|
+
VALUE
|
820
|
+
P4ClientApi::GetSSOPassResult()
|
821
|
+
{
|
822
|
+
return ui.GetSSOPassResult();
|
823
|
+
}
|
824
|
+
|
825
|
+
VALUE
|
826
|
+
P4ClientApi::SetSSOFailResult( VALUE r )
|
827
|
+
{
|
828
|
+
return ui.SetSSOFailResult( r );
|
829
|
+
}
|
830
|
+
|
831
|
+
VALUE
|
832
|
+
P4ClientApi::GetSSOFailResult()
|
833
|
+
{
|
834
|
+
return ui.GetSSOFailResult();
|
835
|
+
}
|
data/ext/P4/p4clientapi.h
CHANGED
@@ -73,6 +73,7 @@ public:
|
|
73
73
|
void SetClient( const char *c ) { client.SetClient( c ); }
|
74
74
|
void SetCwd( const char *c );
|
75
75
|
void SetEnviroFile( const char *c );
|
76
|
+
void SetEVar( const char *var, const char *val );
|
76
77
|
void SetHost( const char *h ) { client.SetHost( h ); }
|
77
78
|
void SetIgnoreFile( const char *f ) { client.SetIgnoreFile( f ); }
|
78
79
|
void SetMaxResults( int v ) { maxResults = v; }
|
@@ -96,6 +97,7 @@ public:
|
|
96
97
|
const StrPtr &GetCwd() { return client.GetCwd(); }
|
97
98
|
const char * GetEnv( const char *v);
|
98
99
|
const StrPtr *GetEnviroFile();
|
100
|
+
const StrPtr *GetEVar(const char *v);
|
99
101
|
const StrPtr &GetHost() { return client.GetHost(); }
|
100
102
|
const StrPtr &GetIgnoreFile() { return client.GetIgnoreFile();}
|
101
103
|
const StrPtr &GetLanguage() { return client.GetLanguage(); }
|
@@ -169,6 +171,17 @@ public:
|
|
169
171
|
VALUE SetProgress( VALUE progress );
|
170
172
|
VALUE GetProgress() { return ui.GetProgress(); }
|
171
173
|
|
174
|
+
// SSO handler
|
175
|
+
VALUE SetEnableSSO( VALUE e );
|
176
|
+
VALUE GetEnableSSO();
|
177
|
+
VALUE GetSSOVars();
|
178
|
+
VALUE SetSSOPassResult( VALUE r );
|
179
|
+
VALUE GetSSOPassResult();
|
180
|
+
VALUE SetSSOFailResult( VALUE r );
|
181
|
+
VALUE GetSSOFailResult();
|
182
|
+
VALUE SetSSOHandler( VALUE handler );
|
183
|
+
VALUE GetSSOHandler() { return ui.GetRubySSOHandler(); }
|
184
|
+
|
172
185
|
// Ruby garbage collection
|
173
186
|
void GCMark();
|
174
187
|
|
data/ext/P4/p4specdata.cpp
CHANGED
@@ -106,3 +106,32 @@ SpecDataRuby::SetLine( SpecElem *sd, int x, const StrPtr *v, Error *e )
|
|
106
106
|
}
|
107
107
|
return;
|
108
108
|
}
|
109
|
+
|
110
|
+
void
|
111
|
+
SpecDataRuby::Comment ( SpecElem *sd, int x, const char **wv, int nl, Error *e )
|
112
|
+
{
|
113
|
+
VALUE key;
|
114
|
+
VALUE val;
|
115
|
+
VALUE ary;
|
116
|
+
StrBuf t;
|
117
|
+
|
118
|
+
key = P4Utils::ruby_string( sd->tag.Text(), sd->tag.Length() );
|
119
|
+
val = P4Utils::ruby_string( *wv );
|
120
|
+
|
121
|
+
if( sd->IsList() )
|
122
|
+
{
|
123
|
+
|
124
|
+
ary = rb_hash_aref( hash, key ); // rb_hash_aref - get the value for hash key
|
125
|
+
if( ary == Qnil )
|
126
|
+
{
|
127
|
+
ary = rb_ary_new();
|
128
|
+
rb_hash_aset( hash, key, ary ); // rb_hash_aset(hash, key, value) - set the hash key to value
|
129
|
+
}
|
130
|
+
rb_ary_store( ary, x, val );
|
131
|
+
}
|
132
|
+
else
|
133
|
+
{
|
134
|
+
rb_hash_aset( hash, key, val );
|
135
|
+
}
|
136
|
+
return;
|
137
|
+
}
|
data/ext/P4/p4specdata.h
CHANGED
@@ -44,6 +44,8 @@ class SpecDataRuby : public SpecData
|
|
44
44
|
virtual StrPtr *GetLine( SpecElem *sd, int x, const char **cmt );
|
45
45
|
virtual void SetLine( SpecElem *sd, int x, const StrPtr *val,
|
46
46
|
Error *e );
|
47
|
+
virtual void Comment( SpecElem *sd, int x, const char **wv,
|
48
|
+
int nl, Error *e );
|
47
49
|
|
48
50
|
private:
|
49
51
|
VALUE hash;
|