openwsman 2.4.14 → 2.5.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4fed348cccfb060ad6c03e0ea8d377b35e282583
4
- data.tar.gz: 25763c25772cfa8cb3a96d78d2fa7f8024d13d96
3
+ metadata.gz: 863a157db8977112dd862c430f9f8ae8348fa448
4
+ data.tar.gz: 7d78155cf5883a0bdc1f4d83a14f4c20dbe94a9b
5
5
  SHA512:
6
- metadata.gz: 28dd065e34e533b994c08d9bf853324a9a0710a78db390726c41d68af1c0683c82db16070a25968f11ad81d17e496cfefb7efd078910f07875a9bab851352ae5
7
- data.tar.gz: e700d27eb3a456c83b53d50e5489f60c34ff71c9b2d02d6aa9ec65e1f8268fc92e6ce5eb0d830ea0fd00b7f0444e8eecca9ab21d54f390fef297152541ed6ecb
6
+ metadata.gz: 87a91cb1af88c6a4cb74f6367791a8bcf7c863aa49ab5f9fc06044fe0345ecce65a7b87a58514c98cf8dad6e9dfafaf396822d9ddd6adeec5663ab2f9e79b081
7
+ data.tar.gz: 103cbaf1914d50d0693232cba422ba9880e2db2860d0c8c2977ff8117e392034e185d4802c047063246e945459f66da5ef0bd9c54e823f93ddac5221e3856949
@@ -182,6 +182,9 @@ SWIGINTERNINLINE SV *SWIG_From_double SWIG_PERL_DECL_ARGS_1(double value);
182
182
 
183
183
  #if defined(SWIGPYTHON)
184
184
  %module pywsman
185
+ /* Wrap file operations, as Python's native ones are incompatible */
186
+ FILE *fopen(char *, char *);
187
+ void fclose(FILE *f);
185
188
  #endif
186
189
 
187
190
  #if defined(SWIGPERL)
@@ -419,6 +422,27 @@ static epr_t *my_epr_deserialize(WsXmlNodeH node) {
419
422
  /* else search the WSA_EPR node */
420
423
  return epr_deserialize(node, XML_NS_ADDRESSING, WSA_EPR, 1);
421
424
  }
425
+
426
+ static VALUE kv_list_to_hash(list_t *list)
427
+ {
428
+ VALUE v = Qnil;
429
+ if (!list_isempty(list)) {
430
+ v = rb_hash_new();
431
+ lnode_t *node = list_first(list);
432
+ while (node) {
433
+ key_value_t *kv = (key_value_t *)node->list_data;
434
+ if (kv->type == 0) {
435
+ rb_hash_aset( v, makestring(kv->key), makestring(kv->v.text));
436
+ }
437
+ else {
438
+ VALUE epr = SWIG_NewPointerObj((void*)kv->v.epr, SWIGTYPE_p_epr_t, 0);
439
+ rb_hash_aset( v, makestring(kv->key), epr);
440
+ }
441
+ node = list_next(list, node);
442
+ }
443
+ }
444
+ return v;
445
+ }
422
446
  #endif
423
447
 
424
448
  static char *epr_prefix(const char *uri);
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  #define OPENWSMAN_MAJOR 2
8
- #define OPENWSMAN_MINOR 4
9
- #define OPENWSMAN_PATCH 14
10
- #define OPENWSMAN_VERSION "2.4.14"
8
+ #define OPENWSMAN_MINOR 5
9
+ #define OPENWSMAN_PATCH 2
10
+ #define OPENWSMAN_VERSION "2.5.2"
11
11
 
@@ -368,42 +368,36 @@ typedef struct {} client_opt_t;
368
368
  * Add a selector as key/value pair
369
369
  *
370
370
  * NOTE:
371
- * the value must be properly escaped (replace & with &, etc.)
371
+ * the string value must be properly escaped (replace & with &, etc.)
372
372
  * in Ruby use CGI::escapeHTML()
373
373
  *
374
374
  * call-seq:
375
375
  * options.add_selector "Key", "Value"
376
+ * options.add_selector "Key", end_point_reference
376
377
  *
377
378
  */
378
379
  void add_selector(VALUE k, VALUE v)
379
380
  {
380
381
  const char *key = as_string(k);
381
- const char *value = as_string(v);
382
+ KLASS_DECL(SwigClassEndPointReference,SWIGTYPE_p_epr_t);
383
+ if (CLASS_OF(v) == KLASS_OF(SwigClassEndPointReference)) {
384
+ epr_t *epr;
385
+ SWIG_ConvertPtr(v, (void **)&epr, SWIGTYPE_p_epr_t, 0);
386
+ wsmc_add_selector_epr($self, key, epr);
387
+ }
388
+ else {
389
+ const char *value = as_string(v);
390
+ wsmc_add_selector($self, key, value);
391
+ }
392
+ }
382
393
  #else
