-
Notifications
You must be signed in to change notification settings - Fork 2
/
k2hdkcpx_func.c
1284 lines (1132 loc) · 41 KB
/
k2hdkcpx_func.c
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
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
*
* K2HDKC PHP Extension library
*
* Copyright 2023 Yahoo Japan Corporation.
*
* K2HDKC is k2hash based distributed KVS cluster.
* K2HDKC uses K2HASH, CHMPX, FULLOCK libraries. K2HDKC supports
* distributed KVS cluster server program and client libraries.
*
* For the full copyright and license information, please view
* the license file that was distributed with this source code.
*
* AUTHOR: Hirotaka Wakabayashi
* CREATE: Fri, Mar 31 2023
* REVISION:
*
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
// cppcheck-suppress missingInclude
#include "php.h"
// cppcheck-suppress missingInclude
#include "ext/standard/info.h"
#include "php_k2hdkcpx.h"
#include "k2hdkcpx_arginfo.h"
/* For compatibility with older PHP versions */
#ifndef ZEND_PARSE_PARAMETERS_NONE
#define ZEND_PARSE_PARAMETERS_NONE() \
ZEND_PARSE_PARAMETERS_START(0, 0) \
ZEND_PARSE_PARAMETERS_END()
#endif
// class entries
zend_class_entry* k2hdkcpx_class_entry;
zval* k2hdkcpx_read_property_resource(zend_class_entry* scope, zval* object, const char* name) {
zval* pzval, tmp;
#if PHP_VERSION_ID < 80000
pzval = zend_read_property(scope, object, name, strlen(name), 1, &tmp);
#else
pzval = zend_read_property(scope, Z_OBJ_P(object), name, strlen(name), 1, &tmp);
#endif
if(IS_RESOURCE != Z_TYPE_P(pzval)){
php_error(E_ERROR, "The property(%s) is not a resource type.", name);
}
return pzval;
}
void k2hdkcpx_update_property_resource(zend_class_entry* scope, zval* object, const char* name, size_t name_length, zval* value) {
#if PHP_VERSION_ID < 80000
zend_update_property(scope, object, name, name_length, value);
#else
zend_update_property(scope, Z_OBJ_P(object), name, name_length, value);
#endif
}
int k2hdkcpx_handle_resource_number;
zend_resource* k2hdkcpx_handle_resource;
static void k2hdkcpx_handle_resource_dtor(zend_resource* rsrc)
{
efree((k2hdkc_chmpx_h*)rsrc->ptr);
}
//
// PHP_FUNCTION ENTRIES START
//
PHP_FUNCTION(k2hdkcpx_open)
{
// declare_variables
char* config_file = NULL;
size_t config_file_len = 0;
zend_long port = 8031;
char* cuk = NULL;
size_t cuk_len = 0;
zend_bool rejoin = true;
zend_bool rejoin_forever = true;
zend_bool clear_backup = true;
// assign_after_declare
ZEND_PARSE_PARAMETERS_START(1, 6)
Z_PARAM_STRING(config_file, config_file_len)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(port)
Z_PARAM_STRING(cuk, cuk_len)
Z_PARAM_BOOL(rejoin)
Z_PARAM_BOOL(rejoin_forever)
Z_PARAM_BOOL(clear_backup)
ZEND_PARSE_PARAMETERS_END();
// validate_after_assign
if(!config_file || 0 == config_file_len){
php_error(E_ERROR, "k2hdkcpx_open: CHMPX configuration file path is empty.");
RETURN_FALSE;
}
// call_some_functions after get_resources
k2hdkc_chmpx_h chmpx_handle = k2hdkc_open_chmpx_full(config_file, port, cuk, rejoin, rejoin_forever, clear_backup);
if(CHM_INVALID_CHMPXHANDLE == chmpx_handle) {
php_error(E_NOTICE, "k2hdkcpx_open: failed to open(join) CHMPX.");
RETURN_FALSE;
}
// return_result after call_some_functions
k2hdkc_chmpx_h* chmpx_handle_ptr = emalloc(sizeof(long)); // this resource destroy by using chmpx_handle_resource_dtor
if (chmpx_handle_ptr == NULL) {
php_error(E_ERROR, "malloc error");
RETURN_FALSE;
}
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress nullPointerRedundantCheck
*chmpx_handle_ptr = chmpx_handle;
RETURN_RES(zend_register_resource(chmpx_handle_ptr, k2hdkcpx_handle_resource_number)); // RETVAL_RES(r) and ZVAL_RES(return_value, r)
}
PHP_FUNCTION(k2hdkcpx_set_value)
{
// declare_variables
zval * zval_k2hdkc_chmpx_handle_ptr = NULL;
char* key = NULL;
size_t key_len = 0;
char* val = NULL;
size_t val_len = 0;
zend_bool clear_subkeys = false;
zval* subkeys = NULL; // NOTE: initial array of keys must be explicitly NULL to avoid SIGSEGV in Z_TYPE_P
char* password = NULL;
size_t password_len = 0;
zend_long expire = 0;
// assign_after_declare
ZEND_PARSE_PARAMETERS_START(3, 7)
Z_PARAM_RESOURCE(zval_k2hdkc_chmpx_handle_ptr)
Z_PARAM_STRING(key, key_len)
Z_PARAM_STRING(val, val_len)
Z_PARAM_OPTIONAL
Z_PARAM_BOOL(clear_subkeys)
Z_PARAM_ARRAY(subkeys)
Z_PARAM_STRING(password, password_len)
Z_PARAM_LONG(expire)
ZEND_PARSE_PARAMETERS_END();
// validate_after_assign
ZEND_ASSERT(Z_TYPE_P(zval_k2hdkc_chmpx_handle_ptr) == IS_RESOURCE);
if(!zval_k2hdkc_chmpx_handle_ptr) {
php_error(E_ERROR, "handle is empty.");
RETURN_FALSE;
}
time_t* ptmexpire = NULL;
if (expire > 0) {
ptmexpire = (time_t*)&expire;
}
// get_resources
k2hdkc_chmpx_h* k2hdkc_chmpx_handle_ptr;
k2hdkc_chmpx_handle_ptr = (k2hdkc_chmpx_h *)zend_fetch_resource(Z_RES_P(zval_k2hdkc_chmpx_handle_ptr), "chmpx_handle_resource", k2hdkcpx_handle_resource_number);
if (K2HDKC_INVALID_HANDLE == *k2hdkc_chmpx_handle_ptr) {
php_error(E_NOTICE, "chmpx_handle_resource is invalid");
RETURN_FALSE; // RETVAL_FALSE; return;
}
// call_some_functions after get_resources
// bool k2hdkc_pm_set_str_all_wa(k2hdkc_chmpx_h handle, const char* pkey, const char* pval, const char** pskeyarray, const char* encpass, const time_t* expire)
bool bResult = false;
if (subkeys && Z_TYPE_P(subkeys) == IS_ARRAY) {
int skeypckcnt = zend_array_count(Z_ARR(*subkeys)); // returns number of elements in array.
char** pskeyarray = (char**)calloc(skeypckcnt + 1, sizeof(char*));
zend_ulong zulong_idx = 0;
zend_string* zstring_key = NULL;
zval* zv_val = NULL;
ZEND_HASH_FOREACH_KEY_VAL(Z_ARR(*subkeys), zulong_idx, zstring_key, zv_val) {
char* subkey = Z_STRVAL_P(zv_val);
pskeyarray[zulong_idx] = (char*)malloc(strlen(subkey) + 1);
memcpy(pskeyarray[zulong_idx], subkey, strlen(subkey));
pskeyarray[zulong_idx][strlen(subkey)] = '\0';
} ZEND_HASH_FOREACH_END();
bResult = k2hdkc_pm_set_str_all_wa(*k2hdkc_chmpx_handle_ptr, key, val, (const char**)pskeyarray, password, ptmexpire);
if (pskeyarray) {
char** ptmp = NULL;
for (ptmp = pskeyarray; *ptmp; ptmp++) {
free(*ptmp);
}
}
} else {
bResult = k2hdkc_pm_set_str_all_wa(*k2hdkc_chmpx_handle_ptr, key, val, NULL, password, ptmexpire);
}
// return_result after call_some_functions
if (bResult) {
RETURN_TRUE; // RETVAL_TRUE; return;
}
RETURN_FALSE;
}
// get
// bool k2hdkc_pm_get_str_value_wp(k2hdkc_chmpx_h handle, const char* pkey, const char* encpass, char** ppval);
PHP_FUNCTION(k2hdkcpx_get_value)
{
// declare_variables
zval * zval_k2hdkc_chmpx_handle_ptr = NULL;
char* key = NULL;
size_t key_len = 0;
char* password = NULL;
size_t password_len = 0;
// assign_after_declare
ZEND_PARSE_PARAMETERS_START(2, 3)
Z_PARAM_RESOURCE(zval_k2hdkc_chmpx_handle_ptr)
Z_PARAM_STRING(key, key_len)
Z_PARAM_OPTIONAL
Z_PARAM_STRING(password, password_len)
ZEND_PARSE_PARAMETERS_END();
// validate_after_assign
ZEND_ASSERT(Z_TYPE_P(zval_k2hdkc_chmpx_handle_ptr) == IS_RESOURCE);
if(!zval_k2hdkc_chmpx_handle_ptr) {
php_error(E_ERROR, "handle is empty.");
RETURN_FALSE;
}
// get_resources
k2hdkc_chmpx_h* k2hdkc_chmpx_handle_ptr;
k2hdkc_chmpx_handle_ptr = (k2hdkc_chmpx_h *)zend_fetch_resource(Z_RES_P(zval_k2hdkc_chmpx_handle_ptr), "chmpx_handle_resource", k2hdkcpx_handle_resource_number);
if (K2HDKC_INVALID_HANDLE == *k2hdkc_chmpx_handle_ptr) {
php_error(E_NOTICE, "chmpx_handle_resource is invalid");
RETURN_FALSE; // RETVAL_FALSE; return;
}
// call_some_functions after get_resources
//// k2hdkc_pm_get_str_value_wp(session.getHandle(), this.key, this.pass, ppval);
char* pval;
if (!k2hdkc_pm_get_str_value_wp(*k2hdkc_chmpx_handle_ptr, key, password, &pval)) {
// return_result after call_some_functions
RETURN_EMPTY_STRING(); // RETVAL_EMPTY_STRING(); return;
}
zend_string* retval = strpprintf(0, "%s", pval);
free(pval);
RETURN_STR(retval);
// come here ???
}
// add_subkey
// bool k2hdkc_pm_set_str_subkey_wa(k2hdkc_chmpx_h handle, const char* pkey, const char* psubkey, const char* pskeyval, bool checkattr, const char* encpass, const time_t* expire)
PHP_FUNCTION(k2hdkcpx_add_subkey)
{
// declare_variables
zval * zval_k2hdkc_chmpx_handle_ptr = NULL;
char* key = NULL;
size_t key_len = 0;
char* subkey = NULL;
size_t subkey_len = 0;
char* subval = NULL;
size_t subval_len = 0;
zend_bool is_attr_checked = true;
char* password = NULL;
size_t password_len = 0;
zend_long expire = 0;
// assign_after_declare
ZEND_PARSE_PARAMETERS_START(4, 7)
Z_PARAM_RESOURCE(zval_k2hdkc_chmpx_handle_ptr)
Z_PARAM_STRING(key, key_len)
Z_PARAM_STRING(subkey, subkey_len)
Z_PARAM_STRING(subval, subval_len)
Z_PARAM_OPTIONAL
Z_PARAM_BOOL(is_attr_checked)
Z_PARAM_STRING(password, password_len)
Z_PARAM_LONG(expire)
ZEND_PARSE_PARAMETERS_END();
// validate_after_assign
time_t* ptmexpire = NULL;
if (expire > 0) {
ptmexpire = (time_t*)&expire;
}
// get_resources after get_props
k2hdkc_chmpx_h* k2hdkc_chmpx_handle_ptr = (k2hdkc_chmpx_h *)zend_fetch_resource(Z_RES_P(zval_k2hdkc_chmpx_handle_ptr), "chmpx_handle_resource", k2hdkcpx_handle_resource_number);
if (K2HDKC_INVALID_HANDLE == *k2hdkc_chmpx_handle_ptr) {
php_error(E_NOTICE, "_handle property is invalid");
RETURN_FALSE; // RETVAL_FALSE; return;
}
// call_some_functions after get_resources
bool bResult = k2hdkc_pm_set_str_subkey_wa(*k2hdkc_chmpx_handle_ptr, key, subkey, subval, is_attr_checked, password, ptmexpire);
// return_result after call_some_functions
if (bResult) {
RETURN_TRUE; // RETVAL_TRUE; return;
}
RETURN_FALSE;
}
// cas_get
// bool k2hdkc_pm_cas64_str_get_wa(k2hdkc_chmpx_h handle, const char* pkey, const char* encpass, uint64_t* pval)
PHP_FUNCTION(k2hdkcpx_cas_get)
{
// declare_variables
zval * zval_k2hdkc_chmpx_handle_ptr = NULL;
char* key = NULL;
size_t key_len = 0;
char* password = NULL;
size_t password_len = 0;
// assign_after_declare
ZEND_PARSE_PARAMETERS_START(2, 3)
Z_PARAM_RESOURCE(zval_k2hdkc_chmpx_handle_ptr)
Z_PARAM_STRING(key, key_len)
Z_PARAM_OPTIONAL
Z_PARAM_STRING(password, password_len)
ZEND_PARSE_PARAMETERS_END();
// get_resources after get_props
k2hdkc_chmpx_h* k2hdkc_chmpx_handle_ptr = (k2hdkc_chmpx_h *)zend_fetch_resource(Z_RES_P(zval_k2hdkc_chmpx_handle_ptr), "chmpx_handle_resource", k2hdkcpx_handle_resource_number);
if (K2HDKC_INVALID_HANDLE == *k2hdkc_chmpx_handle_ptr) {
php_error(E_NOTICE, "_handle property is invalid");
RETURN_FALSE; // RETVAL_FALSE; return;
}
// call_some_functions after get_resources
// bool bResult = k2hdkc_pm_cas64_str_get_wa(*k2hdkc_chmpx_handle_ptr, key, NULL, (uint64_t*)&pval);
int pval = 0;
bool bResult = k2hdkc_pm_cas64_str_get_wa(*k2hdkc_chmpx_handle_ptr, key, NULL, (uint64_t*)&pval);
if (!bResult || !pval) {
// return_result after call_some_functions
RETURN_FALSE;
}
RETURN_LONG(pval);
}
// cas_decrement
// bool k2hdkc_pm_cas_str_decrement_wa(k2hdkc_chmpx_h handle, const char* pkey, const char* encpass, const time_t* expire)
PHP_FUNCTION(k2hdkcpx_cas_decrement)
{
// declare_variables
zval * zval_k2hdkc_chmpx_handle_ptr = NULL;
char* key = NULL;
size_t key_len = 0;
char* password = NULL;
size_t password_len = 0;
zend_long expire = 0;
// assign_after_declare
ZEND_PARSE_PARAMETERS_START(2, 4)
Z_PARAM_RESOURCE(zval_k2hdkc_chmpx_handle_ptr)
Z_PARAM_STRING(key, key_len)
Z_PARAM_OPTIONAL
Z_PARAM_STRING(password, password_len)
Z_PARAM_LONG(expire)
ZEND_PARSE_PARAMETERS_END();
// validate_after_assign
time_t* ptmexpire = NULL;
if (expire > 0) {
ptmexpire = (time_t*)&expire;
}
// get_resources after get_props
k2hdkc_chmpx_h* k2hdkc_chmpx_handle_ptr = (k2hdkc_chmpx_h *)zend_fetch_resource(Z_RES_P(zval_k2hdkc_chmpx_handle_ptr), "chmpx_handle_resource", k2hdkcpx_handle_resource_number);
if (K2HDKC_INVALID_HANDLE == *k2hdkc_chmpx_handle_ptr) {
php_error(E_NOTICE, "_handle property is invalid");
RETURN_FALSE; // RETVAL_FALSE; return;
}
// call_some_functions after get_resources
// bool k2hdkc_pm_cas_str_decrement_wa(k2hdkc_chmpx_h handle, const char* pkey, const char* encpass, const time_t* expire)
bool bResult = k2hdkc_pm_cas_str_decrement_wa(*k2hdkc_chmpx_handle_ptr, key, password, ptmexpire);
if (!bResult) {
// return_result after call_some_functions
php_error(E_NOTICE, "k2hdkc_pm_cas_str_decrement_wa should return true, but false");
RETURN_FALSE; // RETVAL_FALSE; return;
}
RETURN_TRUE; // RETVAL_TRUE; return;
}
// cas_increment
// bool k2hdkc_pm_cas_str_increment_wa(k2hdkc_chmpx_h handle, const char* pkey, const char* encpass, const time_t* expire)
PHP_FUNCTION(k2hdkcpx_cas_increment)
{
// declare_variables
zval * zval_k2hdkc_chmpx_handle_ptr = NULL;
char* key = NULL;
size_t key_len = 0;
char* password = NULL;
size_t password_len = 0;
zend_long expire = 0;
// assign_after_declare
ZEND_PARSE_PARAMETERS_START(2, 4)
Z_PARAM_RESOURCE(zval_k2hdkc_chmpx_handle_ptr)
Z_PARAM_STRING(key, key_len)
Z_PARAM_OPTIONAL
Z_PARAM_STRING(password, password_len)
Z_PARAM_LONG(expire)
ZEND_PARSE_PARAMETERS_END();
// validate_after_assign
time_t* ptmexpire = NULL;
if (expire > 0) {
ptmexpire = (time_t*)&expire;
}
// get_resources after get_props
k2hdkc_chmpx_h* k2hdkc_chmpx_handle_ptr = (k2hdkc_chmpx_h *)zend_fetch_resource(Z_RES_P(zval_k2hdkc_chmpx_handle_ptr), "chmpx_handle_resource", k2hdkcpx_handle_resource_number);
if (K2HDKC_INVALID_HANDLE == *k2hdkc_chmpx_handle_ptr) {
php_error(E_NOTICE, "_handle property is invalid");
RETURN_FALSE; // RETVAL_FALSE; return;
}
// call_some_functions after get_resources
// bool k2hdkc_pm_cas_str_increment_wa(k2hdkc_chmpx_h handle, const char* pkey, const char* encpass, const time_t* expire)
bool bResult = k2hdkc_pm_cas_str_increment_wa(*k2hdkc_chmpx_handle_ptr, key, password, ptmexpire);
if (!bResult) {
// return_result after call_some_functions
php_error(E_NOTICE, "k2hdkc_pm_cas_str_increment_wa should return true, but false");
RETURN_FALSE; // RETVAL_FALSE; return;
}
RETURN_TRUE; // RETVAL_TRUE; return;
}
// cas_init
// bool k2hdkc_pm_cas8_str_init_wa(k2hdkc_chmpx_h handle, const char* pkey, uint8_t val, const char* encpass, const time_t* expire)
PHP_FUNCTION(k2hdkcpx_cas_init)
{
// declare_variables
zval * zval_k2hdkc_chmpx_handle_ptr = NULL;
char* key = NULL;
size_t key_len = 0;
zend_long val = 0;
char* password = NULL;
size_t password_len = 0;
zend_long expire = 0;
// assign_after_declare
ZEND_PARSE_PARAMETERS_START(3, 5)
Z_PARAM_RESOURCE(zval_k2hdkc_chmpx_handle_ptr)
Z_PARAM_STRING(key, key_len)
Z_PARAM_LONG(val)
Z_PARAM_OPTIONAL
Z_PARAM_STRING(password, password_len)
Z_PARAM_LONG(expire)
ZEND_PARSE_PARAMETERS_END();
// validate_after_assign
time_t* ptmexpire = NULL;
if (expire > 0) {
ptmexpire = (time_t*)&expire;
}
// get_resources after get_props
k2hdkc_chmpx_h* k2hdkc_chmpx_handle_ptr = (k2hdkc_chmpx_h *)zend_fetch_resource(Z_RES_P(zval_k2hdkc_chmpx_handle_ptr), "chmpx_handle_resource", k2hdkcpx_handle_resource_number);
if (K2HDKC_INVALID_HANDLE == *k2hdkc_chmpx_handle_ptr) {
php_error(E_NOTICE, "_handle property is invalid");
RETURN_FALSE; // RETVAL_FALSE; return;
}
// call_some_functions after get_resources
// bool k2hdkc_pm_cas64_str_init_wa(k2hdkc_chmpx_h handle, const char* pkey, uint64_t val, const char* encpass, const time_t* expire)
bool bResult = k2hdkc_pm_cas64_str_init_wa(*k2hdkc_chmpx_handle_ptr, key, (uint64_t)val, password, ptmexpire);
if (!bResult) {
// return_result after call_some_functions
php_error(E_NOTICE, "k2hdkc_pm_cas64_str_init_wa should return true, but false");
RETURN_FALSE; // RETVAL_FALSE; return;
}
RETURN_TRUE; // RETVAL_TRUE; return;
}
// cas_set
// bool k2hdkc_pm_cas8_str_set_wa(k2hdkc_chmpx_h handle, const char* pkey, uint8_t oldval, uint8_t newval, const char* encpass, const time_t* expire)
PHP_FUNCTION(k2hdkcpx_cas_set)
{
// declare_variables
zval * zval_k2hdkc_chmpx_handle_ptr = NULL;
char* key = NULL;
size_t key_len = 0;
zend_long old_val = 0;
zend_long new_val = 0;
char* password = NULL;
size_t password_len = 0;
zend_long expire = 0;
// assign_after_declare
ZEND_PARSE_PARAMETERS_START(4, 6)
Z_PARAM_RESOURCE(zval_k2hdkc_chmpx_handle_ptr)
Z_PARAM_STRING(key, key_len)
Z_PARAM_LONG(old_val)
Z_PARAM_LONG(new_val)
Z_PARAM_OPTIONAL
Z_PARAM_STRING(password, password_len)
Z_PARAM_LONG(expire)
ZEND_PARSE_PARAMETERS_END();
// validate_after_assign
time_t* ptmexpire = NULL;
if (expire > 0) {
ptmexpire = (time_t*)&expire;
}
// get_resources after get_props
k2hdkc_chmpx_h* k2hdkc_chmpx_handle_ptr = (k2hdkc_chmpx_h *)zend_fetch_resource(Z_RES_P(zval_k2hdkc_chmpx_handle_ptr), "chmpx_handle_resource", k2hdkcpx_handle_resource_number);
if (K2HDKC_INVALID_HANDLE == *k2hdkc_chmpx_handle_ptr) {
php_error(E_NOTICE, "_handle property is invalid");
RETURN_FALSE; // RETVAL_FALSE; return;
}
// call_some_functions after get_resources
// bool k2hdkc_pm_cas64_str_set_wa(k2hdkc_chmpx_h handle, const char* pkey, uint64_t oldval, uint64_t newval, const char* encpass, const time_t* expire)
bool bResult = k2hdkc_pm_cas64_str_set_wa(*k2hdkc_chmpx_handle_ptr, key, old_val, new_val, password, ptmexpire);
if (!bResult) {
// return_result after call_some_functions
php_error(E_NOTICE, "k2hdkc_pm_cas64_str_set_wa should return true, but false");
RETURN_FALSE; // RETVAL_FALSE; return;
}
RETURN_TRUE; // RETVAL_TRUE; return;
}
// clear_subkeys
// bool k2hdkc_pm_clear_str_subkeys(k2hdkc_chmpx_h handle, const char* pkey)
PHP_FUNCTION(k2hdkcpx_clear_subkeys)
{
// declare_variables
zval * zval_k2hdkc_chmpx_handle_ptr = NULL;
char* key = NULL;
size_t key_len = 0;
// assign_after_declare
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_RESOURCE(zval_k2hdkc_chmpx_handle_ptr)
Z_PARAM_STRING(key, key_len)
ZEND_PARSE_PARAMETERS_END();
// get_resources after get_props
k2hdkc_chmpx_h* k2hdkc_chmpx_handle_ptr = (k2hdkc_chmpx_h *)zend_fetch_resource(Z_RES_P(zval_k2hdkc_chmpx_handle_ptr), "chmpx_handle_resource", k2hdkcpx_handle_resource_number);
if (K2HDKC_INVALID_HANDLE == *k2hdkc_chmpx_handle_ptr) {
php_error(E_NOTICE, "_handle property is invalid");
RETURN_FALSE; // RETVAL_FALSE; return;
}
// call_some_functions after get_resources
//// bool k2hdkc_pm_clear_str_subkeys(k2hdkc_chmpx_h handle, const char* pkey)
bool bResult = k2hdkc_pm_clear_str_subkeys(*k2hdkc_chmpx_handle_ptr, key);
if (!bResult) {
// return_result after call_some_functions
php_error(E_NOTICE, "k2hdkc_pm_clear_str_subkeys should return true, but false");
RETURN_FALSE; // RETVAL_FALSE; return;
}
RETURN_TRUE; // RETVAL_TRUE; return;
}
// bool k2hdkc_close_chmpx_ex(k2hdkc_chmpx_h handle, bool is_clean_bup)
PHP_FUNCTION(k2hdkcpx_close)
{
// declare_variables
zval* zval_k2hdkc_chmpx_handle_ptr = NULL;
zend_bool clean_bup = true;
// assign_after_declare
ZEND_PARSE_PARAMETERS_START(1, 2)
Z_PARAM_RESOURCE(zval_k2hdkc_chmpx_handle_ptr)
Z_PARAM_OPTIONAL
Z_PARAM_BOOL(clean_bup)
ZEND_PARSE_PARAMETERS_END();
// validate_after_assign
ZEND_ASSERT(Z_TYPE_P(zval_k2hdkc_chmpx_handle_ptr) == IS_RESOURCE);
if(!zval_k2hdkc_chmpx_handle_ptr) {
php_error(E_ERROR, "k2hdkcpx_close: handle is empty.");
RETURN_FALSE;
}
// get_resources
k2hdkc_chmpx_h* chmpx_handle_ptr = (chmpx_h *)zend_fetch_resource(Z_RES_P(zval_k2hdkc_chmpx_handle_ptr), "chmpx_handle_resource", k2hdkcpx_handle_resource_number);
// call_some_functions after get_resources
k2hdkc_close_chmpx_ex(*chmpx_handle_ptr, clean_bup);
// return_result after call_some_functions
RETURN_TRUE;
}
// get_attributes
// PK2HDKCATTRPCK k2hdkc_pm_get_str_direct_attrs(k2hdkc_chmpx_h handle, const char* pkey, int* pattrspckcnt)
PHP_FUNCTION(k2hdkcpx_get_attributes)
{
// declare_variables
zval * zval_k2hdkc_chmpx_handle_ptr = NULL;
char* key = NULL;
size_t key_len = 0;
// assign_after_declare
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_RESOURCE(zval_k2hdkc_chmpx_handle_ptr)
Z_PARAM_STRING(key, key_len)
ZEND_PARSE_PARAMETERS_END();
// get_resources after get_props
k2hdkc_chmpx_h* k2hdkc_chmpx_handle_ptr;
k2hdkc_chmpx_handle_ptr = (k2hdkc_chmpx_h *)zend_fetch_resource(Z_RES_P(zval_k2hdkc_chmpx_handle_ptr), "chmpx_handle_resource", k2hdkcpx_handle_resource_number);
if (K2HDKC_INVALID_HANDLE == *k2hdkc_chmpx_handle_ptr) {
php_error(E_NOTICE, "_handle property is invalid");
RETURN_EMPTY_STRING(); // RETVAL_EMPTY_STRING(); return;
}
// call_some_functions after get_resources
//// PK2HDKCATTRPCK k2hdkc_pm_get_str_direct_attrs(k2hdkc_chmpx_h handle, const char* pkey, int* pattrspckcnt)
int attrspckcnt = 0;
PK2HDKCATTRPCK pattrs = k2hdkc_pm_get_str_direct_attrs(*k2hdkc_chmpx_handle_ptr, key, &attrspckcnt);
if (pattrs && attrspckcnt > 0) {
array_init(return_value); // zval* return_value
int cnt;
for(cnt = 0; cnt < attrspckcnt; ++cnt) {
char* pattrkey;
if(NULL != (pattrkey = (char*)emalloc(pattrs[cnt].keylength + 1))) {
memcpy(pattrkey, pattrs[cnt].pkey, pattrs[cnt].keylength);
pattrkey[pattrs[cnt].keylength] = '\0';
add_next_index_string(return_value, pattrkey);
efree(pattrkey);
}
}
}
if(pattrs) {
k2h_free_attrpack(pattrs, attrspckcnt);
}
}
// get_subkeys
// PK2HDKCKEYPCK k2hdkc_pm_get_direct_subkeys(k2hdkc_chmpx_h handle, const unsigned char* pkey, size_t keylength, int* pskeypckcnt)
PHP_FUNCTION(k2hdkcpx_get_subkeys)
{
// declare_variables
zval * zval_k2hdkc_chmpx_handle_ptr = NULL;
char* key = NULL;
size_t key_len = 0;
// assign_after_declare
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_RESOURCE(zval_k2hdkc_chmpx_handle_ptr)
Z_PARAM_STRING(key, key_len)
Z_PARAM_OPTIONAL
ZEND_PARSE_PARAMETERS_END();
// get_resources after get_props
k2hdkc_chmpx_h* k2hdkc_chmpx_handle_ptr;
k2hdkc_chmpx_handle_ptr = (k2hdkc_chmpx_h *)zend_fetch_resource(Z_RES_P(zval_k2hdkc_chmpx_handle_ptr), "chmpx_handle_resource", k2hdkcpx_handle_resource_number);
if (K2HDKC_INVALID_HANDLE == *k2hdkc_chmpx_handle_ptr) {
php_error(E_NOTICE, "_handle property is invalid");
RETURN_EMPTY_STRING(); // RETVAL_EMPTY_STRING(); return;
}
// call_some_functions after get_resources
//// char** k2hdkc_pm_get_str_direct_subkeys(k2hdkc_chmpx_h handle, const char* pkey)
char** pskeyarray = k2hdkc_pm_get_str_direct_subkeys(*k2hdkc_chmpx_handle_ptr, key);
array_init(return_value); // zval* return_value
if (pskeyarray) {
char** ptmp = NULL;
for (ptmp = pskeyarray; *ptmp; ptmp++) {
add_next_index_str(return_value, strpprintf(0, "%s", *ptmp));
free(*ptmp);
}
}
}
// queue_get
// bool k2hdkc_pm_q_str_pop_wp(k2hdkc_chmpx_h handle, const char* pprefix, bool is_fifo, const char* encpass, const char** ppval)
PHP_FUNCTION(k2hdkcpx_queue_get)
{
// declare_variables
zval * zval_k2hdkc_chmpx_handle_ptr = NULL;
char* prefix = NULL;
size_t prefix_len = 0;
zend_bool is_fifo = true;
char* password = NULL;
size_t password_len = 0;
// assign_after_declare
ZEND_PARSE_PARAMETERS_START(2, 4)
Z_PARAM_RESOURCE(zval_k2hdkc_chmpx_handle_ptr)
Z_PARAM_STRING(prefix, prefix_len)
Z_PARAM_OPTIONAL
Z_PARAM_BOOL(is_fifo)
Z_PARAM_STRING(password, password_len)
ZEND_PARSE_PARAMETERS_END();
// get_resources after get_props
k2hdkc_chmpx_h* k2hdkc_chmpx_handle_ptr = (k2hdkc_chmpx_h *)zend_fetch_resource(Z_RES_P(zval_k2hdkc_chmpx_handle_ptr), "chmpx_handle_resource", k2hdkcpx_handle_resource_number);
if (K2HDKC_INVALID_HANDLE == *k2hdkc_chmpx_handle_ptr) {
php_error(E_NOTICE, "_handle property is invalid");
RETURN_FALSE; // RETVAL_FALSE; return;
}
// call_some_functions after get_resources
// bool k2hdkc_pm_q_str_pop_wp(k2hdkc_chmpx_h handle, const char* pprefix, bool is_fifo, const char* encpass, const char** ppval)
const char* pval = NULL;
bool bResult = k2hdkc_pm_q_str_pop_wp(*k2hdkc_chmpx_handle_ptr, prefix, is_fifo, NULL, &pval);
if (!bResult) {
php_error(E_NOTICE, "k2hdkc_pm_q_str_pop_wp should return true, but false");
RETURN_EMPTY_STRING(); // RETVAL_EMPTY_STRING(); return;
}
zend_string* retval = strpprintf(0, "%s", pval);
RETURN_STR(retval);
}
// queue_put
// bool k2hdkc_pm_q_str_push_wa(k2hdkc_chmpx_h handle, const char* pprefix, const char* pval, bool is_fifo, bool checkattr, const char* encpass, const time_t* expire)
PHP_FUNCTION(k2hdkcpx_queue_put)
{
// declare_variables
zval * zval_k2hdkc_chmpx_handle_ptr = NULL;
char* prefix = NULL;
size_t prefix_len = 0;
char* val = NULL;
size_t val_len = 0;
zend_bool is_fifo = true;
zend_bool is_attr_checked = true;
char* password = NULL;
size_t password_len = 0;
zend_long expire = 0;
// assign_after_declare
ZEND_PARSE_PARAMETERS_START(3, 7)
Z_PARAM_RESOURCE(zval_k2hdkc_chmpx_handle_ptr)
Z_PARAM_STRING(prefix, prefix_len)
Z_PARAM_STRING(val, val_len)
Z_PARAM_OPTIONAL
Z_PARAM_BOOL(is_fifo)
Z_PARAM_BOOL(is_attr_checked)
Z_PARAM_STRING(password, password_len)
Z_PARAM_LONG(expire)
ZEND_PARSE_PARAMETERS_END();
// validate_after_assign
time_t* ptmexpire = NULL;
if (expire > 0) {
ptmexpire = (time_t*)&expire;
}
// get_resources after get_props
k2hdkc_chmpx_h* k2hdkc_chmpx_handle_ptr = (k2hdkc_chmpx_h *)zend_fetch_resource(Z_RES_P(zval_k2hdkc_chmpx_handle_ptr), "chmpx_handle_resource", k2hdkcpx_handle_resource_number);
if (K2HDKC_INVALID_HANDLE == *k2hdkc_chmpx_handle_ptr) {
php_error(E_NOTICE, "_handle property is invalid");
RETURN_FALSE; // RETVAL_FALSE; return;
}
// call_some_functions after get_resources
// bool k2hdkc_pm_q_str_push_wa(k2hdkc_chmpx_h handle, const char* pprefix, const char* pval, bool is_fifo, bool checkattr, const char* encpass, const time_t* expire)
bool bResult = k2hdkc_pm_q_str_push_wa(*k2hdkc_chmpx_handle_ptr, prefix, val, is_fifo, is_attr_checked, password, ptmexpire);
if (!bResult) {
php_error(E_NOTICE, "k2hdkc_pm_q_str_push_wa should return true but false");
RETURN_FALSE; // RETVAL_FALSE; return;
}
RETURN_TRUE; // RETVAL_TRUE; return;
}
// keyqueue_get
// bool k2hdkc_pm_keyq_str_pop_wp(k2hdkc_chmpx_h handle, const char* pprefix, bool is_fifo, const char* encpass, const char** ppkey, const char** ppval)
PHP_FUNCTION(k2hdkcpx_key_queue_get)
{
// declare_variables
zval * zval_k2hdkc_chmpx_handle_ptr = NULL;
char* prefix = NULL;
size_t prefix_len = 0;
zend_bool is_fifo = true;
char* password = NULL;
size_t password_len = 0;
// assign_after_declare
ZEND_PARSE_PARAMETERS_START(2, 4)
Z_PARAM_RESOURCE(zval_k2hdkc_chmpx_handle_ptr)
Z_PARAM_STRING(prefix, prefix_len)
Z_PARAM_OPTIONAL
Z_PARAM_BOOL(is_fifo)
Z_PARAM_STRING(password, password_len)
ZEND_PARSE_PARAMETERS_END();
// get_resources after get_props
k2hdkc_chmpx_h* k2hdkc_chmpx_handle_ptr = (k2hdkc_chmpx_h *)zend_fetch_resource(Z_RES_P(zval_k2hdkc_chmpx_handle_ptr), "chmpx_handle_resource", k2hdkcpx_handle_resource_number);
if (K2HDKC_INVALID_HANDLE == *k2hdkc_chmpx_handle_ptr) {
php_error(E_NOTICE, "_handle property is invalid");
RETURN_FALSE; // RETVAL_FALSE; return;
}
// call_some_functions after get_resources
// bool k2hdkc_pm_keyq_str_pop_wp(k2hdkc_chmpx_h handle, const char* pprefix, bool is_fifo, const char* encpass, const char** ppkey, const char** ppval)
const char* pkey = NULL;
const char* pval = NULL;
k2hdkc_pm_keyq_str_pop_wp(*k2hdkc_chmpx_handle_ptr, prefix, is_fifo, NULL, &pkey, &pval);
array_init(return_value); // zval* return_value
if (pkey && pval) {
add_assoc_string(return_value, pkey, pval);
}
}
// keyqueue_put
// bool k2hdkc_pm_keyq_str_push_wa(k2hdkc_chmpx_h handle, const char* pprefix, const char* pkey, const char* pval, bool is_fifo, bool checkattr, const char* encpass, const time_t* expire)
PHP_FUNCTION(k2hdkcpx_key_queue_put)
{
// declare_variables
zval * zval_k2hdkc_chmpx_handle_ptr = NULL;
char* prefix = NULL;
size_t prefix_len = 0;
char* key = NULL;
size_t key_len = 0;
char* val = NULL;
size_t val_len = 0;
zend_bool is_fifo = true;
zend_bool is_attr_checked = true;
char* password = NULL;
size_t password_len = 0;
zend_long expire = 0;
// assign_after_declare
ZEND_PARSE_PARAMETERS_START(4, 8)
Z_PARAM_RESOURCE(zval_k2hdkc_chmpx_handle_ptr)
Z_PARAM_STRING(prefix, prefix_len)
Z_PARAM_STRING(key, key_len)
Z_PARAM_STRING(val, val_len)
Z_PARAM_OPTIONAL
Z_PARAM_BOOL(is_fifo)
Z_PARAM_BOOL(is_attr_checked)
Z_PARAM_STRING(password, password_len)
Z_PARAM_LONG(expire)
ZEND_PARSE_PARAMETERS_END();
// validate_after_assign
time_t* ptmexpire = NULL;
if (expire > 0) {
ptmexpire = (time_t*)&expire;
}
// get_resources after get_props
k2hdkc_chmpx_h* k2hdkc_chmpx_handle_ptr = (k2hdkc_chmpx_h *)zend_fetch_resource(Z_RES_P(zval_k2hdkc_chmpx_handle_ptr), "chmpx_handle_resource", k2hdkcpx_handle_resource_number);
if (K2HDKC_INVALID_HANDLE == *k2hdkc_chmpx_handle_ptr) {
php_error(E_NOTICE, "_handle property is invalid");
RETURN_FALSE; // RETVAL_FALSE; return;
}
// call_some_functions after get_resources
// bool k2hdkc_pm_keyq_str_push_wa(k2hdkc_chmpx_h handle, const char* pprefix, const char* pkey, const char* pval, bool is_fifo, bool checkattr, const char* encpass, const time_t* expire)
bool bResult = k2hdkc_pm_keyq_str_push_wa(*k2hdkc_chmpx_handle_ptr, prefix, key, val, is_fifo, is_attr_checked, password, ptmexpire);
if (!bResult) {
php_error(E_NOTICE, "k2hdkc_pm_keyq_str_push_wa should return true but false");
RETURN_FALSE; // RETVAL_FALSE; return;
}
RETURN_TRUE; // RETVAL_TRUE; return;
}
// remove
// bool k2hdkc_pm_remove_str(k2hdkc_chmpx_h handle, const char* pkey)
PHP_FUNCTION(k2hdkcpx_remove)
{
// declare_variables
zval * zval_k2hdkc_chmpx_handle_ptr = NULL;
char* key = NULL;
size_t key_len = 0;
// assign_after_declare
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_RESOURCE(zval_k2hdkc_chmpx_handle_ptr)
Z_PARAM_STRING(key, key_len)
Z_PARAM_OPTIONAL
ZEND_PARSE_PARAMETERS_END();
// get_resources after get_props
k2hdkc_chmpx_h* k2hdkc_chmpx_handle_ptr;
k2hdkc_chmpx_handle_ptr = (k2hdkc_chmpx_h *)zend_fetch_resource(Z_RES_P(zval_k2hdkc_chmpx_handle_ptr), "chmpx_handle_resource", k2hdkcpx_handle_resource_number);
if (K2HDKC_INVALID_HANDLE == *k2hdkc_chmpx_handle_ptr) {
php_error(E_NOTICE, "_handle property is invalid");
RETURN_FALSE; // RETVAL_FALSE; return;
}
// call_some_functions after get_resources
//// bool k2hdkc_pm_remove_str(k2hdkc_chmpx_h handle, const char* pkey)
if (!k2hdkc_pm_remove_str(*k2hdkc_chmpx_handle_ptr, key)) {
php_error(E_NOTICE, "k2hdkc_pm_remove_str should return true but false");
RETURN_FALSE; // RETVAL_FALSE; return;
}
RETURN_TRUE; // RETVAL_TRUE; return;
}
// remove_subkeys
// bool k2hdkc_pm_remove_str_subkey(k2hdkc_chmpx_h handle, const char* pkey, const char* psubkey, size_t subkeylength, bool is_nest)
PHP_FUNCTION(k2hdkcpx_remove_subkeys)
{
// declare_variables
zval * zval_k2hdkc_chmpx_handle_ptr = NULL;
char* key = NULL;
size_t key_len = 0;
zval* subkeys = NULL;
zend_bool is_nested = false;
// assign_after_declare
ZEND_PARSE_PARAMETERS_START(3, 4)
Z_PARAM_RESOURCE(zval_k2hdkc_chmpx_handle_ptr)
Z_PARAM_STRING(key, key_len)
Z_PARAM_ARRAY(subkeys)
Z_PARAM_OPTIONAL
Z_PARAM_BOOL(is_nested)
ZEND_PARSE_PARAMETERS_END();
// get_resources after get_props
k2hdkc_chmpx_h* k2hdkc_chmpx_handle_ptr = (k2hdkc_chmpx_h *)zend_fetch_resource(Z_RES_P(zval_k2hdkc_chmpx_handle_ptr), "chmpx_handle_resource", k2hdkcpx_handle_resource_number);
if (K2HDKC_INVALID_HANDLE == *k2hdkc_chmpx_handle_ptr) {
php_error(E_NOTICE, "_handle property is invalid");
RETURN_FALSE; // RETVAL_FALSE; return;
}
// call_some_functions after get_resources
//// bool k2hdkc_pm_remove_str_subkey(k2hdkc_chmpx_h handle, const char* pkey, const char* psubkey, size_t subkeylength, bool is_nest)
if (subkeys && Z_TYPE_P(subkeys) == IS_ARRAY) {
zend_ulong zulong_idx= 0;
zend_string* zstring_key = NULL;
zval* zv_val = NULL;
ZEND_HASH_FOREACH_KEY_VAL(Z_ARR(*subkeys), zulong_idx, zstring_key, zv_val) {
char* subkey = Z_STRVAL_P(zv_val);
bool bResult = k2hdkc_pm_remove_str_subkey(*k2hdkc_chmpx_handle_ptr, key, subkey, is_nested);
if (!bResult) {
// return_result after call_some_functions
php_error(E_NOTICE, "k2hdkc_pm_remove_str_subkey should return true, but false");
RETURN_FALSE; // RETVAL_FALSE; return;
}
} ZEND_HASH_FOREACH_END();
}
RETURN_TRUE; // RETVAL_TRUE; return;
}
// rename
// bool k2hdkc_pm_rename_with_parent_str_wa(k2hdkc_chmpx_h handle, const char* poldkey, const char* pnewkey, const char* pparentkey, bool checkattr, const char* encpass, const time_t* expire)
PHP_FUNCTION(k2hdkcpx_rename)
{
// declare_variables
zval * zval_k2hdkc_chmpx_handle_ptr = NULL;
char* key = NULL;
size_t key_len = 0;
char* newKey = NULL;
size_t newKey_len = 0;
char* parentKey = NULL;
size_t parentKey_len = 0;
zend_bool is_attr_checked = true;
char* password = NULL;
size_t password_len = 0;
zend_long expire = 0;
// assign_after_declare
ZEND_PARSE_PARAMETERS_START(3, 7)
Z_PARAM_RESOURCE(zval_k2hdkc_chmpx_handle_ptr)
Z_PARAM_STRING(key, key_len)
Z_PARAM_STRING(newKey, newKey_len)
Z_PARAM_OPTIONAL
Z_PARAM_STRING(parentKey, parentKey_len)
Z_PARAM_BOOL(is_attr_checked)
Z_PARAM_STRING(password, password_len)
Z_PARAM_LONG(expire)
ZEND_PARSE_PARAMETERS_END();
// validate_after_assign
time_t* ptmexpire = NULL;
if (expire > 0) {
ptmexpire = (time_t*)&expire;
}
// get_resources after get_props
k2hdkc_chmpx_h* k2hdkc_chmpx_handle_ptr = (k2hdkc_chmpx_h *)zend_fetch_resource(Z_RES_P(zval_k2hdkc_chmpx_handle_ptr), "chmpx_handle_resource", k2hdkcpx_handle_resource_number);
if (K2HDKC_INVALID_HANDLE == *k2hdkc_chmpx_handle_ptr) {
php_error(E_NOTICE, "_handle property is invalid");
RETURN_FALSE; // RETVAL_FALSE; return;
}
// call_some_functions after get_resources
//// bool k2hdkc_pm_rename_with_parent_str_wa(k2hdkc_chmpx_h handle, const char* poldkey, const char* pnewkey, const char* pparentkey, bool checkattr, const char* encpass, const time_t* expire)
bool bResult = k2hdkc_pm_rename_with_parent_str_wa(*k2hdkc_chmpx_handle_ptr, key, newKey, NULL, is_attr_checked, password, ptmexpire);
// return_result after call_some_functions
if (!bResult) {
// return_result after call_some_functions
php_error(E_NOTICE, "k2hdkc_pm_rename_with_parent_str_wa should return true, but false");
RETURN_FALSE; // RETVAL_FALSE; return;
}
RETURN_TRUE; // RETVAL_TRUE; return;
}
// set_subkeys
// bool k2hdkc_pm_set_subkeys(k2hdkc_chmpx_h handle, const unsigned char* pkey, size_t keylength, const PK2HDKCKEYPCK pskeypck, int skeypckcnt)
PHP_FUNCTION(k2hdkcpx_set_subkeys)
{
// declare_variables
zval * zval_k2hdkc_chmpx_handle_ptr = NULL;
char* key = NULL;
size_t key_len = 0;
zval* subkeys = NULL;
// assign_after_declare
ZEND_PARSE_PARAMETERS_START(3, 3)