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 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079
|
/*
* @ (#)$RCSfile: Cns-python_typemaps.i,v $ $Revision: 6384 $ $Date: 2012-06-06 16:39:34 +0200 (Wed, 06 Jun 2012) $ CERN IT-DM/SMD Remi Mollon
*/
/***********************************************
SWIG input file for Cns Python interface
(including typemaps for non-trivial functions)
***********************************************/
#ifdef SWIGPYTHON
/***************************************
Helpers
***************************************/
%{
static int is_returncode = 0;
static PyObject* my_t_output_helper(PyObject* target, PyObject* o) {
PyObject* o2;
PyObject* o3;
if (!target || (is_returncode && target == Py_None)) {
target = o;
} else {
if (!PyTuple_Check(target)) {
o2 = target;
target = PyTuple_New(1);
PyTuple_SetItem(target, 0, o2);
}
o3 = PyTuple_New(1);
PyTuple_SetItem(o3, 0, o);
o2 = target;
target = PySequence_Concat(o2, o3);
Py_DECREF(o2);
Py_DECREF(o3);
}
is_returncode = 0;
return target;
}
static PyObject* serrno2pyexc (int value) {
PyObject *exc = NULL;
switch (value) {
case EFAULT:
case ENOMEM:
exc = PyExc_MemoryError;
break;
case EACCES:
case EPERM:
exc = PyExc_Exception;
break;
case ENOENT:
case EEXIST:
case ENOTDIR:
case EISDIR:
case ENAMETOOLONG:
case ERANGE:
case SENOSHOST:
exc = PyExc_ValueError;
break;
case EINVAL:
case EBADF:
exc = PyExc_SyntaxError;
break;
case SENOSSERV:
case SECOMERR:
case ENSNACT:
case ENOSPC:
exc = PyExc_SystemError;
break;
case SELOOP:
exc = PyExc_RuntimeError;
break;
default:
exc = PyExc_Exception;
}
return exc;
}
%}
%inline %{
PyObject *version () {
char str[256];
Cns_getifcevers (str);
return (PyString_FromString (str));
}
%}
/***************************************
Input (in) Typemaps
***************************************/
%typemap(in) char * {
if ($input == Py_None) {
$1 = NULL;
} else {
$1 = PyString_AsString ($input);
if ($1 && $1[0] == 0) $1 = NULL;
}
}
/* Nothing to free, need to overload default typemap as of swig 1.3.28 */
%typemap(freearg) (char *) %{%}
%typemap(in) u_signed64 {
if (PyInt_Check ($input))
$1 = PyInt_AsUnsignedLongLongMask ($input);
else if (PyLong_Check ($input))
$1 = PyLong_AsUnsignedLongLong ($input);
else {
PyErr_SetString (PyExc_TypeError, "int or long expected");
return NULL;
}
}
%typemap(in, numinputs=0) (int *OUTPUT) {
int tmp_int;
$1 = &tmp_int;
}
%typemap(in, numinputs=0) (unsigned int *OUTPUT) {
unsigned int tmp_int;
$1 = &tmp_int;
}
%typemap(in, numinputs=0) (char *STRING256OUT) {
char tmp_str[256];
$1 = tmp_str;
}
%typemap(in, numinputs=0) (char *COMMENTOUT) {
char tmp_str[CA_MAXCOMMENTLEN + 1];
$1 = tmp_str;
}
%typemap(in, numinputs=0) (char *PATHOUT, int LENGTH) {
char tmp_str[4096];
$1 = tmp_str;
$2 = 4096;
}
%typemap(in, numinputs=0) (int *LENGTH, struct Cns_filereplica **OUTPUT) {
int tmp_int;
struct Cns_filereplica *tmp_struct;
$1 = &tmp_int;
$2 = &tmp_struct;
}
%typemap(in) (char **INPUT, int LENGTH) {
int i;
if (!PyList_Check ($input)) {
PyErr_SetString (PyExc_ValueError, "Expecting a list");
return NULL;
}
$2 = PyList_Size ($input);
$1 = (char **) calloc ($2+1, sizeof (char *));
for (i = 0; i < $2; i++) {
PyObject *s = PyList_GetItem ($input,i);
if (!PyString_Check (s)) {
free ($1);
PyErr_SetString (PyExc_ValueError, "List items must be strings");
return NULL;
}
$1[i] = PyString_AsString (s);
}
$1[i] = 0;
}
// Free the char** used as input for the C function, if that is not used to build the return value
%typemap(freearg) (char **INPUT, int LENGTH) {
if ($1) free ($1);
}
%typemap(in) (int LENGTH, const char **INPUT) {
int i;
if (!PyList_Check ($input)) {
PyErr_SetString (PyExc_ValueError, "Expecting a list");
return NULL;
}
$1 = PyList_Size ($input);
$2 = (char **) calloc ($1+1, sizeof (char *));
for (i = 0; i < $1; i++) {
PyObject *s = PyList_GetItem ($input,i);
if (!PyString_Check (s)) {
free ($2);
PyErr_SetString (PyExc_ValueError, "List items must be strings");
return NULL;
}
$2[i] = PyString_AsString (s);
}
$2[i] = 0;
}
// Free the char** used as input for the C function, if that is not used to build the return value
%typemap(freearg) (int LENGTH, const char **INPUT) {
if ($2) free ($2);
}
%typemap(in) (const char **INPUTLIST2) {
int i;
if (!PyList_Check ($input)) {
PyErr_SetString (PyExc_ValueError, "Expecting a list");
return NULL;
}
$1 = (char **) calloc (arg1+1, sizeof (char *));
for (i = 0; i < arg1; i++) {
PyObject *s = PyList_GetItem ($input,i);
if (!PyString_Check (s)) {
free ($1);
PyErr_SetString (PyExc_ValueError, "List items must be strings");
return NULL;
}
$1[i] = PyString_AsString (s);
}
$1[i] = 0;
}
// Free the char** used as input for the C function, if that is not used to build the return value
%typemap(freearg) (const char **INPUTLIST2) {
if ($1) free ($1);
}
%typemap(in, numinputs=0) (int *LENGTH, struct Cns_filereplicas **OUTPUT) {
int tmp_int;
struct Cns_filereplicas *tmp_struct;
$1 = &tmp_int;
$2 = &tmp_struct;
}
%typemap(in, numinputs=0) (int *LENGTH, struct Cns_filereplicax **OUTPUT) {
int tmp_int;
struct Cns_filereplicax *tmp_struct;
$1 = &tmp_int;
$2 = &tmp_struct;
}
%typemap(in, numinputs=0) (int *LENGTH, struct Cns_linkinfo **OUTPUT) {
int tmp_int;
struct Cns_linkinfo *tmp_struct;
$1 = &tmp_int;
$2 = &tmp_struct;
}
%typemap(in) (int LENGTH, struct Cns_acl *INPUT) {
/* Check the input list */
if (!PyList_Check ($input)) {
PyErr_SetString (PyExc_ValueError, "Expecting a list");
return NULL;
}
/* No error */
else {
/* Length of the python list (how many Cns_acl structs we will need) */
$1 = PyList_Size ($input);
/* Reserve space to store all the list members in an array (after converting them) */
$2 = (struct Cns_acl *) calloc ($1, sizeof (struct Cns_acl)) ;
int i;
for (i=0; i<$1; i++) {
PyObject * aux_object = PyList_GetItem ($input, i);
/* Temp pointer */
struct Cns_acl * aux_p;
/* This moves aux_p to point to a newly allocated Cns_acl struct representing the item in the python list */
SWIG_ConvertPtr (aux_object, (void**) &aux_p,
$descriptor(struct Cns_acl *), SWIG_POINTER_EXCEPTION);
/* Copy the value to the array */
$2[i] = *aux_p;
}
}/* end of: No error */
}/* end of: typemap(in) */
/* Free the temporary Cns_acl array passed to the C function after the Cns_setacl function has returned */
%typemap(freearg) (int LENGTH, struct Cns_acl *INPUT) {
if ($2) free ($2);
}
%typemap(in, numinputs=0) (int LENGTH, struct Cns_acl *OUTPUT) {
$1 = 255;
$2 = (struct Cns_acl *) calloc ($1, sizeof (struct Cns_acl));
}
%typemap(in) (int LENGTH, struct Cns_filereg *INPUT) {
/* Check the input list */
if (!PyList_Check ($input)) {
PyErr_SetString (PyExc_ValueError, "Expecting a list");
return NULL;
}
/* No error */
else {
/* Length of the python list (how many structs we will need) */
$1 = PyList_Size ($input);
/* Reserve space to store all the list members in an array (after converting them) */
$2 = (struct Cns_filereg *) calloc ($1, sizeof (struct Cns_filereg)) ;
int i;
for (i=0; i<$1; i++) {
PyObject * aux_object = PyList_GetItem ($input, i);
/* Temp pointer */
struct Cns_filereg * aux_p;
/* This moves aux_p to point to a newly allocated Cns_filereg struct representing the item in the python list */
SWIG_ConvertPtr (aux_object, (void**) &aux_p,
$descriptor(struct Cns_filereg *), SWIG_POINTER_EXCEPTION);
/* Copy the value to the array */
$2[i] = *aux_p;
}
}/* end of: No error */
}/* end of: typemap(in) */
/* Free the temporary Cns_filereg array passed to the C function after the Cns_registerfiles function has returned */
%typemap(freearg) (int LENGTH, struct Cns_filereg *INPUT) {
if ($2) free ($2);
}
%typemap(in) (int LENGTH, gid_t *INPUT, char **OUTPUTS1) {
int i;
if (!PyList_Check ($input)) {
PyErr_SetString (PyExc_ValueError, "Expecting a list");
return NULL;
}
$1 = PyList_Size ($input);
$2 = (gid_t *) calloc ($1, sizeof (gid_t));
$3 = (char **) calloc ($1 + 1, sizeof (char *));
for (i = 0; i < $1; i++) {
PyObject *s = PyList_GetItem ($input,i);
if (!PyInt_Check (s)) {
free ($2);
PyErr_SetString (PyExc_ValueError, "List items must be integers");
return NULL;
}
$2[i] = (gid_t) PyInt_AsLong (s);
}
}
%typemap(freearg) (int LENGTH, gid_t *INPUT) {
if ($2) free ($2);
}
%typemap(freearg) (char **OUTPUTS1) {
if ($1) free ($1);
}
%typemap(freearg) (int LENGTH, gid_t *INPUT) {
if ($2) free ($2);
}
%typemap(freearg) (char **OUTPUTS1) {
if ($1) free ($1);
}
%typemap(in, numinputs=0) (int *LENGTH, int **OUTPUT) {
int tmp_int;
int *tmp_tab;
$1 = &tmp_int;
$2 = &tmp_tab;
}
%typemap(in, numinputs=0) (int *LENGTH, struct Cns_filestatus **OUTPUT) {
int tmp_int;
struct Cns_filestatus *tmp_struct;
$1 = &tmp_int;
$2 = &tmp_struct;
}
%typemap(in, numinputs=0) (int *LENGTH, struct Cns_userinfo **OUTPUT) {
int tmp_int;
struct Cns_userinfo *tmp_struct;
$1 = &tmp_int;
$2 = &tmp_struct;
}
%typemap(in, numinputs=0) (int *LENGTH, struct Cns_groupinfo **OUTPUT) {
int tmp_int;
struct Cns_groupinfo *tmp_struct;
$1 = &tmp_int;
$2 = &tmp_struct;
}
%typemap(in, numinputs=0) (struct Cns_filestat *STATOUT) {
$1 = (struct Cns_filestat *) calloc (1, sizeof (struct Cns_filestat));
}
%typemap(in, numinputs=0) (struct Cns_filestatg *STATOUT) {
$1 = (struct Cns_filestatg *) calloc (1, sizeof (struct Cns_filestatg));
}
%typemap(in, numinputs=1) (int LENGTH, const char **INPUT, uid_t *OUTPUT, gid_t *IDMAPOUTPUT) (uid_t tmp_uid){
int i;
if (!PyList_Check ($input)) {
PyErr_SetString (PyExc_ValueError, "Expecting a list");
return NULL;
}
$1 = PyList_Size ($input);
$2 = (char **) calloc ($1+1, sizeof (char *));
for (i = 0; i < $1; i++) {
PyObject *s = PyList_GetItem ($input,i);
if (!PyString_Check (s)) {
free ($2);
PyErr_SetString (PyExc_ValueError, "List items must be strings");
return NULL;
}
$2[i] = PyString_AsString (s);
}
$2[i] = 0;
$3 = &tmp_uid;
$4 = (gid_t *) calloc ($1 > 0 ? $1 : 1, sizeof (gid_t));
}
%typemap(freearg) (gid_t *IDMAPOUTPUT) {
if ($1) free ($1);
}
%typemap(in, numinputs=1) (int LENGTH, const char **INPUT, uid_t *OUTPUT, gid_t *IDMAPOUTPUT1) (uid_t tmp_uid){
int i;
if (!PyList_Check ($input)) {
PyErr_SetString (PyExc_ValueError, "Expecting a list");
return NULL;
}
$1 = PyList_Size ($input);
$2 = (char **) calloc ($1+1, sizeof (char *));
for (i = 0; i < $1; i++) {
PyObject *s = PyList_GetItem ($input,i);
if (!PyString_Check (s)) {
free ($2);
PyErr_SetString (PyExc_ValueError, "List items must be strings");
return NULL;
}
$2[i] = PyString_AsString (s);
}
$2[i] = 0;
$3 = &tmp_uid;
$4 = (gid_t *) calloc ($1 > 0 ? $1 : 1, sizeof (gid_t));
}
%typemap(freearg) (gid_t *IDMAPOUTPUT) {
if ($1) free ($1);
}
%typemap(in, numinputs=1) (int LENGTH, const char **INPUT, uid_t *OUTPUT, gid_t *IDMAPOUTPUT1) (uid_t tmp_uid){
int i;
if (!PyList_Check ($input)) {
PyErr_SetString (PyExc_ValueError, "Expecting a list");
return NULL;
}
$1 = PyList_Size ($input);
$2 = (char **) calloc ($1+1, sizeof (char *));
for (i = 0; i < $1; i++) {
PyObject *s = PyList_GetItem ($input,i);
if (!PyString_Check (s)) {
free ($2);
PyErr_SetString (PyExc_ValueError, "List items must be strings");
return NULL;
}
$2[i] = PyString_AsString (s);
}
$2[i] = 0;
$3 = &tmp_uid;
$4 = (gid_t *) calloc ($1 > 0 ? $1 : 1, sizeof (gid_t));
}
%typemap(freearg) (gid_t *IDMAPOUTPUT1) {
if ($1) free ($1);
}
/***************************************
Output (out/argout) Typemaps
***************************************/
%typemap(out,noblock=1) RETURNCODE {
if ($1 < 0) {
PyErr_SetString (serrno2pyexc (serrno), serrbuf);
return (NULL);
}
is_returncode = 1;
$result = Py_None;
}
%typemap(out,noblock=1) RETURNCODE_BOOL {
if ($1 < 0) {
PyErr_SetString (serrno2pyexc (serrno), serrbuf);
return (NULL);
}
is_returncode = 0;
$result = PyInt_FromLong ($1);
}
%typemap(out,noblock=1) int {
$result = PyInt_FromLong ($1);
}
%typemap(out) char[ANY] {
$result = PyString_FromString ($1);
}
%typemap(argout) (int *OUTPUT) {
$result = my_t_output_helper($result, PyInt_FromLong (*$1));
}
%typemap(argout) (unsigned int *OUTPUT) {
$result = my_t_output_helper($result, PyInt_FromLong (*$1));
}
%typemap(argout) (char *STRING256OUT), (char *COMMENTOUT), (char *PATHOUT, int LENGTH) {
PyObject *myresult;
/* Error, return None */
if (result < 0) {
Py_INCREF (Py_None);
myresult = Py_None;
}
/* No error */
else {
myresult = PyString_FromString ($1);
}
$result = my_t_output_helper($result, myresult);
}
%typemap(argout) (int LENGTH, struct Cns_acl *OUTPUT) {
PyObject *myresult;
/* Error */
if (result < 0) {
Py_INCREF (Py_None);
myresult = Py_None;
}
/* No error */
else {
/* No structs returned, only number of ACL entries */
if ($2 == 0) {
Py_INCREF (Py_None);
myresult = Py_None;
}
/* Structs returned in array */
else {
int i, len = result;
myresult = PyList_New (len);
for (i = 0; i < len; i++) {
/* Let python garbage-collect only the 1st one. That will already delete it all!
Because the original var was Cns_al* and not Cns_acl** (only 1 pointer responsible) */
int PYTHON_OWNED = i > 0 ? 0 : 1;
/* Python object for each of the Cns_acl structs set by the C call */
PyObject * aux_obj = SWIG_NewPointerObj (&$2[i], $descriptor(struct Cns_acl *), PYTHON_OWNED);
PyList_SetItem (myresult, i, aux_obj);
}/* end of for */
}/* end of: Structs returned in array */
}/* end of: No error */
$result = my_t_output_helper($result, myresult);
}/* end of: typemap(argout) */
%typemap(out) struct Cns_direnrep * {
PyObject *myresult;
/* Don't let python garbage-collect these structures, because they are freed with Cns_closedir */
int PYTHON_OWNED=0;
/* Error, return None */
if ($1 == 0) {
Py_INCREF (Py_None);
myresult = Py_None;
}
/* No error */
else {
/* Python object for the Cns_direnrep set by the C call */
myresult = SWIG_NewPointerObj ($1, $descriptor(struct Cns_direnrep *), PYTHON_OWNED);
}
$result = my_t_output_helper(NULL, myresult);
}
%typemap(out) struct Cns_rep_info * {
PyObject *myresult;
int len = (arg1)->nbreplicas;
/* Don't let python garbage-collect these structures, because they are freed with Cns_closedir */
int PYTHON_OWNED=0;
/* Error, return None */
if ($1 == 0 || len < 0) {
Py_INCREF (Py_None);
myresult = Py_None;
}
/* No error */
else {
myresult = PyList_New (len);
int i;
for (i = 0; i < len; i++) {
/* Python object for each of the Cns_rep_info structs set by the C call */
PyObject * aux_rep = SWIG_NewPointerObj ($1 + i, $descriptor(struct Cns_rep_info *), PYTHON_OWNED);
PyList_SetItem (myresult, i, aux_rep);
}
}
$result = my_t_output_helper(NULL, myresult);
}
%typemap(argout) (int *LENGTH, struct Cns_filereplica **OUTPUT) {
PyObject *myresult;
/* Error, return None */
if (result < 0) {
Py_INCREF (Py_None);
myresult = Py_None;
}
/* No error */
else {
myresult = PyList_New (*$1);
int i;
for (i = 0; i < *$1; i++) {
/* Let python garbage-collect only the 1st one. That will already delete it all! */
int PYTHON_OWNED = i > 0 ? 0 : 1;
struct Cns_filereplica * aux = (struct Cns_filereplica *) (*$2)+i;
/* Create a python object based on the C struct set by the C function */
PyObject * aux_obj = SWIG_NewPointerObj (aux, $descriptor(struct Cns_filereplica *), PYTHON_OWNED);
/* Add the python object to the tuple to return */
PyList_SetItem (myresult, i, aux_obj);
}
}
$result = my_t_output_helper($result, myresult);
}
%typemap(argout) (int *LENGTH, struct Cns_filereplicas **OUTPUT) {
PyObject *myresult;
/* Error, return None */
if (result < 0) {
Py_INCREF (Py_None);
myresult = Py_None;
}
/* No error */
else {
myresult = PyList_New (*$1);
int i;
for (i = 0; i < *$1; i++) {
/* Let python garbage-collect only the 1st one. That will already delete it all! */
int PYTHON_OWNED = i > 0 ? 0 : 1;
struct Cns_filereplicas * aux = (struct Cns_filereplicas *) (*$2)+i;
/* Create a python object based on the C struct set by the C function */
PyObject * aux_obj = SWIG_NewPointerObj (aux, $descriptor(struct Cns_filereplicas *), PYTHON_OWNED);
/* Add the python object to the tuple to return */
PyList_SetItem (myresult, i, aux_obj);
}
}
$result = my_t_output_helper($result, myresult);
}
%typemap(argout) (int *LENGTH, struct Cns_filereplicax **OUTPUT) {
PyObject *myresult;
/* Error, return None */
if (result < 0) {
Py_INCREF (Py_None);
myresult = Py_None;
}
/* No error */
else {
myresult = PyList_New (*$1);
int i;
for (i = 0; i < *$1; i++) {
/* Let python garbage-collect only the 1st one. That will already delete it all! */
int PYTHON_OWNED = i > 0 ? 0 : 1;
struct Cns_filereplicax * aux = (struct Cns_filereplicax *) (*$2)+i;
/* Create a python object based on the C struct set by the C function */
PyObject * aux_obj = SWIG_NewPointerObj (aux, $descriptor(struct Cns_filereplicax *), PYTHON_OWNED);
/* Add the python object to the tuple to return */
PyList_SetItem (myresult, i, aux_obj);
}
}
$result = my_t_output_helper($result, myresult);
}
%typemap(argout) (int *LENGTH, struct Cns_linkinfo **OUTPUT) {
PyObject *myresult;
/* Error, return None */
if (result < 0) {
Py_INCREF (Py_None);
myresult = Py_None;
}
/* No error */
else {
myresult = PyList_New (*$1);
int i;
for (i = 0; i < *$1; i++) {
/* Let python garbage-collect only the 1st one. That will already delete it all! */
int PYTHON_OWNED = i > 0 ? 0 : 1;
struct Cns_linkinfo * aux = (struct Cns_linkinfo *) (*$2)+i;
/* Create a python object based on the C struct set by the C function */
PyObject * aux_obj = SWIG_NewPointerObj (aux, $descriptor(struct Cns_linkinfo *), PYTHON_OWNED);
/* Add the python object to the tuple to return */
PyList_SetItem (myresult, i, aux_obj);
}
}
$result = my_t_output_helper($result, myresult);
}
%typemap(argout) (int *LENGTH, int **OUTPUT) {
PyObject *myresult;
/* Error */
if (result < 0 || *$1 < 0) {
Py_INCREF (Py_None);
myresult = Py_None;
}
/* No error */
else {
int i;
PyObject *aux_obj;
myresult = PyList_New (*$1);
for (i = 0; i < *$1; i++) {
aux_obj = PyInt_FromLong ((long) (*$2)[i]);
PyList_SetItem (myresult, i, aux_obj);
}/* end of for */
}/* end of: No error */
$result = my_t_output_helper($result, myresult);
}/* end of: typemap(argout) */
%typemap(argout) (int *LENGTH, struct Cns_filestatus **OUTPUT) {
PyObject *myresult;
/* Error, return None */
if (result < 0 || *$1 < 0) {
Py_INCREF (Py_None);
myresult = Py_None;
}
/* No error */
else {
int i;
myresult = PyList_New (*$1);
for (i = 0; i < *$1; i++) {
/* Let python garbage-collect only the 1st one. That will already delete it all! */
int PYTHON_OWNED = i>0 ? 0 : 1;
struct Cns_filestatus * aux = (struct Cns_filestatus *) (*$2)+i;
/* Create a python object based on the C struct set by the C function */
PyObject * aux_obj = SWIG_NewPointerObj (aux, $descriptor(struct Cns_filestatus *), PYTHON_OWNED);
/* Add the python object to the tuple to return */
PyList_SetItem (myresult, i, aux_obj);
}
}
$result = my_t_output_helper($result, myresult);
}
%typemap(argout) (int *LENGTH, struct Cns_userinfo **OUTPUT) {
PyObject *myresult;
/* Error, return None */
if (result < 0 || *$1 < 0) {
Py_INCREF (Py_None);
myresult = Py_None;
}
/* No error */
else {
int i;
myresult = PyList_New (*$1);
for (i = 0; i < *$1; i++) {
/* Let python garbage-collect only the 1st one. That will already delete it all! */
int PYTHON_OWNED = i > 0 ? 0 : 1;
struct Cns_userinfo * aux = (struct Cns_userinfo *) (*$2)+i;
/* Create a python object based on the C struct set by the C function */
PyObject * aux_obj = SWIG_NewPointerObj (aux, $descriptor(struct Cns_userinfo *), PYTHON_OWNED);
/* Add the python object to the tuple to return */
PyList_SetItem (myresult, i, aux_obj);
}
}
$result = my_t_output_helper($result, myresult);
}
%typemap(argout) (int *LENGTH, struct Cns_groupinfo **OUTPUT) {
PyObject *myresult;
/* Error, return None */
if (result < 0 || *$1 < 0) {
Py_INCREF (Py_None);
myresult = Py_None;
}
/* No error */
else {
int i;
myresult = PyList_New (*$1);
for (i = 0; i < *$1; i++) {
/* Let python garbage-collect only the 1st one. That will already delete it all! */
int PYTHON_OWNED = i > 0 ? 0 : 1;
struct Cns_groupinfo * aux = (struct Cns_groupinfo *) (*$2)+i;
/* Create a python object based on the C struct set by the C function */
PyObject * aux_obj = SWIG_NewPointerObj (aux, $descriptor(struct Cns_groupinfo *), PYTHON_OWNED);
/* Add the python object to the tuple to return */
PyList_SetItem (myresult, i, aux_obj);
}
}
$result = my_t_output_helper($result, myresult);
}
%typemap(argout) (struct Cns_filestat *STATOUT) {
PyObject *myresult;
/* Error, return None */
if (result < 0) {
Py_INCREF (Py_None);
myresult = Py_None;
}
/* No error */
else {
int PYTHON_OWNED = 1;
struct Cns_filestat * aux = (struct Cns_filestat *) $1;
/* Create a python object based on the C struct set by the C function */
myresult = SWIG_NewPointerObj (aux, $descriptor(struct Cns_filestat *), PYTHON_OWNED);
}
$result = my_t_output_helper($result, myresult);
}
%typemap(argout) (struct Cns_filestatg *STATOUT) {
PyObject *myresult;
/* Error, return None */
if (result < 0) {
Py_INCREF (Py_None);
myresult = Py_None;
}
/* No error */
else {
int PYTHON_OWNED = 1;
struct Cns_filestatg * aux = (struct Cns_filestatg *) $1;
/* Create a python object based on the C struct set by the C function */
myresult = SWIG_NewPointerObj (aux, $descriptor(struct Cns_filestatg *), PYTHON_OWNED);
}
$result = my_t_output_helper($result, myresult);
}
%typemap(argout) (char **OUTPUTS1) {
PyObject *myresult;
/* Error, return None */
if (result < 0) {
Py_INCREF (Py_None);
myresult = Py_None;
}
/* No error */
else {
int i;
myresult = PyList_New (arg1);
for (i = 0; i < arg1; ++i)
PyList_SetItem (myresult, i, PyString_FromString ($1[i]));
}
$result = my_t_output_helper($result, myresult);
}
%typemap(argout) (gid_t *IDMAPOUTPUT) {
PyObject *myresult;
/* Error, return None */
if (result < 0) {
Py_INCREF (Py_None);
myresult = Py_None;
}
/* No error */
else {
int i;
myresult = PyList_New (arg2);
for (i = 0; i < arg2; ++i)
PyList_SetItem (myresult, i, PyInt_FromLong ($1[i]));
}
$result = my_t_output_helper($result, myresult);
}
%typemap(argout) (gid_t *IDMAPOUTPUT1) {
PyObject *myresult;
/* Error, return None */
if (result < 0) {
Py_INCREF (Py_None);
myresult = Py_None;
}
/* No error */
else {
int i;
myresult = PyList_New (arg3);
for (i = 0; i < arg3; ++i)
PyList_SetItem (myresult, i, PyInt_FromLong ($1[i]));
}
$result = my_t_output_helper($result, myresult);
}
#endif
|