383
394
  void add_selector(const char *key, const char *value)
384
395
  {
385
- #endif
386
396
  wsmc_add_selector($self, key, value);
387
397
  }
398
+ #endif
388
399
 
389
400
  #if defined(SWIGRUBY)
390
- %rename( "selectors=" ) set_selectors(VALUE hash);
391
- /*
392
- * Set selectors from Hash
393
- *
394
- * NOTE:
395
- * the values must be properly escaped (replace & with &, etc.)
396
- * in Ruby use CGI::escapeHTML()
397
- *
398
- * call-seq:
399
- * options.selectors = { "Key" => "Value", ... }
400
- *
401
- */
402
- void set_selectors(VALUE hash)
403
- {
404
- $self->selectors = value2hash(NULL, hash, 0);
405
- }
406
-
407
401
  %rename( "selectors" ) get_selectors(void);
408
402
  /*
409
403
  * Get selectors as Hash
@@ -414,7 +408,7 @@ typedef struct {} client_opt_t;
414
408
  */
415
409
  VALUE get_selectors(void)
416
410
  {
417
- return hash2value($self->selectors);
411
+ return kv_list_to_hash($self->selectors);
418
412
  }
419
413
  #endif
420
414
 
@@ -485,22 +479,7 @@ typedef struct {} client_opt_t;
485
479
  */
486
480
  VALUE get_properties(void)
487
481
  {
488
- VALUE v = Qnil;
489
- if (!list_isempty($self->properties)) {
490
- v = rb_hash_new();
491
- lnode_t *node = list_first($self->properties);
492
- while (node) {
493
- client_property_t *property = (client_property_t *)node->list_data;
494
- if (property->value.type == 0) {
495
- rb_hash_aset( v, makestring(property->key), makestring(property->value.entry.text));
496
- }
497
- else {
498
- rb_hash_aset( v, makestring(property->key), makestring(epr_to_string(property->value.entry.eprp)));
499
- }
500
- node = list_next($self->properties, node);
501
- }
502
- }
503
- return v;
482
+ return kv_list_to_hash($self->properties);
504
483
  }
505
484
  #endif
506
485
 
@@ -193,9 +193,9 @@ typedef struct {} epr_t;
193
193
  #endif
194
194
  int i;
195
195
  Target_Type ary = Target_SizedArray($self->refparams.selectorset.count);
196
- Selector *p = $self->refparams.selectorset.selectors;
196
+ key_value_t *p = $self->refparams.selectorset.selectors;
197
197
  for (i = 0; i < $self->refparams.selectorset.count; i++) {
198
- Target_ListSet(ary, i, SWIG_FromCharPtr(p->name));
198
+ Target_ListSet(ary, i, SWIG_FromCharPtr(p->key));
199
199
  ++p;
200
200
  }
201
201
  #if defined(SWIGPERL)
@@ -216,18 +216,16 @@ typedef struct {} epr_t;
216
216
  */
