p4ruby 2022.1.2359956-x64-mingw-ucrt

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.
@@ -0,0 +1,46 @@
1
+ /*******************************************************************************
2
+
3
+ Copyright (c) 2001-2008, Perforce Software, Inc. All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright
9
+ notice, this list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright
12
+ notice, this list of conditions and the following disclaimer in the
13
+ documentation and/or other materials provided with the distribution.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
+ ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE SOFTWARE, INC. BE LIABLE FOR ANY
19
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+
26
+ *******************************************************************************/
27
+
28
+ /*******************************************************************************
29
+ * Name : p4rubydebug.h
30
+ *
31
+ * Author : Tony Smith <tony@perforce.com> or <tony@smee.org>
32
+ *
33
+ * Description : Debugging support for P4Ruby
34
+ *
35
+ ******************************************************************************/
36
+ #ifndef P4RUBYDEBUG_H
37
+ # define P4RUBYDEBUG_H
38
+
39
+ #define P4RDB_COMMANDS ( debug > 0 )
40
+ #define P4RDB_CALLS ( debug > 1 )
41
+ #define P4RDB_DATA ( debug > 2 )
42
+ #define P4RDB_GC ( debug > 3 )
43
+ #define P4RDB_RPC ( debug > 8 )
44
+ #define P4RDB_SSL ( debug > 10 )
45
+
46
+ #endif
@@ -0,0 +1,137 @@
1
+ /*******************************************************************************
2
+
3
+ Copyright (c) 2009, Perforce Software, Inc. All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright
9
+ notice, this list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright
12
+ notice, this list of conditions and the following disclaimer in the
13
+ documentation and/or other materials provided with the distribution.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
+ ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE SOFTWARE, INC. BE LIABLE FOR ANY
19
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+
26
+ *******************************************************************************/
27
+
28
+ /*******************************************************************************
29
+ * Name : p4specdata.cpp
30
+ *
31
+ * Author : Tony Smith <tony@perforce.com> or <tony@smee.org>
32
+ *
33
+ * Description : Ruby bindings for the Perforce API. SpecData subclass for
34
+ * P4Ruby. This class allows for manipulation of Spec data
35
+ * stored in a Ruby hash using the standard Perforce classes
36
+ *
37
+ ******************************************************************************/
38
+
39
+ #include <ruby.h>
40
+ #include "undefdups.h"
41
+ #include <p4/clientapi.h>
42
+ #include <p4/i18napi.h>
43
+ #include <p4/spec.h>
44
+ #include <p4/debug.h>
45
+ #include "p4rubydebug.h"
46
+ #include "p4utils.h"
47
+ #include "p4specdata.h"
48
+
49
+ StrPtr *
50
+ SpecDataRuby::GetLine( SpecElem *sd, int x, const char **cmt )
51
+ {
52
+ *cmt = 0;
53
+ VALUE val;
54
+ VALUE key;
55
+ StrBuf t;
56
+
57
+ key = P4Utils::ruby_string( sd->tag.Text(), sd->tag.Length() );
58
+ val = rb_hash_aref( hash, key );
59
+ if( val == Qnil ) return 0;
60
+
61
+ if( !sd->IsList() )
62
+ {
63
+ last = StringValuePtr( val );
64
+ return &last;
65
+ }
66
+
67
+ // It's a list, which means we should have an array value here
68
+
69
+ if( !rb_obj_is_kind_of( val, rb_cArray ) )
70
+ {
71
+ rb_warn( "%s should be an array element. Ignoring...",
72
+ sd->tag.Text() );
73
+ return 0;
74
+ }
75
+ val = rb_ary_entry( val, x );
76
+ if( val == Qnil ) return 0;
77
+
78
+ last = StringValuePtr( val );
79
+ return &last;
80
+ }
81
+
82
+ void
83
+ SpecDataRuby::SetLine( SpecElem *sd, int x, const StrPtr *v, Error *e )
84
+ {
85
+ VALUE key;
86
+ VALUE val;
87
+ VALUE ary;
88
+ StrBuf t;
89
+
90
+ key = P4Utils::ruby_string( sd->tag.Text(), sd->tag.Length() );
91
+ val = P4Utils::ruby_string( v->Text(), v->Length() );
92
+
93
+ if( sd->IsList() )
94
+ {
95
+ ary = rb_hash_aref( hash, key );
96
+ if( ary == Qnil )
97
+ {
98
+ ary = rb_ary_new();
99
+ rb_hash_aset( hash, key, ary );
100
+ }
101
+ rb_ary_store( ary, x, val );
102
+ }
103
+ else
104
+ {
105
+ rb_hash_aset( hash, key, val );
106
+ }
107
+ return;
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
+ }
@@ -0,0 +1,54 @@
1
+ /*******************************************************************************
2
+
3
+ Copyright (c) 2009, Perforce Software, Inc. All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright
9
+ notice, this list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright
12
+ notice, this list of conditions and the following disclaimer in the
13
+ documentation and/or other materials provided with the distribution.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
+ ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE SOFTWARE, INC. BE LIABLE FOR ANY
19
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+
26
+ *******************************************************************************/
27
+
28
+ /*******************************************************************************
29
+ * Name : p4specdata.h
30
+ *
31
+ * Author : Tony Smith <tony@perforce.com> or <tony@smee.org>
32
+ *
33
+ * Description : Ruby bindings for the Perforce API. SpecData subclass for
34
+ * P4Ruby. This class allows for manipulation of Spec data
35
+ * stored in a Ruby hash using the standard Perforce classes
36
+ *
37
+ ******************************************************************************/
38
+
39
+ class SpecDataRuby : public SpecData
40
+ {
41
+ public:
42
+ SpecDataRuby( VALUE h ) { hash = h; }
43
+
44
+ virtual StrPtr *GetLine( SpecElem *sd, int x, const char **cmt );
45
+ virtual void SetLine( SpecElem *sd, int x, const StrPtr *val,
46
+ Error *e );
47
+ virtual void Comment( SpecElem *sd, int x, const char **wv,
48
+ int nl, Error *e );
49
+
50
+ private:
51
+ VALUE hash;
52
+ StrBuf last;
53
+ };
54
+
@@ -0,0 +1,62 @@
1
+ // vim:ts=8:sw=4:
2
+ /*******************************************************************************
3
+
4
+ Copyright (c) 2011, Perforce Software, Inc. All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright
10
+ notice, this list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright
13
+ notice, this list of conditions and the following disclaimer in the
14
+ documentation and/or other materials provided with the distribution.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
+ ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE SOFTWARE, INC. BE LIABLE FOR ANY
20
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
+
27
+ *******************************************************************************/
28
+ #include <ruby.h>
29
+ #ifdef HAVE_RUBY_ENCODING_H
30
+ #include <ruby/encoding.h>
31
+ #endif
32
+ #include "p4utils.h"
33
+
34
+ char *P4Utils::charset = 0;
35
+
36
+ VALUE P4Utils::ruby_string( const char *msg, long len )
37
+ {
38
+ VALUE str;
39
+ // If a length has been passed then use it
40
+ if( len )
41
+ {
42
+ str = rb_str_new( msg, len );
43
+ }
44
+ else
45
+ {
46
+ str = rb_str_new2( msg );
47
+ }
48
+
49
+ // Now check if an encoding should be set for the string.
50
+ #ifdef HAVE_RUBY_ENCODING_H
51
+ if( charset )
52
+ {
53
+ rb_enc_associate(str, rb_enc_find("UTF-8"));
54
+ }
55
+ else
56
+ {
57
+ rb_enc_associate(str, rb_locale_encoding());
58
+ }
59
+ #endif
60
+
61
+ return str;
62
+ }
data/ext/P4/p4utils.h ADDED
@@ -0,0 +1,46 @@
1
+ /*******************************************************************************
2
+
3
+ Copyright (c) 2011, Perforce Software, Inc. All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright
9
+ notice, this list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright
12
+ notice, this list of conditions and the following disclaimer in the
13
+ documentation and/or other materials provided with the distribution.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
+ ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE SOFTWARE, INC. BE LIABLE FOR ANY
19
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+
26
+ *******************************************************************************/
27
+
28
+ /*******************************************************************************
29
+ * Name : p4utils.h
30
+ *
31
+ * Author : Jayesh Mistry <jmistry@perforce.com>
32
+ *
33
+ * Description : C++ class with useful methods
34
+ *
35
+ ******************************************************************************/
36
+ class P4Utils {
37
+ public:
38
+ static void SetCharset( const char *cs ) { charset = (char *) cs; };
39
+ static char* GetCharset() { return charset; };
40
+
41
+ static VALUE ruby_string( const char *msg, long len = 0);
42
+
43
+ private:
44
+ static char* charset;
45
+ };
46
+