217
217
  void each() {
218
218
  int i;
219
- Selector *p = NULL;
219
+ key_value_t *p = NULL;
220
220
  VALUE value, ary;
221
221
  p = $self->refparams.selectorset.selectors;
222
222
  for (i = 0; i < $self->refparams.selectorset.count; i++) {
223
223
  ary = rb_ary_new2(2);
224
- rb_ary_store(ary, 0, SWIG_FromCharPtr(p->name));
224
+ rb_ary_store(ary, 0, SWIG_FromCharPtr(p->key));
225
225
  if (p->type == 0) {
226
- value = SWIG_FromCharPtr(p->value);
226
+ value = SWIG_FromCharPtr(p->v.text);
227
227
  } else {
228
- char *epr_value = epr_to_string((const epr_t *)p->value);
229
- value = SWIG_FromCharPtr(epr_value);
230
- u_free(epr_value);
228
+ value = SWIG_NewPointerObj((void*) p->v.epr, SWIGTYPE_p_epr_t, 0);
231
229
  }
232
230
  rb_ary_store(ary, 1, value);
233
231
  rb_yield(ary);
data/ext/ruby/helpers.h CHANGED
@@ -125,26 +125,34 @@ _add_str( VALUE key, VALUE value, hash_t *h )
125
125
  }
126
126
 
127
127
 
128
- /* add key,value VALUE pair to hash_t* as selector_entry*
128
+ /* add key,value VALUE pair to hash_t* as key_value_t*
129
129
  * (used as callback for value2hash)
130
130
  */
131
131
  static int
132
- _add_selector( VALUE key, VALUE value, hash_t *h )
132
+ _add_kv( VALUE key, VALUE value, hash_t *h )
133
133
  {
134
134
  if (key != Qundef) {
135
- const char *k = strdup( as_string( key ) );
135
+ const char *k = as_string( key );
136
136
  if (!hash_lookup( h, k ) ) {
137
- selector_entry *entry = u_malloc(sizeof(selector_entry));
138
- entry->type = 0;
139
- if (TYPE(value) == T_ARRAY) {
140
- rb_raise( rb_eException, "Passing array parameter via invoke() still unsupported" );
141
- }
142
- else {
143
- entry->entry.text = strdup(as_string( value ));
144
- }
145
- if ( !hash_alloc_insert( h, k, entry ) ) {
146
- rb_raise( rb_eException, "hash_alloc_insert failed" );
147
- }
137
+ epr_t *epr;
138
+ const char *text;
139
+ key_value_t *entry;
140
+ KLASS_DECL(SwigClassEndPointReference,SWIGTYPE_p_epr_t);
141
+ if (CLASS_OF(value) == KLASS_OF(SwigClassEndPointReference)) {
142
+ SWIG_ConvertPtr(value, (void **)&epr, SWIGTYPE_p_epr_t, 0);
143
+ text = NULL;
144
+ }
145
+ else if (TYPE(value) == T_ARRAY) {
146
+ rb_raise( rb_eException, "Passing array parameter via invoke() still unsupported" );
147
+ }
148
+ else {
149
+ text = as_string(value);
150
+ epr = NULL;
151
+ }
152
+ entry = key_value_create(k, text, epr, NULL);
153
+ if ( !hash_alloc_insert( h, k, entry ) ) {
154
+ rb_raise( rb_eException, "hash_alloc_insert failed" );
155
+ }
148
156
  }
149
157
  }
150
158
  return 0;
@@ -158,7 +166,7 @@ _add_selector( VALUE key, VALUE value, hash_t *h )
158
166
  *
159
167
  * valuetype - type of hash values
160
168
  * 0 - values are string (char *)
161
- * 1 - values are selector_entry *
169
+ * 1 - values are key_value_t *
162
170
  *
163
171
  */
164
172
  static hash_t *
@@ -170,7 +178,7 @@ value2hash( hash_t *h, VALUE v, int valuetype )
170
178
 
171
179
  if (!h) h = hash_create3(HASHCOUNT_T_MAX, 0, 0);
172
180
 
173
- rb_hash_foreach( v, (valuetype==0)?_add_str:_add_selector, (unsigned long)h );
181
+ rb_hash_foreach( v, (valuetype==0)?_add_str:_add_kv, (unsigned long)h );
174
182
 
175
183
  return h;
176
184
  }
@@ -38,14 +38,26 @@ require 'openwsman/xmldoc'
38
38
  # response and dig down through its XmlNode and XmlAttr objects.
39
39
 
40
40
  module Openwsman
41
- class ClientOption
41
+ #
42
+ # ClientOptions
43
+ #
44
+ class ClientOptions
42
45
  # assign hash to properties
43
46
  def properties= value
44
47
  value.each do |k,v|
45
- self.add_property k.to_s, v.to_s
48
+ self.add_property k.to_s, v
49
+ end
50
+ end
51
+ # assign hash to selectors
52
+ def selectors= value
53
+ value.each do |k,v|
54
+ self.add_selector k.to_s, v
46
55
  end
47
56
  end
48
57
  end
58
+ #
59
+ # Transport
60
+ #
49
61
  class Transport
50
62
  # called when authentication credentials missing or wrong
51
63
  def Transport.auth_request_callback client, auth_type
@@ -85,10 +97,30 @@ module Openwsman
85
97
  raise "Classname must not be nil" unless classname
86
98
  epr = epr_prefix_for(classname,namespace) + "/#{classname}"
87
99
  end
88
-
100
+ #
101
+ # EndPointReference
102
+ #
89
103
  class EndPointReference
90
104
  def method_missing name, *args # :nodoc:
91
- selector(name)
105
+ selector(name.to_s)
106
+ end
107
+ def to_s
108
+ s = "#{classname}"
109
+ first = true
110
+ self.each do |k,v|
111
+ s << ((first)?"?":"&")
112
+ first = false
113
+ s << "#{k}=#{v.inspect}"
114
+ end
115
+ s
116
+ end
117
+ end
118
+ #
119
+ # Fault
120
+ #
121
+ class Fault
122
+ def to_s
123
+ "Fault #{code}.#{subcode}: #{detail} - #{reason}"
92
124
  end
93
125
  end
94
126
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openwsman
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.14
4
+ version: 2.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Klaus Kämpf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-24 00:00:00.000000000 Z
11
+ date: 2015-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler