Changeset 740 for vendor/current/pidl


Ignore:
Timestamp:
Nov 14, 2012, 12:59:34 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to 3.6.0

Location:
vendor/current/pidl
Files:
2 added
2 deleted
24 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/pidl/idl.yp

    r414 r740  
    170170
    171171typedef:
    172         property_list 'typedef' type identifier array_len ';'
     172        property_list 'typedef' type pointers identifier array_len ';'
    173173        {{
    174174                "TYPE" => "TYPEDEF",
    175175                "PROPERTIES" => $_[1],
    176                 "NAME" => $_[4],
     176                "NAME" => $_[5],
    177177                "DATA" => $_[3],
    178                 "ARRAY_LEN" => $_[5],
     178                "POINTERS" => $_[4],
     179                "ARRAY_LEN" => $_[6],
    179180                "FILE" => $_[0]->YYData->{FILE},
    180181                "LINE" => $_[0]->YYData->{LINE},
     
    387388                "TYPE" => "PIPE",
    388389                "PROPERTIES" => $_[1],
    389                 "DATA" => $_[3],
     390                "NAME" => undef,
     391                "DATA" => {
     392                        "TYPE" => "STRUCT",
     393                        "PROPERTIES" => $_[1],
     394                        "NAME" => undef,
     395                        "ELEMENTS" => [{
     396                                "NAME" => "count",
     397                                "PROPERTIES" => $_[1],
     398                                "POINTERS" => 0,
     399                                "ARRAY_LEN" => [],
     400                                "TYPE" => "uint3264",
     401                                "FILE" => $_[0]->YYData->{FILE},
     402                                "LINE" => $_[0]->YYData->{LINE},
     403                        },{
     404                                "NAME" => "array",
     405                                "PROPERTIES" => $_[1],
     406                                "POINTERS" => 0,
     407                                "ARRAY_LEN" => [ "count" ],
     408                                "TYPE" => $_[3],
     409                                "FILE" => $_[0]->YYData->{FILE},
     410                                "LINE" => $_[0]->YYData->{LINE},
     411                        }],
     412                        "FILE" => $_[0]->YYData->{FILE},
     413                        "LINE" => $_[0]->YYData->{LINE},
     414                },
    390415                "FILE" => $_[0]->YYData->{FILE},
    391416                "LINE" => $_[0]->YYData->{LINE},
     
    653678        undef $/;
    654679        my $cpp = $ENV{CPP};
     680        my $options = "";
    655681        if (! defined $cpp) {
    656                 $cpp = "cpp";
     682                if (defined $ENV{CC}) {
     683                        $cpp = "$ENV{CC}";
     684                        $options = "-E";
     685                } else {
     686                        $cpp = "cpp";
     687                }
    657688        }
    658689        my $includes = join('',map { " -I$_" } @$incdirs);
    659         my $data = `$cpp -D__PIDL__$includes -xc $filename`;
     690        my $data = `$cpp $options -D__PIDL__$includes -xc "$filename"`;
    660691        $/ = $saved_delim;
    661692
  • vendor/current/pidl/lib/Parse/Pidl/Compat.pm

    r414 r740  
    2020        "endpoint"              => ["INTERFACE"],
    2121        "pointer_default"       => ["INTERFACE"],
     22        "no_srv_register"       => ["INTERFACE"],
    2223
    2324        # dcom
     
    4546        "nopull"                => ["FUNCTION", "TYPEDEF"],
    4647        "noprint"               => ["FUNCTION", "TYPEDEF"],
     48        "nopython"              => ["FUNCTION", "TYPEDEF"],
    4749
    4850        # union
     
    126128        }
    127129
     130        if (has_property($e, "relative_short")) {
     131                warning($e, "relative_short() pointer property not supported");
     132        }
     133
    128134        if (has_property($e, "flag")) {
    129135                warning($e, "ignoring flag() property");
  • vendor/current/pidl/lib/Parse/Pidl/Expr.pm

    r414 r740  
    11281128                 'exp', 1,
    11291129sub
    1130 #line 24 "./../pidl/expr.yp"
     1130#line 24 "expr.yp"
    11311131{ "\"$_[1]\"" }
    11321132        ],
     
    11401140                 'exp', 2,
    11411141sub
    1142 #line 30 "./../pidl/expr.yp"
     1142#line 30 "expr.yp"
    11431143{ "~$_[2]" }
    11441144        ],
     
    11461146                 'exp', 3,
    11471147sub
    1148 #line 32 "./../pidl/expr.yp"
     1148#line 32 "expr.yp"
    11491149{ "$_[1] + $_[3]" }
    11501150        ],
     
    11521152                 'exp', 3,
    11531153sub
    1154 #line 34 "./../pidl/expr.yp"
     1154#line 34 "expr.yp"
    11551155{ "$_[1] - $_[3]" }
    11561156        ],
     
    11581158                 'exp', 3,
    11591159sub
    1160 #line 36 "./../pidl/expr.yp"
     1160#line 36 "expr.yp"
    11611161{ "$_[1] * $_[3]" }
    11621162        ],
     
    11641164                 'exp', 3,
    11651165sub
    1166 #line 38 "./../pidl/expr.yp"
     1166#line 38 "expr.yp"
    11671167{ "$_[1] % $_[3]" }
    11681168        ],
     
    11701170                 'exp', 3,
    11711171sub
    1172 #line 40 "./../pidl/expr.yp"
     1172#line 40 "expr.yp"
    11731173{ "$_[1] < $_[3]" }
    11741174        ],
     
    11761176                 'exp', 3,
    11771177sub
    1178 #line 42 "./../pidl/expr.yp"
     1178#line 42 "expr.yp"
    11791179{ "$_[1] > $_[3]" }
    11801180        ],
     
    11821182                 'exp', 3,
    11831183sub
    1184 #line 44 "./../pidl/expr.yp"
     1184#line 44 "expr.yp"
    11851185{ "$_[1] | $_[3]" }
    11861186        ],
     
    11881188                 'exp', 3,
    11891189sub
    1190 #line 46 "./../pidl/expr.yp"
     1190#line 46 "expr.yp"
    11911191{ "$_[1] == $_[3]" }
    11921192        ],
     
    11941194                 'exp', 3,
    11951195sub
    1196 #line 48 "./../pidl/expr.yp"
     1196#line 48 "expr.yp"
    11971197{ "$_[1] <= $_[3]" }
    11981198        ],
     
    12001200                 'exp', 3,
    12011201sub
    1202 #line 50 "./../pidl/expr.yp"
     1202#line 50 "expr.yp"
    12031203{ "$_[1] => $_[3]" }
    12041204        ],
     
    12061206                 'exp', 3,
    12071207sub
    1208 #line 52 "./../pidl/expr.yp"
     1208#line 52 "expr.yp"
    12091209{ "$_[1] << $_[3]" }
    12101210        ],
     
    12121212                 'exp', 3,
    12131213sub
    1214 #line 54 "./../pidl/expr.yp"
     1214#line 54 "expr.yp"
    12151215{ "$_[1] >> $_[3]" }
    12161216        ],
     
    12181218                 'exp', 3,
    12191219sub
    1220 #line 56 "./../pidl/expr.yp"
     1220#line 56 "expr.yp"
    12211221{ "$_[1] != $_[3]" }
    12221222        ],
     
    12241224                 'exp', 3,
    12251225sub
    1226 #line 58 "./../pidl/expr.yp"
     1226#line 58 "expr.yp"
    12271227{ "$_[1] || $_[3]" }
    12281228        ],
     
    12301230                 'exp', 3,
    12311231sub
    1232 #line 60 "./../pidl/expr.yp"
     1232#line 60 "expr.yp"
    12331233{ "$_[1] && $_[3]" }
    12341234        ],
     
    12361236                 'exp', 3,
    12371237sub
    1238 #line 62 "./../pidl/expr.yp"
     1238#line 62 "expr.yp"
    12391239{ "$_[1] & $_[3]" }
    12401240        ],
     
    12421242                 'exp', 5,
    12431243sub
    1244 #line 64 "./../pidl/expr.yp"
     1244#line 64 "expr.yp"
    12451245{ "$_[1]?$_[3]:$_[5]" }
    12461246        ],
     
    12481248                 'exp', 2,
    12491249sub
    1250 #line 66 "./../pidl/expr.yp"
     1250#line 66 "expr.yp"
    12511251{ "~$_[1]" }
    12521252        ],
     
    12541254                 'exp', 2,
    12551255sub
    1256 #line 68 "./../pidl/expr.yp"
     1256#line 68 "expr.yp"
    12571257{ "not $_[1]" }
    12581258        ],
     
    12601260                 'exp', 3,
    12611261sub
    1262 #line 70 "./../pidl/expr.yp"
     1262#line 70 "expr.yp"
    12631263{ "$_[1] / $_[3]" }
    12641264        ],
     
    12661266                 'exp', 2,
    12671267sub
    1268 #line 72 "./../pidl/expr.yp"
     1268#line 72 "expr.yp"
    12691269{ "-$_[2]" }
    12701270        ],
     
    12721272                 'exp', 2,
    12731273sub
    1274 #line 74 "./../pidl/expr.yp"
     1274#line 74 "expr.yp"
    12751275{ "&$_[2]" }
    12761276        ],
     
    12781278                 'exp', 3,
    12791279sub
    1280 #line 76 "./../pidl/expr.yp"
     1280#line 76 "expr.yp"
    12811281{ "$_[1]^$_[3]" }
    12821282        ],
     
    12841284                 'exp', 3,
    12851285sub
    1286 #line 78 "./../pidl/expr.yp"
     1286#line 78 "expr.yp"
    12871287{ "($_[2])" }
    12881288        ],
     
    12901290                 'possible_pointer', 1,
    12911291sub
    1292 #line 82 "./../pidl/expr.yp"
     1292#line 82 "expr.yp"
    12931293{ $_[0]->_Lookup($_[1]) }
    12941294        ],
     
    12961296                 'possible_pointer', 2,
    12971297sub
    1298 #line 84 "./../pidl/expr.yp"
     1298#line 84 "expr.yp"
    12991299{ $_[0]->_Dereference($_[2]); "*$_[2]" }
    13001300        ],
     
    13021302                 'var', 1,
    13031303sub
    1304 #line 88 "./../pidl/expr.yp"
     1304#line 88 "expr.yp"
    13051305{ $_[0]->_Use($_[1]) }
    13061306        ],
     
    13081308                 'var', 3,
    13091309sub
    1310 #line 90 "./../pidl/expr.yp"
     1310#line 90 "expr.yp"
    13111311{ $_[0]->_Use("$_[1].$_[3]") }
    13121312        ],
     
    13141314                 'var', 3,
    13151315sub
    1316 #line 92 "./../pidl/expr.yp"
     1316#line 92 "expr.yp"
    13171317{ "($_[2])" }
    13181318        ],
     
    13201320                 'var', 3,
    13211321sub
    1322 #line 94 "./../pidl/expr.yp"
     1322#line 94 "expr.yp"
    13231323{ $_[0]->_Use("*$_[1]"); $_[1]."->".$_[3] }
    13241324        ],
     
    13261326                 'func', 4,
    13271327sub
    1328 #line 99 "./../pidl/expr.yp"
     1328#line 99 "expr.yp"
    13291329{ "$_[1]($_[3])" }
    13301330        ],
     
    13321332                 'opt_args', 0,
    13331333sub
    1334 #line 104 "./../pidl/expr.yp"
     1334#line 104 "expr.yp"
    13351335{ "" }
    13361336        ],
     
    13501350                 'args', 3,
    13511351sub
    1352 #line 118 "./../pidl/expr.yp"
     1352#line 118 "expr.yp"
    13531353{ "$_[1], $_[3]" }
    13541354        ]
     
    13581358}
    13591359
    1360 #line 121 "./../pidl/expr.yp"
     1360#line 121 "expr.yp"
    13611361
    13621362
  • vendor/current/pidl/lib/Parse/Pidl/IDL.pm

    r414 r740  
    10661066        },
    10671067        {#State 125
    1068                 ACTIONS => {
    1069                         'IDENTIFIER' => 26
    1070                 },
    1071                 GOTOS => {
    1072                         'identifier' => 137
     1068                DEFAULT => -75,
     1069                GOTOS => {
     1070                        'pointers' => 137
    10731071                }
    10741072        },
     
    11661164        {#State 137
    11671165                ACTIONS => {
    1168                         "[" => 155
    1169                 },
    1170                 DEFAULT => -86,
    1171                 GOTOS => {
    1172                         'array_len' => 156
     1166                        'IDENTIFIER' => 26,
     1167                        "*" => 152
     1168                },
     1169                GOTOS => {
     1170                        'identifier' => 155
    11731171                }
    11741172        },
     
    11791177                DEFAULT => -68,
    11801178                GOTOS => {
    1181                         'union_elements' => 157
     1179                        'union_elements' => 156
    11821180                }
    11831181        },
     
    11911189                DEFAULT => -78,
    11921190                GOTOS => {
    1193                         'element_list1' => 158
     1191                        'element_list1' => 157
    11941192                }
    11951193        },
     
    12021200                },
    12031201                GOTOS => {
    1204                         'identifier' => 159,
    1205                         'enum_element' => 160,
    1206                         'enum_elements' => 161
     1202                        'identifier' => 158,
     1203                        'enum_element' => 159,
     1204                        'enum_elements' => 160
    12071205                }
    12081206        },
     
    12221220                DEFAULT => -57,
    12231221                GOTOS => {
    1224                         'identifier' => 164,
    1225                         'bitmap_element' => 163,
    1226                         'bitmap_elements' => 162,
    1227                         'opt_bitmap_elements' => 165
     1222                        'identifier' => 163,
     1223                        'bitmap_element' => 162,
     1224                        'bitmap_elements' => 161,
     1225                        'opt_bitmap_elements' => 164
    12281226                }
    12291227        },
     
    12341232                ACTIONS => {
    12351233                        "," => -82,
    1236                         "void" => 169,
    1237                         "const" => 167,
     1234                        "void" => 168,
     1235                        "const" => 166,
    12381236                        ")" => -82
    12391237                },
    12401238                DEFAULT => -80,
    12411239                GOTOS => {
    1242                         'optional_const' => 166,
    1243                         'element_list2' => 168
     1240                        'optional_const' => 165,
     1241                        'element_list2' => 167
    12441242                }
    12451243        },
    12461244        {#State 151
    12471245                ACTIONS => {
    1248                         "[" => 155,
     1246                        "[" => 169,
    12491247                        "=" => 171
    12501248                },
     
    12891287        {#State 155
    12901288                ACTIONS => {
     1289                        "[" => 169
     1290                },
     1291                DEFAULT => -86,
     1292                GOTOS => {
     1293                        'array_len' => 172
     1294                }
     1295        },
     1296        {#State 156
     1297                ACTIONS => {
     1298                        "}" => 173
     1299                },
     1300                DEFAULT => -89,
     1301                GOTOS => {
     1302                        'optional_base_element' => 175,
     1303                        'property_list' => 174
     1304                }
     1305        },
     1306        {#State 157
     1307                ACTIONS => {
     1308                        "}" => 176
     1309                },
     1310                DEFAULT => -89,
     1311                GOTOS => {
     1312                        'base_element' => 177,
     1313                        'property_list' => 178
     1314                }
     1315        },
     1316        {#State 158
     1317                ACTIONS => {
     1318                        "=" => 179
     1319                },
     1320                DEFAULT => -49
     1321        },
     1322        {#State 159
     1323                DEFAULT => -47
     1324        },
     1325        {#State 160
     1326                ACTIONS => {
     1327                        "}" => 180,
     1328                        "," => 181
     1329                }
     1330        },
     1331        {#State 161
     1332                ACTIONS => {
     1333                        "," => 182
     1334                },
     1335                DEFAULT => -58
     1336        },
     1337        {#State 162
     1338                DEFAULT => -55
     1339        },
     1340        {#State 163
     1341                ACTIONS => {
     1342                        "=" => 183
     1343                }
     1344        },
     1345        {#State 164
     1346                ACTIONS => {
     1347                        "}" => 184
     1348                }
     1349        },
     1350        {#State 165
     1351                DEFAULT => -89,
     1352                GOTOS => {
     1353                        'base_element' => 185,
     1354                        'property_list' => 178
     1355                }
     1356        },
     1357        {#State 166
     1358                DEFAULT => -81
     1359        },
     1360        {#State 167
     1361                ACTIONS => {
     1362                        "," => 186,
     1363                        ")" => 187
     1364                }
     1365        },
     1366        {#State 168
     1367                DEFAULT => -83
     1368        },
     1369        {#State 169
     1370                ACTIONS => {
    12911371                        'CONSTANT' => 48,
    12921372                        'TEXT' => 16,
    1293                         "]" => 172,
     1373                        "]" => 188,
    12941374                        'IDENTIFIER' => 26
    12951375                },
     
    12971377                GOTOS => {
    12981378                        'identifier' => 50,
    1299                         'anytext' => 173,
     1379                        'anytext' => 189,
    13001380                        'text' => 51,
    13011381                        'constant' => 47
    13021382                }
    1303         },
    1304         {#State 156
    1305                 ACTIONS => {
    1306                         ";" => 174
    1307                 }
    1308         },
    1309         {#State 157
    1310                 ACTIONS => {
    1311                         "}" => 175
    1312                 },
    1313                 DEFAULT => -89,
    1314                 GOTOS => {
    1315                         'optional_base_element' => 177,
    1316                         'property_list' => 176
    1317                 }
    1318         },
    1319         {#State 158
    1320                 ACTIONS => {
    1321                         "}" => 178
    1322                 },
    1323                 DEFAULT => -89,
    1324                 GOTOS => {
    1325                         'base_element' => 179,
    1326                         'property_list' => 180
    1327                 }
    1328         },
    1329         {#State 159
    1330                 ACTIONS => {
    1331                         "=" => 181
    1332                 },
    1333                 DEFAULT => -49
    1334         },
    1335         {#State 160
    1336                 DEFAULT => -47
    1337         },
    1338         {#State 161
    1339                 ACTIONS => {
    1340                         "}" => 182,
    1341                         "," => 183
    1342                 }
    1343         },
    1344         {#State 162
    1345                 ACTIONS => {
    1346                         "," => 184
    1347                 },
    1348                 DEFAULT => -58
    1349         },
    1350         {#State 163
    1351                 DEFAULT => -55
    1352         },
    1353         {#State 164
    1354                 ACTIONS => {
    1355                         "=" => 185
    1356                 }
    1357         },
    1358         {#State 165
    1359                 ACTIONS => {
    1360                         "}" => 186
    1361                 }
    1362         },
    1363         {#State 166
    1364                 DEFAULT => -89,
    1365                 GOTOS => {
    1366                         'base_element' => 187,
    1367                         'property_list' => 180
    1368                 }
    1369         },
    1370         {#State 167
    1371                 DEFAULT => -81
    1372         },
    1373         {#State 168
    1374                 ACTIONS => {
    1375                         "," => 188,
    1376                         ")" => 189
    1377                 }
    1378         },
    1379         {#State 169
    1380                 DEFAULT => -83
    13811383        },
    13821384        {#State 170
     
    14011403        {#State 172
    14021404                ACTIONS => {
    1403                         "[" => 155
     1405                        ";" => 192
     1406                }
     1407        },
     1408        {#State 173
     1409                DEFAULT => -70
     1410        },
     1411        {#State 174
     1412                ACTIONS => {
     1413                        "[" => 20
     1414                },
     1415                DEFAULT => -89,
     1416                GOTOS => {
     1417                        'base_or_empty' => 193,
     1418                        'base_element' => 194,
     1419                        'empty_element' => 195,
     1420                        'property_list' => 196
     1421                }
     1422        },
     1423        {#State 175
     1424                DEFAULT => -69
     1425        },
     1426        {#State 176
     1427                DEFAULT => -60
     1428        },
     1429        {#State 177
     1430                ACTIONS => {
     1431                        ";" => 197
     1432                }
     1433        },
     1434        {#State 178
     1435                ACTIONS => {
     1436                        'IDENTIFIER' => 26,
     1437                        "signed" => 100,
     1438                        'void' => 93,
     1439                        "unsigned" => 104,
     1440                        "[" => 20
     1441                },
     1442                DEFAULT => -89,
     1443                GOTOS => {
     1444                        'existingtype' => 99,
     1445                        'pipe' => 56,
     1446                        'bitmap' => 57,
     1447                        'usertype' => 95,
     1448                        'property_list' => 94,
     1449                        'identifier' => 96,
     1450                        'struct' => 62,
     1451                        'enum' => 65,
     1452                        'type' => 198,
     1453                        'union' => 67,
     1454                        'sign' => 97
     1455                }
     1456        },
     1457        {#State 179
     1458                ACTIONS => {
     1459                        'CONSTANT' => 48,
     1460                        'TEXT' => 16,
     1461                        'IDENTIFIER' => 26
     1462                },
     1463                DEFAULT => -97,
     1464                GOTOS => {
     1465                        'identifier' => 50,
     1466                        'anytext' => 199,
     1467                        'text' => 51,
     1468                        'constant' => 47
     1469                }
     1470        },
     1471        {#State 180
     1472                DEFAULT => -43
     1473        },
     1474        {#State 181
     1475                ACTIONS => {
     1476                        'IDENTIFIER' => 26
     1477                },
     1478                GOTOS => {
     1479                        'identifier' => 158,
     1480                        'enum_element' => 200
     1481                }
     1482        },
     1483        {#State 182
     1484                ACTIONS => {
     1485                        'IDENTIFIER' => 26
     1486                },
     1487                GOTOS => {
     1488                        'identifier' => 163,
     1489                        'bitmap_element' => 201
     1490                }
     1491        },
     1492        {#State 183
     1493                ACTIONS => {
     1494                        'CONSTANT' => 48,
     1495                        'TEXT' => 16,
     1496                        'IDENTIFIER' => 26
     1497                },
     1498                DEFAULT => -97,
     1499                GOTOS => {
     1500                        'identifier' => 50,
     1501                        'anytext' => 202,
     1502                        'text' => 51,
     1503                        'constant' => 47
     1504                }
     1505        },
     1506        {#State 184
     1507                DEFAULT => -51
     1508        },
     1509        {#State 185
     1510                DEFAULT => -84
     1511        },
     1512        {#State 186
     1513                ACTIONS => {
     1514                        "const" => 166
     1515                },
     1516                DEFAULT => -80,
     1517                GOTOS => {
     1518                        'optional_const' => 203
     1519                }
     1520        },
     1521        {#State 187
     1522                ACTIONS => {
     1523                        ";" => 204
     1524                }
     1525        },
     1526        {#State 188
     1527                ACTIONS => {
     1528                        "[" => 169
    14041529                },
    14051530                DEFAULT => -86,
    14061531                GOTOS => {
    1407                         'array_len' => 192
    1408                 }
    1409         },
    1410         {#State 173
     1532                        'array_len' => 205
     1533                }
     1534        },
     1535        {#State 189
    14111536                ACTIONS => {
    14121537                        "-" => 69,
     
    14241549                        "*" => 80,
    14251550                        "." => 81,
    1426                         "]" => 193,
     1551                        "]" => 206,
    14271552                        ">" => 82
    14281553                }
    14291554        },
    1430         {#State 174
    1431                 DEFAULT => -29
    1432         },
    1433         {#State 175
    1434                 DEFAULT => -70
    1435         },
    1436         {#State 176
    1437                 ACTIONS => {
    1438                         "[" => 20
    1439                 },
    1440                 DEFAULT => -89,
    1441                 GOTOS => {
    1442                         'base_or_empty' => 194,
    1443                         'base_element' => 195,
    1444                         'empty_element' => 196,
    1445                         'property_list' => 197
    1446                 }
    1447         },
    1448         {#State 177
    1449                 DEFAULT => -69
    1450         },
    1451         {#State 178
    1452                 DEFAULT => -60
    1453         },
    1454         {#State 179
    1455                 ACTIONS => {
    1456                         ";" => 198
    1457                 }
    1458         },
    1459         {#State 180
    1460                 ACTIONS => {
    1461                         'IDENTIFIER' => 26,
    1462                         "signed" => 100,
    1463                         'void' => 93,
    1464                         "unsigned" => 104,
    1465                         "[" => 20
    1466                 },
    1467                 DEFAULT => -89,
    1468                 GOTOS => {
    1469                         'existingtype' => 99,
    1470                         'pipe' => 56,
    1471                         'bitmap' => 57,
    1472                         'usertype' => 95,
    1473                         'property_list' => 94,
    1474                         'identifier' => 96,
    1475                         'struct' => 62,
    1476                         'enum' => 65,
    1477                         'type' => 199,
    1478                         'union' => 67,
    1479                         'sign' => 97
    1480                 }
    1481         },
    1482         {#State 181
     1555        {#State 190
    14831556                ACTIONS => {
    14841557                        'CONSTANT' => 48,
     
    14891562                GOTOS => {
    14901563                        'identifier' => 50,
    1491                         'anytext' => 200,
    1492                         'text' => 51,
    1493                         'constant' => 47
    1494                 }
    1495         },
    1496         {#State 182
    1497                 DEFAULT => -43
    1498         },
    1499         {#State 183
    1500                 ACTIONS => {
    1501                         'IDENTIFIER' => 26
    1502                 },
    1503                 GOTOS => {
    1504                         'identifier' => 159,
    1505                         'enum_element' => 201
    1506                 }
    1507         },
    1508         {#State 184
    1509                 ACTIONS => {
    1510                         'IDENTIFIER' => 26
    1511                 },
    1512                 GOTOS => {
    1513                         'identifier' => 164,
    1514                         'bitmap_element' => 202
    1515                 }
    1516         },
    1517         {#State 185
    1518                 ACTIONS => {
    1519                         'CONSTANT' => 48,
    1520                         'TEXT' => 16,
    1521                         'IDENTIFIER' => 26
    1522                 },
    1523                 DEFAULT => -97,
    1524                 GOTOS => {
    1525                         'identifier' => 50,
    1526                         'anytext' => 203,
    1527                         'text' => 51,
    1528                         'constant' => 47
    1529                 }
    1530         },
    1531         {#State 186
    1532                 DEFAULT => -51
    1533         },
    1534         {#State 187
    1535                 DEFAULT => -84
    1536         },
    1537         {#State 188
    1538                 ACTIONS => {
    1539                         "const" => 167
    1540                 },
    1541                 DEFAULT => -80,
    1542                 GOTOS => {
    1543                         'optional_const' => 204
    1544                 }
    1545         },
    1546         {#State 189
    1547                 ACTIONS => {
    1548                         ";" => 205
    1549                 }
    1550         },
    1551         {#State 190
    1552                 ACTIONS => {
    1553                         'CONSTANT' => 48,
    1554                         'TEXT' => 16,
    1555                         'IDENTIFIER' => 26
    1556                 },
    1557                 DEFAULT => -97,
    1558                 GOTOS => {
    1559                         'identifier' => 50,
    1560                         'anytext' => 206,
     1564                        'anytext' => 207,
    15611565                        'text' => 51,
    15621566                        'constant' => 47
     
    15691573                        "?" => 70,
    15701574                        "<" => 71,
    1571                         ";" => 207,
     1575                        ";" => 208,
    15721576                        "+" => 73,
    15731577                        "~" => 72,
     
    15841588        },
    15851589        {#State 192
    1586                 DEFAULT => -87
     1590                DEFAULT => -29
    15871591        },
    15881592        {#State 193
    1589                 ACTIONS => {
    1590                         "[" => 155
    1591                 },
    1592                 DEFAULT => -86,
    1593                 GOTOS => {
    1594                         'array_len' => 208
    1595                 }
     1593                DEFAULT => -67
    15961594        },
    15971595        {#State 194
    1598                 DEFAULT => -67
     1596                ACTIONS => {
     1597                        ";" => 209
     1598                }
    15991599        },
    16001600        {#State 195
    1601                 ACTIONS => {
    1602                         ";" => 209
    1603                 }
     1601                DEFAULT => -66
    16041602        },
    16051603        {#State 196
    1606                 DEFAULT => -66
    1607         },
    1608         {#State 197
    16091604                ACTIONS => {
    16101605                        'IDENTIFIER' => 26,
     
    16251620                        'struct' => 62,
    16261621                        'enum' => 65,
    1627                         'type' => 199,
     1622                        'type' => 198,
    16281623                        'union' => 67,
    16291624                        'sign' => 97
    16301625                }
    16311626        },
     1627        {#State 197
     1628                DEFAULT => -79
     1629        },
    16321630        {#State 198
    1633                 DEFAULT => -79
     1631                DEFAULT => -75,
     1632                GOTOS => {
     1633                        'pointers' => 211
     1634                }
    16341635        },
    16351636        {#State 199
    1636                 DEFAULT => -75,
    1637                 GOTOS => {
    1638                         'pointers' => 211
    1639                 }
    1640         },
    1641         {#State 200
    16421637                ACTIONS => {
    16431638                        "-" => 69,
     
    16591654                DEFAULT => -50
    16601655        },
     1656        {#State 200
     1657                DEFAULT => -48
     1658        },
    16611659        {#State 201
    1662                 DEFAULT => -48
     1660                DEFAULT => -56
    16631661        },
    16641662        {#State 202
    1665                 DEFAULT => -56
    1666         },
    1667         {#State 203
    16681663                ACTIONS => {
    16691664                        "-" => 69,
     
    16851680                DEFAULT => -59
    16861681        },
     1682        {#State 203
     1683                DEFAULT => -89,
     1684                GOTOS => {
     1685                        'base_element' => 212,
     1686                        'property_list' => 178
     1687                }
     1688        },
    16871689        {#State 204
    1688                 DEFAULT => -89,
    1689                 GOTOS => {
    1690                         'base_element' => 212,
    1691                         'property_list' => 180
    1692                 }
     1690                DEFAULT => -28
    16931691        },
    16941692        {#State 205
    1695                 DEFAULT => -28
     1693                DEFAULT => -87
    16961694        },
    16971695        {#State 206
     1696                ACTIONS => {
     1697                        "[" => 169
     1698                },
     1699                DEFAULT => -86,
     1700                GOTOS => {
     1701                        'array_len' => 213
     1702                }
     1703        },
     1704        {#State 207
    16981705                ACTIONS => {
    16991706                        "-" => 69,
     
    17011708                        "?" => 70,
    17021709                        "<" => 71,
    1703                         ";" => 213,
     1710                        ";" => 214,
    17041711                        "+" => 73,
    17051712                        "~" => 72,
     
    17151722                }
    17161723        },
    1717         {#State 207
     1724        {#State 208
    17181725                DEFAULT => -26
    1719         },
    1720         {#State 208
    1721                 DEFAULT => -88
    17221726        },
    17231727        {#State 209
     
    17331737                },
    17341738                GOTOS => {
    1735                         'identifier' => 214
     1739                        'identifier' => 215
    17361740                }
    17371741        },
     
    17401744        },
    17411745        {#State 213
     1746                DEFAULT => -88
     1747        },
     1748        {#State 214
    17421749                DEFAULT => -27
    17431750        },
    1744         {#State 214
    1745                 ACTIONS => {
    1746                         "[" => 155
     1751        {#State 215
     1752                ACTIONS => {
     1753                        "[" => 169
    17471754                },
    17481755                DEFAULT => -86,
    17491756                GOTOS => {
    1750                         'array_len' => 215
    1751                 }
    1752         },
    1753         {#State 215
     1757                        'array_len' => 216
     1758                }
     1759        },
     1760        {#State 216
    17541761                DEFAULT => -74
    17551762        }
     
    17661773                 'idl', 2,
    17671774sub
    1768 #line 20 "./../pidl/idl.yp"
     1775#line 20 "idl.yp"
    17691776{ push(@{$_[1]}, $_[2]); $_[1] }
    17701777        ],
     
    17721779                 'idl', 2,
    17731780sub
    1774 #line 22 "./../pidl/idl.yp"
     1781#line 22 "idl.yp"
    17751782{ push(@{$_[1]}, $_[2]); $_[1] }
    17761783        ],
     
    17781785                 'idl', 2,
    17791786sub
    1780 #line 24 "./../pidl/idl.yp"
     1787#line 24 "idl.yp"
    17811788{ push(@{$_[1]}, $_[2]); $_[1] }
    17821789        ],
     
    17841791                 'idl', 2,
    17851792sub
    1786 #line 26 "./../pidl/idl.yp"
     1793#line 26 "idl.yp"
    17871794{ push(@{$_[1]}, $_[2]); $_[1] }
    17881795        ],
     
    17901797                 'idl', 2,
    17911798sub
    1792 #line 28 "./../pidl/idl.yp"
     1799#line 28 "idl.yp"
    17931800{ push(@{$_[1]}, $_[2]); $_[1] }
    17941801        ],
     
    17961803                 'idl', 2,
    17971804sub
    1798 #line 30 "./../pidl/idl.yp"
     1805#line 30 "idl.yp"
    17991806{ push(@{$_[1]}, $_[2]); $_[1] }
    18001807        ],
     
    18021809                 'import', 3,
    18031810sub
    1804 #line 35 "./../pidl/idl.yp"
     1811#line 35 "idl.yp"
    18051812{{
    18061813                "TYPE" => "IMPORT",
     
    18131820                 'include', 3,
    18141821sub
    1815 #line 45 "./../pidl/idl.yp"
     1822#line 45 "idl.yp"
    18161823{{
    18171824                "TYPE" => "INCLUDE",
     
    18241831                 'importlib', 3,
    18251832sub
    1826 #line 55 "./../pidl/idl.yp"
     1833#line 55 "idl.yp"
    18271834{{
    18281835                "TYPE" => "IMPORTLIB",
     
    18351842                 'commalist', 1,
    18361843sub
    1837 #line 64 "./../pidl/idl.yp"
     1844#line 64 "idl.yp"
    18381845{ [ $_[1] ] }
    18391846        ],
     
    18411848                 'commalist', 3,
    18421849sub
    1843 #line 66 "./../pidl/idl.yp"
     1850#line 66 "idl.yp"
    18441851{ push(@{$_[1]}, $_[3]); $_[1] }
    18451852        ],
     
    18471854                 'coclass', 7,
    18481855sub
    1849 #line 71 "./../pidl/idl.yp"
     1856#line 71 "idl.yp"
    18501857{{
    18511858                "TYPE" => "COCLASS",
     
    18631870                 'interface_names', 4,
    18641871sub
    1865 #line 84 "./../pidl/idl.yp"
     1872#line 84 "idl.yp"
    18661873{ push(@{$_[1]}, $_[2]); $_[1] }
    18671874        ],
     
    18691876                 'interface', 8,
    18701877sub
    1871 #line 89 "./../pidl/idl.yp"
     1878#line 89 "idl.yp"
    18721879{{
    18731880                "TYPE" => "INTERFACE",
     
    18861893                 'base_interface', 2,
    18871894sub
    1888 #line 103 "./../pidl/idl.yp"
     1895#line 103 "idl.yp"
    18891896{ $_[2] }
    18901897        ],
     
    18921899                 'cpp_quote', 4,
    18931900sub
    1894 #line 109 "./../pidl/idl.yp"
     1901#line 109 "idl.yp"
    18951902{{
    18961903                 "TYPE" => "CPP_QUOTE",
     
    19031910                 'definitions', 1,
    19041911sub
    1905 #line 118 "./../pidl/idl.yp"
     1912#line 118 "idl.yp"
    19061913{ [ $_[1] ] }
    19071914        ],
     
    19091916                 'definitions', 2,
    19101917sub
    1911 #line 120 "./../pidl/idl.yp"
     1918#line 120 "idl.yp"
    19121919{ push(@{$_[1]}, $_[2]); $_[1] }
    19131920        ],
     
    19271934                 'const', 7,
    19281935sub
    1929 #line 135 "./../pidl/idl.yp"
     1936#line 135 "idl.yp"
    19301937{{
    19311938                "TYPE"  => "CONST",
     
    19411948                 'const', 8,
    19421949sub
    1943 #line 146 "./../pidl/idl.yp"
     1950#line 146 "idl.yp"
    19441951{{
    19451952                "TYPE"  => "CONST",
     
    19561963                 'function', 7,
    19571964sub
    1958 #line 160 "./../pidl/idl.yp"
     1965#line 160 "idl.yp"
    19591966{{
    19601967                "TYPE" => "FUNCTION",
     
    19681975        ],
    19691976        [#Rule 29
    1970                  'typedef', 6,
    1971 sub
    1972 #line 173 "./../pidl/idl.yp"
     1977                 'typedef', 7,
     1978sub
     1979#line 173 "idl.yp"
    19731980{{
    19741981                "TYPE" => "TYPEDEF",
    19751982                "PROPERTIES" => $_[1],
    1976                 "NAME" => $_[4],
     1983                "NAME" => $_[5],
    19771984                "DATA" => $_[3],
    1978                 "ARRAY_LEN" => $_[5],
     1985                "POINTERS" => $_[4],
     1986                "ARRAY_LEN" => $_[6],
    19791987                "FILE" => $_[0]->YYData->{FILE},
    19801988                "LINE" => $_[0]->YYData->{LINE},
     
    19992007                 'typedecl', 2,
    20002008sub
    2001 #line 197 "./../pidl/idl.yp"
     2009#line 198 "idl.yp"
    20022010{ $_[1] }
    20032011        ],
     
    20112019                 'existingtype', 2,
    20122020sub
    2013 #line 207 "./../pidl/idl.yp"
     2021#line 208 "idl.yp"
    20142022{ ($_[1]?$_[1]:"signed") ." $_[2]" }
    20152023        ],
     
    20262034                 'type', 1,
    20272035sub
    2028 #line 217 "./../pidl/idl.yp"
     2036#line 218 "idl.yp"
    20292037{ "void" }
    20302038        ],
     
    20322040                 'enum_body', 3,
    20332041sub
    2034 #line 221 "./../pidl/idl.yp"
     2042#line 222 "idl.yp"
    20352043{ $_[2] }
    20362044        ],
     
    20442052                 'enum', 4,
    20452053sub
    2046 #line 232 "./../pidl/idl.yp"
     2054#line 233 "idl.yp"
    20472055{{
    20482056                "TYPE" => "ENUM",
     
    20572065                 'enum_elements', 1,
    20582066sub
    2059 #line 243 "./../pidl/idl.yp"
     2067#line 244 "idl.yp"
    20602068{ [ $_[1] ] }
    20612069        ],
     
    20632071                 'enum_elements', 3,
    20642072sub
    2065 #line 245 "./../pidl/idl.yp"
     2073#line 246 "idl.yp"
    20662074{ push(@{$_[1]}, $_[3]); $_[1] }
    20672075        ],
     
    20722080                 'enum_element', 3,
    20732081sub
    2074 #line 251 "./../pidl/idl.yp"
     2082#line 252 "idl.yp"
    20752083{ "$_[1]$_[2]$_[3]" }
    20762084        ],
     
    20782086                 'bitmap_body', 3,
    20792087sub
    2080 #line 255 "./../pidl/idl.yp"
     2088#line 256 "idl.yp"
    20812089{ $_[2] }
    20822090        ],
     
    20902098                 'bitmap', 4,
    20912099sub
    2092 #line 266 "./../pidl/idl.yp"
     2100#line 267 "idl.yp"
    20932101{{
    20942102                "TYPE" => "BITMAP",
     
    21032111                 'bitmap_elements', 1,
    21042112sub
    2105 #line 277 "./../pidl/idl.yp"
     2113#line 278 "idl.yp"
    21062114{ [ $_[1] ] }
    21072115        ],
     
    21092117                 'bitmap_elements', 3,
    21102118sub
    2111 #line 279 "./../pidl/idl.yp"
     2119#line 280 "idl.yp"
    21122120{ push(@{$_[1]}, $_[3]); $_[1] }
    21132121        ],
     
    21212129                 'bitmap_element', 3,
    21222130sub
    2123 #line 289 "./../pidl/idl.yp"
     2131#line 290 "idl.yp"
    21242132{ "$_[1] ( $_[3] )" }
    21252133        ],
     
    21272135                 'struct_body', 3,
    21282136sub
    2129 #line 293 "./../pidl/idl.yp"
     2137#line 294 "idl.yp"
    21302138{ $_[2] }
    21312139        ],
     
    21392147                 'struct', 4,
    21402148sub
    2141 #line 304 "./../pidl/idl.yp"
     2149#line 305 "idl.yp"
    21422150{{
    21432151                "TYPE" => "STRUCT",
     
    21522160                 'empty_element', 2,
    21532161sub
    2154 #line 316 "./../pidl/idl.yp"
     2162#line 317 "idl.yp"
    21552163{{
    21562164                "NAME" => "",
     
    21722180                 'optional_base_element', 2,
    21732181sub
    2174 #line 333 "./../pidl/idl.yp"
     2182#line 334 "idl.yp"
    21752183{ $_[2]->{PROPERTIES} = FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] }
    21762184        ],
     
    21812189                 'union_elements', 2,
    21822190sub
    2183 #line 339 "./../pidl/idl.yp"
     2191#line 340 "idl.yp"
    21842192{ push(@{$_[1]}, $_[2]); $_[1] }
    21852193        ],
     
    21872195                 'union_body', 3,
    21882196sub
    2189 #line 343 "./../pidl/idl.yp"
     2197#line 344 "idl.yp"
    21902198{ $_[2] }
    21912199        ],
     
    21992207                 'union', 4,
    22002208sub
    2201 #line 354 "./../pidl/idl.yp"
     2209#line 355 "idl.yp"
    22022210{{
    22032211                "TYPE" => "UNION",
     
    22122220                 'base_element', 5,
    22132221sub
    2214 #line 366 "./../pidl/idl.yp"
     2222#line 367 "idl.yp"
    22152223{{
    22162224                "NAME" => $_[4],
     
    22262234                 'pointers', 0,
    22272235sub
    2228 #line 379 "./../pidl/idl.yp"
     2236#line 380 "idl.yp"
    22292237{ 0 }
    22302238        ],
     
    22322240                 'pointers', 2,
    22332241sub
    2234 #line 381 "./../pidl/idl.yp"
     2242#line 382 "idl.yp"
    22352243{ $_[1]+1 }
    22362244        ],
     
    22382246                 'pipe', 3,
    22392247sub
    2240 #line 386 "./../pidl/idl.yp"
     2248#line 387 "idl.yp"
    22412249{{
    22422250                "TYPE" => "PIPE",
    22432251                "PROPERTIES" => $_[1],
    2244                 "NAME" => $_[4],
    2245                 "DATA" => $_[3],
     2252                "NAME" => undef,
     2253                "DATA" => {
     2254                        "TYPE" => "STRUCT",
     2255                        "PROPERTIES" => $_[1],
     2256                        "NAME" => undef,
     2257                        "ELEMENTS" => [{
     2258                                "NAME" => "count",
     2259                                "PROPERTIES" => $_[1],
     2260                                "POINTERS" => 0,
     2261                                "ARRAY_LEN" => [],
     2262                                "TYPE" => "uint3264",
     2263                                "FILE" => $_[0]->YYData->{FILE},
     2264                                "LINE" => $_[0]->YYData->{LINE},
     2265                        },{
     2266                                "NAME" => "array",
     2267                                "PROPERTIES" => $_[1],
     2268                                "POINTERS" => 0,
     2269                                "ARRAY_LEN" => [ "count" ],
     2270                                "TYPE" => $_[3],
     2271                                "FILE" => $_[0]->YYData->{FILE},
     2272                                "LINE" => $_[0]->YYData->{LINE},
     2273                        }],
     2274                        "FILE" => $_[0]->YYData->{FILE},
     2275                        "LINE" => $_[0]->YYData->{LINE},
     2276                },
    22462277                "FILE" => $_[0]->YYData->{FILE},
    22472278                "LINE" => $_[0]->YYData->{LINE},
     
    22512282                 'element_list1', 0,
    22522283sub
    2253 #line 398 "./../pidl/idl.yp"
     2284#line 422 "idl.yp"
    22542285{ [] }
    22552286        ],
     
    22572288                 'element_list1', 3,
    22582289sub
    2259 #line 400 "./../pidl/idl.yp"
     2290#line 424 "idl.yp"
    22602291{ push(@{$_[1]}, $_[2]); $_[1] }
    22612292        ],
     
    22752306                 'element_list2', 2,
    22762307sub
    2277 #line 414 "./../pidl/idl.yp"
     2308#line 438 "idl.yp"
    22782309{ [ $_[2] ] }
    22792310        ],
     
    22812312                 'element_list2', 4,
    22822313sub
    2283 #line 416 "./../pidl/idl.yp"
     2314#line 440 "idl.yp"
    22842315{ push(@{$_[1]}, $_[4]); $_[1] }
    22852316        ],
     
    22902321                 'array_len', 3,
    22912322sub
    2292 #line 422 "./../pidl/idl.yp"
     2323#line 446 "idl.yp"
    22932324{ push(@{$_[3]}, "*"); $_[3] }
    22942325        ],
     
    22962327                 'array_len', 4,
    22972328sub
    2298 #line 424 "./../pidl/idl.yp"
     2329#line 448 "idl.yp"
    22992330{ push(@{$_[4]}, "$_[2]"); $_[4] }
    23002331        ],
     
    23052336                 'property_list', 4,
    23062337sub
    2307 #line 430 "./../pidl/idl.yp"
     2338#line 454 "idl.yp"
    23082339{ FlattenHash([$_[1],$_[3]]); }
    23092340        ],
     
    23112342                 'properties', 1,
    23122343sub
    2313 #line 434 "./../pidl/idl.yp"
     2344#line 458 "idl.yp"
    23142345{ $_[1] }
    23152346        ],
     
    23172348                 'properties', 3,
    23182349sub
    2319 #line 436 "./../pidl/idl.yp"
     2350#line 460 "idl.yp"
    23202351{ FlattenHash([$_[1], $_[3]]); }
    23212352        ],
     
    23232354                 'property', 1,
    23242355sub
    2325 #line 440 "./../pidl/idl.yp"
     2356#line 464 "idl.yp"
    23262357{{ "$_[1]" => "1"     }}
    23272358        ],
     
    23292360                 'property', 4,
    23302361sub
    2331 #line 442 "./../pidl/idl.yp"
     2362#line 466 "idl.yp"
    23322363{{ "$_[1]" => "$_[3]" }}
    23332364        ],
     
    23382369                 'commalisttext', 3,
    23392370sub
    2340 #line 448 "./../pidl/idl.yp"
     2371#line 472 "idl.yp"
    23412372{ "$_[1],$_[3]" }
    23422373        ],
     
    23442375                 'anytext', 0,
    23452376sub
    2346 #line 453 "./../pidl/idl.yp"
     2377#line 477 "idl.yp"
    23472378{ "" }
    23482379        ],
     
    23592390                 'anytext', 3,
    23602391sub
    2361 #line 461 "./../pidl/idl.yp"
     2392#line 485 "idl.yp"
    23622393{ "$_[1]$_[2]$_[3]" }
    23632394        ],
     
    23652396                 'anytext', 3,
    23662397sub
    2367 #line 463 "./../pidl/idl.yp"
     2398#line 487 "idl.yp"
    23682399{ "$_[1]$_[2]$_[3]" }
    23692400        ],
     
    23712402                 'anytext', 3,
    23722403sub
    2373 #line 465 "./../pidl/idl.yp"
     2404#line 489 "idl.yp"
    23742405{ "$_[1]$_[2]$_[3]" }
    23752406        ],
     
    23772408                 'anytext', 3,
    23782409sub
    2379 #line 467 "./../pidl/idl.yp"
     2410#line 491 "idl.yp"
    23802411{ "$_[1]$_[2]$_[3]" }
    23812412        ],
     
    23832414                 'anytext', 3,
    23842415sub
    2385 #line 469 "./../pidl/idl.yp"
     2416#line 493 "idl.yp"
    23862417{ "$_[1]$_[2]$_[3]" }
    23872418        ],
     
    23892420                 'anytext', 3,
    23902421sub
    2391 #line 471 "./../pidl/idl.yp"
     2422#line 495 "idl.yp"
    23922423{ "$_[1]$_[2]$_[3]" }
    23932424        ],
     
    23952426                 'anytext', 3,
    23962427sub
    2397 #line 473 "./../pidl/idl.yp"
     2428#line 497 "idl.yp"
    23982429{ "$_[1]$_[2]$_[3]" }
    23992430        ],
     
    24012432                 'anytext', 3,
    24022433sub
    2403 #line 475 "./../pidl/idl.yp"
     2434#line 499 "idl.yp"
    24042435{ "$_[1]$_[2]$_[3]" }
    24052436        ],
     
    24072438                 'anytext', 3,
    24082439sub
    2409 #line 477 "./../pidl/idl.yp"
     2440#line 501 "idl.yp"
    24102441{ "$_[1]$_[2]$_[3]" }
    24112442        ],
     
    24132444                 'anytext', 3,
    24142445sub
    2415 #line 479 "./../pidl/idl.yp"
     2446#line 503 "idl.yp"
    24162447{ "$_[1]$_[2]$_[3]" }
    24172448        ],
     
    24192450                 'anytext', 3,
    24202451sub
    2421 #line 481 "./../pidl/idl.yp"
     2452#line 505 "idl.yp"
    24222453{ "$_[1]$_[2]$_[3]" }
    24232454        ],
     
    24252456                 'anytext', 3,
    24262457sub
    2427 #line 483 "./../pidl/idl.yp"
     2458#line 507 "idl.yp"
    24282459{ "$_[1]$_[2]$_[3]" }
    24292460        ],
     
    24312462                 'anytext', 3,
    24322463sub
    2433 #line 485 "./../pidl/idl.yp"
     2464#line 509 "idl.yp"
    24342465{ "$_[1]$_[2]$_[3]" }
    24352466        ],
     
    24372468                 'anytext', 5,
    24382469sub
    2439 #line 487 "./../pidl/idl.yp"
     2470#line 511 "idl.yp"
    24402471{ "$_[1]$_[2]$_[3]$_[4]$_[5]" }
    24412472        ],
     
    24432474                 'anytext', 5,
    24442475sub
    2445 #line 489 "./../pidl/idl.yp"
     2476#line 513 "idl.yp"
    24462477{ "$_[1]$_[2]$_[3]$_[4]$_[5]" }
    24472478        ],
     
    24612492                 'text', 1,
    24622493sub
    2463 #line 507 "./../pidl/idl.yp"
     2494#line 531 "idl.yp"
    24642495{ "\"$_[1]\"" }
    24652496        ],
     
    24752506}
    24762507
    2477 #line 519 "./../pidl/idl.yp"
     2508#line 543 "idl.yp"
    24782509
    24792510
     
    26132644        undef $/;
    26142645        my $cpp = $ENV{CPP};
     2646        my $options = "";
    26152647        if (! defined $cpp) {
    2616                 $cpp = "cpp";
     2648                if (defined $ENV{CC}) {
     2649                        $cpp = "$ENV{CC}";
     2650                        $options = "-E";
     2651                } else {
     2652                        $cpp = "cpp";
     2653                }
    26172654        }
    26182655        my $includes = join('',map { " -I$_" } @$incdirs);
    2619         my $data = `$cpp -D__PIDL__$includes -xc $filename`;
     2656        my $data = `$cpp $options -D__PIDL__$includes -xc "$filename"`;
    26202657        $/ = $saved_delim;
    26212658
  • vendor/current/pidl/lib/Parse/Pidl/NDR.pm

    r414 r740  
    3535$VERSION = '0.01';
    3636@ISA = qw(Exporter);
    37 @EXPORT = qw(GetPrevLevel GetNextLevel ContainsDeferred ContainsString);
     37@EXPORT = qw(GetPrevLevel GetNextLevel ContainsDeferred ContainsPipe ContainsString);
    3838@EXPORT_OK = qw(GetElementLevelTable ParseElement ValidElement align_type mapToScalar ParseType can_contain_deferred is_charset_array);
    3939
    4040use strict;
    4141use Parse::Pidl qw(warning fatal);
    42 use Parse::Pidl::Typelist qw(hasType getType expandAlias);
     42use Parse::Pidl::Typelist qw(hasType getType typeIs expandAlias mapScalarType is_fixed_size_scalar);
    4343use Parse::Pidl::Util qw(has_property property_matches);
    4444
     
    5555        'int32' => 4,
    5656        'uint32' => 4,
     57        'int3264' => 5,
     58        'uint3264' => 5,
    5759        'hyper' => 8,
    5860        'double' => 8,
     
    6567        'string_array' => 4, #???
    6668        'time_t' => 4,
     69        'uid_t' => 8,
     70        'gid_t' => 8,
    6771        'NTTIME' => 4,
    6872        'NTTIME_1sec' => 4,
     
    7175        'NTSTATUS' => 4,
    7276        'COMRESULT' => 4,
     77        'dns_string' => 4,
    7378        'nbt_string' => 4,
    7479        'wrepl_nbt_name' => 4,
    75         'ipv4address' => 4
     80        'ipv4address' => 4,
     81        'ipv6address' => 4, #16?
     82        'dnsp_name' => 1,
     83        'dnsp_string' => 1
    7684};
    7785
    78 sub GetElementLevelTable($$)
    79 {
    80         my ($e, $pointer_default) = @_;
     86sub GetElementLevelTable($$$)
     87{
     88        my ($e, $pointer_default, $ms_union) = @_;
    8189
    8290        my $order = [];
     
    102110                my $needptrs = 1;
    103111
    104                 if (has_property($e, "string")) { $needptrs++; }
     112                if (has_property($e, "string") and not has_property($e, "in")) { $needptrs++; }
    105113                if ($#bracket_array >= 0) { $needptrs = 0; }
    106114
    107115                warning($e, "[out] argument `$e->{NAME}' not a pointer") if ($needptrs > $e->{POINTERS});
     116        }
     117
     118        my $allow_pipe = ($e->{PARENT}->{TYPE} eq "FUNCTION");
     119        my $is_pipe = typeIs($e->{TYPE}, "PIPE");
     120
     121        if ($is_pipe) {
     122                if (not $allow_pipe) {
     123                        fatal($e, "argument `$e->{NAME}' is a pipe and not allowed on $e->{PARENT}->{TYPE}");
     124                }
     125
     126                if ($e->{POINTERS} > 1) {
     127                        fatal($e, "$e->{POINTERS} are not allowed on pipe element $e->{NAME}");
     128                }
     129
     130                if ($e->{POINTERS} < 0) {
     131                        fatal($e, "pipe element $e->{NAME} needs pointer");
     132                }
     133
     134                if ($e->{POINTERS} == 1 and pointer_type($e) ne "ref") {
     135                        fatal($e, "pointer should be 'ref' on pipe element $e->{NAME}");
     136                }
     137
     138                if (scalar(@size_is) > 0) {
     139                        fatal($e, "size_is() on pipe element");
     140                }
     141
     142                if (scalar(@length_is) > 0) {
     143                        fatal($e, "length_is() on pipe element");
     144                }
     145
     146                if (scalar(@bracket_array) > 0) {
     147                        fatal($e, "brackets on pipe element");
     148                }
     149
     150                if (defined(has_property($e, "subcontext"))) {
     151                        fatal($e, "subcontext on pipe element");
     152                }
     153
     154                if (has_property($e, "switch_is")) {
     155                        fatal($e, "switch_is on pipe element");
     156                }
     157
     158                if (can_contain_deferred($e->{TYPE})) {
     159                        fatal($e, "$e->{TYPE} can_contain_deferred - not allowed on pipe element");
     160                }
    108161        }
    109162
     
    123176                        $is_conformant = 1;
    124177                        if ($size = shift @size_is) {
     178                                if ($e->{POINTERS} < 1 and has_property($e, "string")) {
     179                                        $is_string = 1;
     180                                        delete($e->{PROPERTIES}->{string});
     181                                }
    125182                        } elsif ((scalar(@size_is) == 0) and has_property($e, "string")) {
    126183                                $is_string = 1;
     
    248305        }
    249306
     307        if ($is_pipe) {
     308                push (@$order, {
     309                        TYPE => "PIPE",
     310                        IS_DEFERRED => 0,
     311                        CONTAINS_DEFERRED => 0,
     312                });
     313
     314                my $i = 0;
     315                foreach (@$order) { $_->{LEVEL_INDEX} = $i; $i+=1; }
     316
     317                return $order;
     318        }
     319
    250320        if (defined(has_property($e, "subcontext"))) {
    251321                my $hdr_size = has_property($e, "subcontext");
     
    298368}
    299369
    300 sub GetTypedefLevelTable($$$)
    301 {
    302         my ($e, $data, $pointer_default) = @_;
     370sub GetTypedefLevelTable($$$$)
     371{
     372        my ($e, $data, $pointer_default, $ms_union) = @_;
    303373
    304374        my $order = [];
     
    350420        return "unique" if (has_property($e, "unique"));
    351421        return "relative" if (has_property($e, "relative"));
     422        return "relative_short" if (has_property($e, "relative_short"));
    352423        return "ignore" if (has_property($e, "ignore"));
    353424
     
    407478        if ($dt->{TYPE} eq "TYPEDEF") {
    408479                return align_type($dt->{DATA});
     480        } elsif ($dt->{TYPE} eq "CONFORMANCE") {
     481                return $dt->{DATA}->{ALIGN};
    409482        } elsif ($dt->{TYPE} eq "ENUM") {
    410483                return align_type(Parse::Pidl::Typelist::enum_type_fn($dt));
     
    415488                return 4 unless (defined($dt->{ELEMENTS}));
    416489                return find_largest_alignment($dt);
     490        } elsif (($dt->{TYPE} eq "PIPE")) {
     491                return 5;
    417492        }
    418493
     
    420495}
    421496
    422 sub ParseElement($$)
    423 {
    424         my ($e, $pointer_default) = @_;
     497sub ParseElement($$$)
     498{
     499        my ($e, $pointer_default, $ms_union) = @_;
    425500
    426501        $e->{TYPE} = expandAlias($e->{TYPE});
    427502
    428503        if (ref($e->{TYPE}) eq "HASH") {
    429                 $e->{TYPE} = ParseType($e->{TYPE}, $pointer_default);
     504                $e->{TYPE} = ParseType($e->{TYPE}, $pointer_default, $ms_union);
    430505        }
    431506
     
    434509                TYPE => $e->{TYPE},
    435510                PROPERTIES => $e->{PROPERTIES},
    436                 LEVELS => GetElementLevelTable($e, $pointer_default),
     511                LEVELS => GetElementLevelTable($e, $pointer_default, $ms_union),
    437512                REPRESENTATION_TYPE => ($e->{PROPERTIES}->{represent_as} or $e->{TYPE}),
    438513                ALIGN => align_type($e->{TYPE}),
     
    441516}
    442517
    443 sub ParseStruct($$)
    444 {
    445         my ($struct, $pointer_default) = @_;
     518sub ParseStruct($$$)
     519{
     520        my ($struct, $pointer_default, $ms_union) = @_;
    446521        my @elements = ();
    447522        my $surrounding = undef;
     
    461536        foreach my $x (@{$struct->{ELEMENTS}})
    462537        {
    463                 my $e = ParseElement($x, $pointer_default);
     538                my $e = ParseElement($x, $pointer_default, $ms_union);
    464539                if ($x != $struct->{ELEMENTS}[-1] and
    465540                        $e->{LEVELS}[0]->{IS_SURROUNDING}) {
     
    498573sub ParseUnion($$)
    499574{
    500         my ($e, $pointer_default) = @_;
     575        my ($e, $pointer_default, $ms_union) = @_;
    501576        my @elements = ();
     577        my $is_ms_union = $ms_union;
     578        $is_ms_union = 1 if has_property($e, "ms_union");
    502579        my $hasdefault = 0;
    503580        my $switch_type = has_property($e, "switch_type");
     
    512589                PROPERTIES => $e->{PROPERTIES},
    513590                HAS_DEFAULT => $hasdefault,
     591                IS_MS_UNION => $is_ms_union,
    514592                ORIGINAL => $e,
    515593                ALIGN => undef
     
    524602                        $t = { TYPE => "EMPTY" };
    525603                } else {
    526                         $t = ParseElement($x, $pointer_default);
     604                        $t = ParseElement($x, $pointer_default, $ms_union);
    527605                }
    528606                if (has_property($x, "default")) {
     
    549627                PROPERTIES => $e->{PROPERTIES},
    550628                HAS_DEFAULT => $hasdefault,
     629                IS_MS_UNION => $is_ms_union,
    551630                ORIGINAL => $e,
    552631                ALIGN => $align
     
    556635sub ParseEnum($$)
    557636{
    558         my ($e, $pointer_default) = @_;
     637        my ($e, $pointer_default, $ms_union) = @_;
    559638
    560639        return {
     
    568647}
    569648
    570 sub ParseBitmap($$)
    571 {
    572         my ($e, $pointer_default) = @_;
     649sub ParseBitmap($$$)
     650{
     651        my ($e, $pointer_default, $ms_union) = @_;
    573652
    574653        return {
     
    582661}
    583662
    584 sub ParseType($$)
    585 {
    586         my ($d, $pointer_default) = @_;
     663sub ParsePipe($$$)
     664{
     665        my ($pipe, $pointer_default, $ms_union) = @_;
     666
     667        my $pname = $pipe->{NAME};
     668        $pname = $pipe->{PARENT}->{NAME} unless defined $pname;
     669
     670        if (not defined($pipe->{PROPERTIES})
     671            and defined($pipe->{PARENT}->{PROPERTIES})) {
     672                $pipe->{PROPERTIES} = $pipe->{PARENT}->{PROPERTIES};
     673        }
     674
     675        if (ref($pipe->{DATA}) eq "HASH") {
     676                if (not defined($pipe->{DATA}->{PROPERTIES})
     677                    and defined($pipe->{PROPERTIES})) {
     678                        $pipe->{DATA}->{PROPERTIES} = $pipe->{PROPERTIES};
     679                }
     680        }
     681
     682        my $struct = ParseStruct($pipe->{DATA}, $pointer_default, $ms_union);
     683        $struct->{ALIGN} = 5;
     684        $struct->{NAME} = "$pname\_chunk";
     685
     686        # 'count' is element [0] and 'array' [1]
     687        my $e = $struct->{ELEMENTS}[1];
     688        # level [0] is of type "ARRAY"
     689        my $l = $e->{LEVELS}[1];
     690
     691        # here we check that pipe elements have a fixed size type
     692        while (defined($l)) {
     693                my $cl = $l;
     694                $l = GetNextLevel($e, $cl);
     695                if ($cl->{TYPE} ne "DATA") {
     696                        fatal($pipe, el_name($pipe) . ": pipe contains non DATA level");
     697                }
     698
     699                # for now we only support scalars
     700                next if is_fixed_size_scalar($cl->{DATA_TYPE});
     701
     702                fatal($pipe, el_name($pipe) . ": pipe contains non fixed size type[$cl->{DATA_TYPE}]");
     703        }
     704
     705        return {
     706                TYPE => "PIPE",
     707                NAME => $pipe->{NAME},
     708                DATA => $struct,
     709                PROPERTIES => $pipe->{PROPERTIES},
     710                ORIGINAL => $pipe,
     711        };
     712}
     713
     714sub ParseType($$$)
     715{
     716        my ($d, $pointer_default, $ms_union) = @_;
    587717
    588718        my $data = {
     
    592722                BITMAP => \&ParseBitmap,
    593723                TYPEDEF => \&ParseTypedef,
    594         }->{$d->{TYPE}}->($d, $pointer_default);
     724                PIPE => \&ParsePipe,
     725        }->{$d->{TYPE}}->($d, $pointer_default, $ms_union);
    595726
    596727        return $data;
     
    599730sub ParseTypedef($$)
    600731{
    601         my ($d, $pointer_default) = @_;
    602 
    603         if (defined($d->{DATA}->{PROPERTIES}) && !defined($d->{PROPERTIES})) {
    604                 $d->{PROPERTIES} = $d->{DATA}->{PROPERTIES};
    605         }
    606 
    607         my $data = ParseType($d->{DATA}, $pointer_default);
    608         $data->{ALIGN} = align_type($d->{NAME});
     732        my ($d, $pointer_default, $ms_union) = @_;
     733
     734        my $data;
     735
     736        if (ref($d->{DATA}) eq "HASH") {
     737                if (defined($d->{DATA}->{PROPERTIES})
     738                    and not defined($d->{PROPERTIES})) {
     739                        $d->{PROPERTIES} = $d->{DATA}->{PROPERTIES};
     740                }
     741
     742                $data = ParseType($d->{DATA}, $pointer_default, $ms_union);
     743                $data->{ALIGN} = align_type($d->{NAME});
     744        } else {
     745                $data = getType($d->{DATA});
     746        }
    609747
    610748        return {
     
    612750                TYPE => $d->{TYPE},
    613751                PROPERTIES => $d->{PROPERTIES},
    614                 LEVELS => GetTypedefLevelTable($d, $data, $pointer_default),
     752                LEVELS => GetTypedefLevelTable($d, $data, $pointer_default, $ms_union),
    615753                DATA => $data,
    616754                ORIGINAL => $d
     
    625763}
    626764
    627 sub ParseFunction($$$)
    628 {
    629         my ($ndr,$d,$opnum) = @_;
     765sub ParseFunction($$$$)
     766{
     767        my ($ndr,$d,$opnum,$ms_union) = @_;
    630768        my @elements = ();
    631769        my $rettype = undef;
     
    640778
    641779        foreach my $x (@{$d->{ELEMENTS}}) {
    642                 my $e = ParseElement($x, $ndr->{PROPERTIES}->{pointer_default});
     780                my $e = ParseElement($x, $ndr->{PROPERTIES}->{pointer_default}, $ms_union);
    643781                push (@{$e->{DIRECTION}}, "in") if (has_property($x, "in"));
    644782                push (@{$e->{DIRECTION}}, "out") if (has_property($x, "out"));
     
    650788                $rettype = expandAlias($d->{RETURN_TYPE});
    651789        }
    652        
    653         my $async = 0;
    654         if (has_property($d, "async")) { $async = 1; }
    655790       
    656791        return {
     
    658793                        TYPE => "FUNCTION",
    659794                        OPNUM => $thisopnum,
    660                         ASYNC => $async,
    661795                        RETURN_TYPE => $rettype,
    662796                        PROPERTIES => $d->{PROPERTIES},
     
    705839        my $opnum = 0;
    706840        my $version;
     841        my $ms_union = 0;
     842        $ms_union = 1 if has_property($idl, "ms_union");
    707843
    708844        if (not has_property($idl, "pointer_default")) {
     
    714850        foreach my $d (@{$idl->{DATA}}) {
    715851                if ($d->{TYPE} eq "FUNCTION") {
    716                         push (@functions, ParseFunction($idl, $d, \$opnum));
     852                        push (@functions, ParseFunction($idl, $d, \$opnum, $ms_union));
    717853                } elsif ($d->{TYPE} eq "CONST") {
    718854                        push (@consts, ParseConst($idl, $d));
    719855                } else {
    720                         push (@types, ParseType($d, $idl->{PROPERTIES}->{pointer_default}));
     856                        push (@types, ParseType($d, $idl->{PROPERTIES}->{pointer_default}, $ms_union));
    721857                        FindNestedTypes(\@types, $d);
    722858                }
     
    830966}
    831967
     968sub ContainsPipe($$)
     969{
     970        my ($e,$l) = @_;
     971
     972        return 1 if ($l->{TYPE} eq "PIPE");
     973
     974        while ($l = GetNextLevel($e,$l))
     975        {
     976                return 1 if ($l->{TYPE} eq "PIPE");
     977        }
     978
     979        return 0;
     980}
     981
    832982sub el_name($)
    833983{
     
    8781028        "pyhelper"              => ["INTERFACE"],
    8791029        "authservice"           => ["INTERFACE"],
    880         "restricted"    => ["INTERFACE"],
     1030        "restricted"            => ["INTERFACE"],
     1031        "no_srv_register"       => ["INTERFACE"],
    8811032
    8821033        # dcom
     
    8911042        "in"                    => ["ELEMENT"],
    8921043        "out"                   => ["ELEMENT"],
    893         "async"                 => ["FUNCTION"],
    8941044
    8951045        # pointer
    896         "ref"                   => ["ELEMENT"],
    897         "ptr"                   => ["ELEMENT"],
    898         "unique"                => ["ELEMENT"],
     1046        "ref"                   => ["ELEMENT", "TYPEDEF"],
     1047        "ptr"                   => ["ELEMENT", "TYPEDEF"],
     1048        "unique"                => ["ELEMENT", "TYPEDEF"],
    8991049        "ignore"                => ["ELEMENT"],
    900         "relative"              => ["ELEMENT"],
    901         "null_is_ffffffff" => ["ELEMENT"],
     1050        "relative"              => ["ELEMENT", "TYPEDEF"],
     1051        "relative_short"        => ["ELEMENT", "TYPEDEF"],
     1052        "null_is_ffffffff"      => ["ELEMENT"],
    9021053        "relative_base"         => ["TYPEDEF", "STRUCT", "UNION"],
    9031054
    9041055        "gensize"               => ["TYPEDEF", "STRUCT", "UNION"],
    9051056        "value"                 => ["ELEMENT"],
    906         "flag"                  => ["ELEMENT", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"],
     1057        "flag"                  => ["ELEMENT", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP", "PIPE"],
    9071058
    9081059        # generic
    909         "public"                => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"],
    910         "nopush"                => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"],
    911         "nopull"                => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"],
     1060        "public"                => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP", "PIPE"],
     1061        "nopush"                => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP", "PIPE"],
     1062        "nopull"                => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP", "PIPE"],
    9121063        "nosize"                => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"],
    913         "noprint"               => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP", "ELEMENT"],
     1064        "noprint"               => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP", "ELEMENT", "PIPE"],
     1065        "nopython"              => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"],
    9141066        "todo"                  => ["FUNCTION"],
    9151067
     
    9181070        "switch_type"           => ["ELEMENT", "UNION"],
    9191071        "nodiscriminant"        => ["UNION"],
     1072        "ms_union"              => ["INTERFACE", "UNION"],
    9201073        "case"                  => ["ELEMENT"],
    9211074        "default"               => ["ELEMENT"],
     
    10071160                        $discriminator_type = "uint32" unless defined ($discriminator_type);
    10081161
    1009                         my $t1 = mapToScalar($discriminator_type);
     1162                        my $t1 = mapScalarType(mapToScalar($discriminator_type));
    10101163
    10111164                        if (not defined($t1)) {
     
    10131166                        }
    10141167
    1015                         my $t2 = mapToScalar($e2->{TYPE});
     1168                        my $t2 = mapScalarType(mapToScalar($e2->{TYPE}));
    10161169                        if (not defined($t2)) {
    10171170                                fatal($e, el_name($e) . ": unable to map variable used for switch_is() to scalar");
     
    10561209                has_property($e, "unique") or
    10571210                has_property($e, "relative") or
     1211                has_property($e, "relative_short") or
    10581212                has_property($e, "ref"))) {
    10591213                fatal($e, el_name($e) . " : pointer properties on non-pointer element\n");     
     
    11371291{
    11381292        my ($pipe) = @_;
    1139         my $data = $pipe->{DATA};
     1293        my $struct = $pipe->{DATA};
    11401294
    11411295        ValidProperties($pipe, "PIPE");
    11421296
    1143         fatal($pipe, $pipe->{NAME} . ": 'pipe' is not yet supported by pidl");
     1297        $struct->{PARENT} = $pipe;
     1298
     1299        $struct->{FILE} = $pipe->{FILE} unless defined($struct->{FILE});
     1300        $struct->{LINE} = $pipe->{LINE} unless defined($struct->{LINE});
     1301
     1302        ValidType($struct);
    11441303}
    11451304
     
    11531312        ValidProperties($typedef, "TYPEDEF");
    11541313
     1314        return unless (ref($data) eq "HASH");
     1315
    11551316        $data->{PARENT} = $typedef;
    11561317
     
    11581319        $data->{LINE} = $typedef->{LINE} unless defined($data->{LINE});
    11591320
    1160         ValidType($data) if (ref($data) eq "HASH");
     1321        ValidType($data);
    11611322}
    11621323
  • vendor/current/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm

    r587 r740  
    1010use Exporter;
    1111@ISA = qw(Exporter);
    12 @EXPORT_OK = qw(ParseFunction $res $res_hdr ParseOutputArgument);
     12@EXPORT_OK = qw(ParseFunction $res $res_hdr);
    1313
    1414use strict;
    1515use Parse::Pidl qw(fatal warning error);
    1616use Parse::Pidl::Util qw(has_property ParseExpr);
     17use Parse::Pidl::NDR qw(ContainsPipe);
     18use Parse::Pidl::Typelist qw(mapTypeName);
    1719use Parse::Pidl::Samba4 qw(DeclLong);
    1820use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv GenerateFunctionOutEnv);
     
    8688}
    8789
    88 sub ParseOutputArgument($$$;$$$)
    89 {
    90         my ($self, $fn, $e, $r, $o, $invalid_response_type) = @_;
    91         my $level = 0;
    92         $r = "r." unless defined($r);
    93         $o = "" unless defined($o);
    94         $invalid_response_type = "sync" unless defined($invalid_response_type);
    95 
    96         if ($e->{LEVELS}[0]->{TYPE} ne "POINTER" and $e->{LEVELS}[0]->{TYPE} ne "ARRAY") {
    97                 $self->pidl("return NT_STATUS_NOT_SUPPORTED;");
    98                 error($e->{ORIGINAL}, "[out] argument is not a pointer or array");
    99                 return;
    100         }
    101 
    102         if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
    103                 $level = 1;
    104                 if ($e->{LEVELS}[0]->{POINTER_TYPE} ne "ref") {
    105                         $self->pidl("if ($o$e->{NAME} && ${r}out.$e->{NAME}) {");
    106                         $self->indent;
    107                 }
    108         }
    109 
    110         if ($e->{LEVELS}[$level]->{TYPE} eq "ARRAY") {
    111                 # This is a call to GenerateFunctionInEnv intentionally.
    112                 # Since the data is being copied into a user-provided data
    113                 # structure, the user should be able to know the size beforehand
    114                 # to allocate a structure of the right size.
    115                 my $in_env = GenerateFunctionInEnv($fn, $r);
    116                 my $out_env = GenerateFunctionOutEnv($fn, $r);
    117                 my $l = $e->{LEVELS}[$level];
    118                 unless (defined($l->{SIZE_IS})) {
    119                         $self->pidl('#error No size known for [out] array `$e->{NAME}');
    120                         error($e->{ORIGINAL}, "no size known for [out] array `$e->{NAME}'");
    121                 } else {
    122                         my $in_size_is = ParseExpr($l->{SIZE_IS}, $in_env, $e->{ORIGINAL});
    123                         my $out_size_is = ParseExpr($l->{SIZE_IS}, $out_env, $e->{ORIGINAL});
    124                         my $out_length_is = $out_size_is;
    125                         if (defined($l->{LENGTH_IS})) {
    126                                 $out_length_is = ParseExpr($l->{LENGTH_IS}, $out_env, $e->{ORIGINAL});
    127                         }
    128                         if ($out_size_is ne $in_size_is) {
    129                                 $self->pidl("if (($out_size_is) > ($in_size_is)) {");
    130                                 $self->indent;
    131                                 $self->ParseInvalidResponse($invalid_response_type);
    132                                 $self->deindent;
    133                                 $self->pidl("}");
    134                         }
    135                         if ($out_length_is ne $out_size_is) {
    136                                 $self->pidl("if (($out_length_is) > ($out_size_is)) {");
    137                                 $self->indent;
    138                                 $self->ParseInvalidResponse($invalid_response_type);
    139                                 $self->deindent;
    140                                 $self->pidl("}");
    141                         }
    142                         if (has_property($e, "charset")) {
    143                                 $self->pidl("memcpy(discard_const_p(uint8_t *, $o$e->{NAME}), ${r}out.$e->{NAME}, ($out_length_is) * sizeof(*$o$e->{NAME}));");
    144                         } else {
    145                                 $self->pidl("memcpy($o$e->{NAME}, ${r}out.$e->{NAME}, ($out_length_is) * sizeof(*$o$e->{NAME}));");
    146                         }
    147                 }
    148         } else {
    149                 $self->pidl("*$o$e->{NAME} = *${r}out.$e->{NAME};");
    150         }
    151 
    152         if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
    153                 if ($e->{LEVELS}[0]->{POINTER_TYPE} ne "ref") {
    154                         $self->deindent;
    155                         $self->pidl("}");
    156                 }
    157         }
    158 }
    159 
    16090sub ParseFunctionAsyncState($$$)
    16191{
     
    16797        $self->pidl("$state_str {");
    16898        $self->indent;
    169         $self->pidl("struct $fn->{NAME} orig;");
    170         $self->pidl("struct $fn->{NAME} tmp;");
    17199        $self->pidl("TALLOC_CTX *out_mem_ctx;");
    172         $self->pidl("NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);");
     100        if (defined($fn->{RETURN_TYPE})) {
     101                $self->pidl(mapTypeName($fn->{RETURN_TYPE}). " result;");
     102        }
    173103        $self->deindent;
    174104        $self->pidl("};");
     
    216146        $self->pidl("}");
    217147        $self->pidl("state->out_mem_ctx = NULL;");
    218         $self->pidl("state->dispatch_recv = cli->dispatch_recv;");
    219         $self->pidl("");
    220 
    221         $self->pidl("/* In parameters */");
    222         foreach (@{$fn->{ELEMENTS}}) {
    223                 if (grep(/in/, @{$_->{DIRECTION}})) {
    224                         $self->pidl("state->orig.in.$_->{NAME} = _$_->{NAME};");
    225                 }
    226         }
    227148        $self->pidl("");
    228149
    229150        my $out_params = 0;
    230         $self->pidl("/* Out parameters */");
    231151        foreach (@{$fn->{ELEMENTS}}) {
    232152                if (grep(/out/, @{$_->{DIRECTION}})) {
    233                         $self->pidl("state->orig.out.$_->{NAME} = _$_->{NAME};");
    234153                        $out_params++;
    235154                }
    236         }
    237         $self->pidl("");
    238 
    239         if (defined($fn->{RETURN_TYPE})) {
    240                 $self->pidl("/* Result */");
    241                 $self->pidl("ZERO_STRUCT(state->orig.out.result);");
    242                 $self->pidl("");
    243155        }
    244156
     
    254166        }
    255167
    256         $self->pidl("/* make a temporary copy, that we pass to the dispatch function */");
    257         $self->pidl("state->tmp = state->orig;");
    258         $self->pidl("");
    259 
    260         $self->pidl("subreq = cli->dispatch_send(state, ev, cli,");
    261         $self->pidl("\t\t\t    &ndr_table_$if,");
    262         $self->pidl("\t\t\t    $ufn,");
    263         $self->pidl("\t\t\t    &state->tmp);");
     168        $fn_str = "subreq = dcerpc_$fn->{NAME}_send";
     169        $pad = "\t" . genpad($fn_str);
     170        $fn_args = "state,\n" . $pad . "ev,\n" . $pad . "cli->binding_handle";
     171        foreach (@{$fn->{ELEMENTS}}) {
     172                $fn_args .= ",\n" . $pad . "_". $_->{NAME};
     173        }
     174
     175        $self->pidl("$fn_str($fn_args);");
    264176        $self->pidl("if (tevent_req_nomem(subreq, req)) {");
    265177        $self->indent;
     
    303215        $self->pidl("");
    304216
    305         $self->pidl("status = state->dispatch_recv(subreq, mem_ctx);");
     217        my $fn_str = "status = dcerpc_$fn->{NAME}_recv";
     218        my $pad = "\t" . genpad($fn_str);
     219        my $fn_args = "subreq,\n" . $pad . "mem_ctx";
     220        if (defined($fn->{RETURN_TYPE})) {
     221                $fn_args .= ",\n" . $pad . "&state->result";
     222        }
     223
     224        $self->pidl("$fn_str($fn_args);");
    306225        $self->pidl("TALLOC_FREE(subreq);");
    307226        $self->pidl("if (!NT_STATUS_IS_OK(status)) {");
     
    311230        $self->deindent;
    312231        $self->pidl("}");
    313         $self->pidl("");
    314 
    315         $self->pidl("/* Copy out parameters */");
    316         foreach my $e (@{$fn->{ELEMENTS}}) {
    317                 next unless (grep(/out/, @{$e->{DIRECTION}}));
    318 
    319                 $self->ParseOutputArgument($fn, $e,
    320                                            "state->tmp.",
    321                                            "state->orig.out.",
    322                                            "async");
    323         }
    324         $self->pidl("");
    325 
    326         if (defined($fn->{RETURN_TYPE})) {
    327                 $self->pidl("/* Copy result */");
    328                 $self->pidl("state->orig.out.result = state->tmp.out.result;");
    329                 $self->pidl("");
    330         }
    331 
    332         $self->pidl("/* Reset temporary structure */");
    333         $self->pidl("ZERO_STRUCT(state->tmp);");
    334232        $self->pidl("");
    335233
     
    370268        $self->pidl("");
    371269
    372         $self->pidl("/* Steal possbile out parameters to the callers context */");
     270        $self->pidl("/* Steal possible out parameters to the callers context */");
    373271        $self->pidl("talloc_steal(mem_ctx, state->out_mem_ctx);");
    374272        $self->pidl("");
     
    376274        if (defined($fn->{RETURN_TYPE})) {
    377275                $self->pidl("/* Return result */");
    378                 $self->pidl("*result = state->orig.out.result;");
     276                $self->pidl("*result = state->result;");
    379277                $self->pidl("");
    380278        }
     
    402300                my $dir = ElementDirection($_);
    403301                my $prop = HeaderProperties($_->{PROPERTIES}, ["in", "out"]);
    404                 $fn_args .= ",\n" . $pad . DeclLong($_) . " /* $dir $prop */";
     302                $fn_args .= ",\n" . $pad . DeclLong($_, "_") . " /* $dir $prop */";
    405303        }
    406304
     
    412310        $self->pidl("{");
    413311        $self->indent;
    414         $self->pidl("struct $fn->{NAME} r;");
     312        if (defined($fn->{RETURN_TYPE})) {
     313                $self->pidl(mapTypeName($fn->{RETURN_TYPE})." result;");
     314        }
    415315        $self->pidl("NTSTATUS status;");
    416316        $self->pidl("");
    417         $self->pidl("/* In parameters */");
    418 
     317
     318        $fn_str = "status = dcerpc_$fn->{NAME}";
     319        $pad = "\t" . genpad($fn_str);
     320        $fn_args = "cli->binding_handle,\n" . $pad . "mem_ctx";
    419321        foreach (@{$fn->{ELEMENTS}}) {
    420                 if (grep(/in/, @{$_->{DIRECTION}})) {
    421                         $self->pidl("r.in.$_->{NAME} = $_->{NAME};");
    422                 }
    423         }
    424 
    425         $self->pidl("");
    426         $self->pidl("status = cli->dispatch(cli,");
    427         $self->pidl("\t\t\tmem_ctx,");
    428         $self->pidl("\t\t\t&ndr_table_$if,");
    429         $self->pidl("\t\t\t$ufn,");
    430         $self->pidl("\t\t\t&r);");
    431         $self->pidl("");
    432 
     322                $fn_args .= ",\n" . $pad . "_". $_->{NAME};
     323        }
     324        if (defined($fn->{RETURN_TYPE})) {
     325                $fn_args .= ",\n" . $pad . "&result";
     326        }
     327
     328        $self->pidl("$fn_str($fn_args);");
    433329        $self->pidl("if (!NT_STATUS_IS_OK(status)) {");
    434330        $self->indent;
     
    436332        $self->deindent;
    437333        $self->pidl("}");
    438 
    439         $self->pidl("");
    440         $self->pidl("if (NT_STATUS_IS_ERR(status)) {");
    441         $self->indent;
    442         $self->pidl("return status;");
    443         $self->deindent;
    444         $self->pidl("}");
    445         $self->pidl("");
    446         $self->pidl("/* Return variables */");
    447         foreach my $e (@{$fn->{ELEMENTS}}) {
    448                 next unless (grep(/out/, @{$e->{DIRECTION}}));
    449 
    450                 $self->ParseOutputArgument($fn, $e);
    451 
    452         }
    453 
    454         $self->pidl("");
     334        $self->pidl("");
     335
    455336        $self->pidl("/* Return result */");
    456337        if (not $fn->{RETURN_TYPE}) {
    457338                $self->pidl("return NT_STATUS_OK;");
    458339        } elsif ($fn->{RETURN_TYPE} eq "NTSTATUS") {
    459                 $self->pidl("return r.out.result;");
     340                $self->pidl("return result;");
    460341        } elsif ($fn->{RETURN_TYPE} eq "WERROR") {
    461342                $self->pidl("if (werror) {");
    462343                $self->indent;
    463                 $self->pidl("*werror = r.out.result;");
     344                $self->pidl("*werror = result;");
    464345                $self->deindent;
    465346                $self->pidl("}");
    466347                $self->pidl("");
    467                 $self->pidl("return werror_to_ntstatus(r.out.result);");
     348                $self->pidl("return werror_to_ntstatus(result);");
    468349        } else {
    469350                warning($fn->{ORIGINAL}, "Unable to convert $fn->{RETURN_TYPE} to NTSTATUS");
     
    496377        $self->pidl_hdr("#ifndef __CLI_$uif\__");
    497378        $self->pidl_hdr("#define __CLI_$uif\__");
    498         foreach (@{$if->{FUNCTIONS}}) {
    499                 next if ($_->{PROPERTIES}{noopnum});
    500                 $self->ParseFunction($if->{NAME}, $_);
     379        foreach my $fn (@{$if->{FUNCTIONS}}) {
     380                next if has_property($fn, "noopnum");
     381                next if has_property($fn, "todo");
     382
     383                my $skip = 0;
     384                foreach my $e (@{$fn->{ELEMENTS}}) {
     385                        if (ContainsPipe($e, $e->{LEVELS}[0])) {
     386                                $skip = 1;
     387                                last;
     388                        }
     389                }
     390                next if $skip;
     391
     392                $self->ParseFunction($if->{NAME}, $fn);
    501393        }
    502394        $self->pidl_hdr("#endif /* __CLI_$uif\__ */");
     
    505397sub Parse($$$$)
    506398{
    507         my($self,$ndr,$header,$ndr_header) = @_;
     399        my($self,$ndr,$header,$c_header) = @_;
    508400
    509401        $self->pidl("/*");
     
    514406        $self->pidl("#include \"includes.h\"");
    515407        $self->pidl("#include \"$header\"");
    516         $self->pidl_hdr("#include \"$ndr_header\"");
     408        $self->pidl_hdr("#include \"$c_header\"");
    517409        $self->pidl("");
    518410       
  • vendor/current/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm

    r414 r740  
    101101        pidl "ZERO_STRUCT(r->out);" if ($hasout);
    102102
    103         my $proto = "_$fn->{NAME}(pipes_struct *p, struct $fn->{NAME} *r";
     103        my $proto = "_$fn->{NAME}(struct pipes_struct *p, struct $fn->{NAME} *r";
    104104        my $ret = "_$fn->{NAME}($pipes_struct, r";
    105105        foreach (@{$fn->{ELEMENTS}}) {
     
    139139        my $op = "NDR_".uc($fn->{NAME});
    140140
    141         pidl "static bool api_$fn->{NAME}(pipes_struct *p)";
     141        pidl "static bool api_$fn->{NAME}(struct pipes_struct *p)";
    142142        pidl "{";
    143143        indent;
     
    146146        pidl "struct ndr_push *push;";
    147147        pidl "enum ndr_err_code ndr_err;";
    148         pidl "DATA_BLOB blob;";
    149148        pidl "struct $fn->{NAME} *r;";
    150149        pidl "";
     
    156155        pidl "}";
    157156        pidl "";
    158         pidl "if (!prs_data_blob(&p->in_data.data, &blob, r)) {";
    159         pidl "\ttalloc_free(r);";
    160         pidl "\treturn false;";
    161         pidl "}";
    162         pidl "";
    163         pidl "pull = ndr_pull_init_blob(&blob, r, NULL);";
     157        pidl "pull = ndr_pull_init_blob(&p->in_data.data, r);";
    164158        pidl "if (pull == NULL) {";
    165159        pidl "\ttalloc_free(r);";
     
    168162        pidl "";
    169163        pidl "pull->flags |= LIBNDR_FLAG_REF_ALLOC;";
     164        pidl "if (p->endian) {";
     165        pidl "\tpull->flags |= LIBNDR_FLAG_BIGENDIAN;";
     166        pidl "}";
    170167        pidl "ndr_err = call->ndr_pull(pull, NDR_IN, r);";
    171168        pidl "if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {";
     
    175172        pidl "";
    176173        pidl "if (DEBUGLEVEL >= 10) {";
    177         pidl "\tNDR_PRINT_IN_DEBUG($fn->{NAME}, r);";
     174        pidl "\tNDR_PRINT_FUNCTION_DEBUG($fn->{NAME}, NDR_IN, r);";
    178175        pidl "}";
    179176        pidl "";
     
    194191        pidl "";
    195192        pidl "if (DEBUGLEVEL >= 10) {";
    196         pidl "\tNDR_PRINT_OUT_DEBUG($fn->{NAME}, r);";
    197         pidl "}";
    198         pidl "";
    199         pidl "push = ndr_push_init_ctx(r, NULL);";
     193        pidl "\tNDR_PRINT_FUNCTION_DEBUG($fn->{NAME}, NDR_OUT | NDR_SET_VALUES, r);";
     194        pidl "}";
     195        pidl "";
     196        pidl "push = ndr_push_init_ctx(r);";
    200197        pidl "if (push == NULL) {";
    201198        pidl "\ttalloc_free(r);";
    202199        pidl "\treturn false;";
    203200        pidl "}";
     201        pidl "";
     202        pidl "/*";
     203        pidl " * carry over the pointer count to the reply in case we are";
     204        pidl " * using full pointer. See NDR specification for full pointers";
     205        pidl " */";
     206        pidl "push->ptr_count = pull->ptr_count;";
    204207        pidl "";
    205208        pidl "ndr_err = call->ndr_push(push, NDR_OUT, r);";
     
    209212        pidl "}";
    210213        pidl "";
    211         pidl "blob = ndr_push_blob(push);";
    212         pidl "if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {";
    213         pidl "\ttalloc_free(r);";
    214         pidl "\treturn false;";
    215         pidl "}";
     214        pidl "p->out_data.rdata = ndr_push_blob(push);";
     215        pidl "talloc_steal(p->mem_ctx, p->out_data.rdata.data);";
    216216        pidl "";
    217217        pidl "talloc_free(r);";
     
    220220        deindent;
    221221        pidl "}";
    222         pidl "";
    223 }
    224 
    225 sub ParseDispatchFunction($)
    226 {
    227         my ($if) = @_;
    228 
    229         pidl_hdr "NTSTATUS rpc_$if->{NAME}_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const struct ndr_interface_table *table, uint32_t opnum, void *r);";
    230         pidl "NTSTATUS rpc_$if->{NAME}_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const struct ndr_interface_table *table, uint32_t opnum, void *_r)";
    231         pidl "{";
    232         indent;
    233         pidl "if (cli->pipes_struct == NULL) {";
    234         pidl "\treturn NT_STATUS_INVALID_PARAMETER;";
    235         pidl "}";
    236         pidl "";
    237         pidl "switch (opnum)";
    238         pidl "{";
    239         indent;
    240         foreach my $fn (@{$if->{FUNCTIONS}}) {
    241                 next if ($fn->{PROPERTIES}{noopnum});
    242                 my $op = "NDR_".uc($fn->{NAME});
    243                 pidl "case $op: {";
    244                 indent;
    245                 pidl "struct $fn->{NAME} *r = (struct $fn->{NAME} *)_r;";
    246                 CallWithStruct("cli->pipes_struct", "mem_ctx", $fn,
    247                         sub { pidl "return NT_STATUS_NO_MEMORY;"; });
    248                 pidl "return NT_STATUS_OK;";
    249                 deindent;
    250                 pidl "}";
    251                 pidl "";
    252         }
    253 
    254         pidl "default:";
    255         pidl "\treturn NT_STATUS_NOT_IMPLEMENTED;";
    256         deindent;
    257         pidl "}";
    258         deindent;
    259         pidl "}";
    260 
    261222        pidl "";
    262223}
     
    302263        pidl "";
    303264
    304         ParseDispatchFunction($if);
    305 
    306         pidl_hdr "NTSTATUS rpc_$if->{NAME}_init(void);";
    307         pidl "NTSTATUS rpc_$if->{NAME}_init(void)";
    308         pidl "{";
    309         pidl "\treturn rpc_srv_register(SMB_RPC_INTERFACE_VERSION, \"$if->{NAME}\", \"$if->{NAME}\", \&ndr_table_$if->{NAME}, api_$if->{NAME}_cmds, sizeof(api_$if->{NAME}_cmds) / sizeof(struct api_struct));";
    310         pidl "}";
    311 
     265        if (not has_property($if, "no_srv_register")) {
     266            pidl_hdr "struct rpc_srv_callbacks;";
     267            pidl_hdr "NTSTATUS rpc_$if->{NAME}_init(const struct rpc_srv_callbacks *rpc_srv_cb);";
     268            pidl "NTSTATUS rpc_$if->{NAME}_init(const struct rpc_srv_callbacks *rpc_srv_cb)";
     269            pidl "{";
     270            pidl "\treturn rpc_srv_register(SMB_RPC_INTERFACE_VERSION, \"$if->{NAME}\", \"$if->{NAME}\", \&ndr_table_$if->{NAME}, api_$if->{NAME}_cmds, sizeof(api_$if->{NAME}_cmds) / sizeof(struct api_struct), rpc_srv_cb);";
     271            pidl "}";
     272
     273            pidl "";
     274
     275            pidl_hdr "NTSTATUS rpc_$if->{NAME}_shutdown(void);";
     276            pidl "NTSTATUS rpc_$if->{NAME}_shutdown(void)";
     277            pidl "{";
     278            pidl "\treturn rpc_srv_unregister(\&ndr_table_$if->{NAME});";
     279            pidl "}";
     280        }
    312281        pidl_hdr "#endif /* __SRV_$uif\__ */";
    313282}
     
    326295        pidl "";
    327296        pidl "#include \"includes.h\"";
     297        pidl "#include \"ntdomain.h\"";
    328298        pidl "#include \"$header\"";
    329299        pidl_hdr "#include \"$ndr_header\"";
  • vendor/current/pidl/lib/Parse/Pidl/Samba4.pm

    r414 r740  
    1919$VERSION = '0.01';
    2020
     21
     22# return true if we are using pidl within the samba source tree. This changes
     23# the names of include files, as some include files (such as ntstatus.h) have
     24# different paths when installed to the patch in the source tree
    2125sub is_intree()
    2226{
    2327        my $srcdir = $ENV{srcdir};
    2428        $srcdir = $srcdir ? "$srcdir/" : "";
    25         return 4 if (-f "${srcdir}kdc/kdc.c");
    26         return 3 if (-f "${srcdir}include/smb.h");
     29        return 1 if (-f "${srcdir}kdc/kdc.c");
     30        return 1 if (-d "${srcdir}source4");
     31        return 1 if (-f "${srcdir}include/smb.h");
    2732        return 0;
    2833}
  • vendor/current/pidl/lib/Parse/Pidl/Samba4/COM/Stub.pm

    r414 r740  
    9090
    9191        pidl "
    92 static NTSTATUS $name\__op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface)
     92static NTSTATUS $name\__op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface, uint32_t if_version)
    9393{
    9494#ifdef DCESRV_INTERFACE_$uname\_BIND
  • vendor/current/pidl/lib/Parse/Pidl/Samba4/Header.pm

    r414 r740  
    66
    77package Parse::Pidl::Samba4::Header;
    8 
    98require Exporter;
    109
     
    218217
    219218#####################################################################
     219# parse a pipe
     220sub HeaderPipe($$;$)
     221{
     222        my($pipe,$name,$tail) = @_;
     223
     224        my $struct = $pipe->{DATA};
     225        my $e = $struct->{ELEMENTS}[1];
     226
     227        pidl "struct $name;\n";
     228        pidl "struct $struct->{NAME} {\n";
     229        $tab_depth++;
     230        pidl tabs()."uint32_t count;\n";
     231        pidl tabs().mapTypeName($e->{TYPE})." *array;\n";
     232        $tab_depth--;
     233        pidl "}";
     234
     235        if (defined $struct->{PROPERTIES}) {
     236                HeaderProperties($struct->{PROPERTIES}, []);
     237        }
     238
     239        pidl $tail if defined($tail);
     240}
     241
     242#####################################################################
    220243# parse a type
    221244sub HeaderType($$$;$)
     
    227250                ($data->{TYPE} eq "STRUCT") && HeaderStruct($data, $name, $tail);
    228251                ($data->{TYPE} eq "UNION") && HeaderUnion($data, $name, $tail);
     252                ($data->{TYPE} eq "PIPE") && HeaderPipe($data, $name, $tail);
    229253                return;
    230254        }
     
    387411                HeaderEnum($t, $t->{NAME}, ";\n\n") if ($t->{TYPE} eq "ENUM");
    388412                HeaderBitmap($t, $t->{NAME}) if ($t->{TYPE} eq "BITMAP");
     413                HeaderPipe($t, $t->{NAME}, "\n\n") if ($t->{TYPE} eq "PIPE");
    389414        }
    390415
     
    413438        %headerstructs = ();
    414439        pidl "/* header auto-generated by pidl */\n\n";
     440
     441        my $ifacename = "";
     442
     443        # work out a unique interface name
     444        foreach (@{$ndr}) {
     445                if ($_->{TYPE} eq "INTERFACE") {
     446                        $ifacename = $_->{NAME};
     447                        last;
     448                }
     449        }
     450
     451        pidl "#ifndef _PIDL_HEADER_$ifacename\n";
     452        pidl "#define _PIDL_HEADER_$ifacename\n\n";
     453
    415454        if (!is_intree()) {
    416455                pidl "#include <util/data_blob.h>\n";
     
    429468        }
    430469
     470        pidl "#endif /* _PIDL_HEADER_$ifacename */\n";
     471
    431472        return $res;
    432473}
  • vendor/current/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm

    r414 r740  
    77package Parse::Pidl::Samba4::NDR::Client;
    88
    9 use Parse::Pidl::Samba4 qw(choose_header is_intree);
    10 use Parse::Pidl::Util qw(has_property);
     9use Exporter;
     10@ISA = qw(Exporter);
     11@EXPORT_OK = qw(Parse);
     12
     13use Parse::Pidl qw(fatal warning error);
     14use Parse::Pidl::Util qw(has_property ParseExpr);
     15use Parse::Pidl::NDR qw(ContainsPipe);
     16use Parse::Pidl::Typelist qw(mapTypeName);
     17use Parse::Pidl::Samba4 qw(choose_header is_intree DeclLong);
     18use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv GenerateFunctionOutEnv);
    1119
    1220use vars qw($VERSION);
     
    1523use strict;
    1624
    17 my($res,$res_hdr);
    18 
    19 sub ParseFunctionSend($$$)
    20 {
    21         my ($interface, $fn, $name) = @_;
     25sub indent($) { my ($self) = @_; $self->{tabs}.="\t"; }
     26sub deindent($) { my ($self) = @_; $self->{tabs} = substr($self->{tabs}, 1); }
     27sub pidl($$) { my ($self,$txt) = @_; $self->{res} .= $txt ? "$self->{tabs}$txt\n" : "\n"; }
     28sub pidl_hdr($$) { my ($self, $txt) = @_; $self->{res_hdr} .= "$txt\n"; }
     29sub pidl_both($$) { my ($self, $txt) = @_; $self->{hdr} .= "$txt\n"; $self->{res_hdr} .= "$txt\n"; }
     30sub fn_declare($$) { my ($self,$n) = @_; $self->pidl($n); $self->pidl_hdr("$n;"); }
     31
     32sub genpad($)
     33{
     34        my ($s) = @_;
     35        my $nt = int((length($s)+1)/8);
     36        my $lt = ($nt*8)-1;
     37        my $ns = (length($s)-$lt);
     38        return "\t"x($nt)." "x($ns);
     39}
     40
     41sub new($)
     42{
     43        my ($class) = shift;
     44        my $self = { res => "", res_hdr => "", tabs => "" };
     45        bless($self, $class);
     46}
     47
     48sub ParseFunctionHasPipes($$)
     49{
     50        my ($self, $fn) = @_;
     51
     52        foreach my $e (@{$fn->{ELEMENTS}}) {
     53                return 1 if ContainsPipe($e, $e->{LEVELS}[0]);
     54        }
     55
     56        return 0;
     57}
     58
     59sub ParseFunction_r_State($$$$)
     60{
     61        my ($self, $if, $fn, $name) = @_;
    2262        my $uname = uc $name;
    2363
    24         my $proto = "struct rpc_request *dcerpc_$name\_send(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r)";
    25 
    26         $res_hdr .= "\n$proto;\n";
    27 
    28         $res .= "$proto\n{\n";
    29 
    30         if (has_property($fn, "todo")) {
    31                 $res .= "\treturn NULL;\n";
     64        $self->pidl("struct dcerpc_$name\_r_state {");
     65        $self->indent;
     66        $self->pidl("TALLOC_CTX *out_mem_ctx;");
     67        $self->deindent;
     68        $self->pidl("};");
     69        $self->pidl("");
     70        $self->pidl("static void dcerpc_$name\_r_done(struct tevent_req *subreq);");
     71        $self->pidl("");
     72}
     73
     74sub ParseFunction_r_Send($$$$)
     75{
     76        my ($self, $if, $fn, $name) = @_;
     77        my $uname = uc $name;
     78
     79        my $proto = "struct tevent_req *dcerpc_$name\_r_send(TALLOC_CTX *mem_ctx,\n";
     80        $proto   .= "\tstruct tevent_context *ev,\n",
     81        $proto   .= "\tstruct dcerpc_binding_handle *h,\n",
     82        $proto   .= "\tstruct $name *r)";
     83
     84        $self->fn_declare($proto);
     85
     86        $self->pidl("{");
     87        $self->indent;
     88
     89        $self->pidl("struct tevent_req *req;");
     90        $self->pidl("struct dcerpc_$name\_r_state *state;");
     91        $self->pidl("struct tevent_req *subreq;");
     92        $self->pidl("");
     93
     94        $self->pidl("req = tevent_req_create(mem_ctx, &state,");
     95        $self->pidl("\t\t\tstruct dcerpc_$name\_r_state);");
     96        $self->pidl("if (req == NULL) {");
     97        $self->indent;
     98        $self->pidl("return NULL;");
     99        $self->deindent;
     100        $self->pidl("}");
     101        $self->pidl("");
     102
     103        my $out_params = 0;
     104        foreach my $e (@{$fn->{ELEMENTS}}) {
     105                next unless grep(/out/, @{$e->{DIRECTION}});
     106                next if ContainsPipe($e, $e->{LEVELS}[0]);
     107                $out_params++;
     108
     109        }
     110
     111        my $submem;
     112        if ($out_params > 0) {
     113                $self->pidl("state->out_mem_ctx = talloc_new(state);");
     114                $self->pidl("if (tevent_req_nomem(state->out_mem_ctx, req)) {");
     115                $self->indent;
     116                $self->pidl("return tevent_req_post(req, ev);");
     117                $self->deindent;
     118                $self->pidl("}");
     119                $submem = "state->out_mem_ctx";
    32120        } else {
    33                 $res .= "
    34         if (p->conn->flags & DCERPC_DEBUG_PRINT_IN) {
    35                 NDR_PRINT_IN_DEBUG($name, r);
    36         }
    37 
    38         return dcerpc_ndr_request_send(p, NULL, &ndr_table_$interface->{NAME},
    39                                        NDR_$uname, true, mem_ctx, r);
    40 ";
    41         }
    42 
    43         $res .= "}\n\n";
    44 }
    45 
    46 sub ParseFunctionSync($$$)
    47 {
    48         my ($interface, $fn, $name) = @_;
     121                $self->pidl("state->out_mem_ctx = NULL;");
     122                $submem = "state";
     123        }
     124        $self->pidl("");
     125
     126        $self->pidl("subreq = dcerpc_binding_handle_call_send(state, ev, h,");
     127        $self->pidl("\t\tNULL, &ndr_table_$if->{NAME},");
     128        $self->pidl("\t\tNDR_$uname, $submem, r);");
     129        $self->pidl("if (tevent_req_nomem(subreq, req)) {");
     130        $self->indent;
     131        $self->pidl("return tevent_req_post(req, ev);");
     132        $self->deindent;
     133        $self->pidl("}");
     134        $self->pidl("tevent_req_set_callback(subreq, dcerpc_$name\_r_done, req);");
     135        $self->pidl("");
     136
     137        $self->pidl("return req;");
     138        $self->deindent;
     139        $self->pidl("}");
     140        $self->pidl("");
     141}
     142
     143sub ParseFunction_r_Done($$$$)
     144{
     145        my ($self, $if, $fn, $name) = @_;
    49146        my $uname = uc $name;
    50147
    51         my $proto = "NTSTATUS dcerpc_$name(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r)";
    52 
    53         $res_hdr .= "\n$proto;\n";
    54         $res .= "$proto\n{\n";
    55 
    56         if (has_property($fn, "todo")) {
    57                 $res .= "\treturn NT_STATUS_NOT_IMPLEMENTED;\n";
     148        my $proto = "static void dcerpc_$name\_r_done(struct tevent_req *subreq)";
     149
     150        $self->pidl("$proto");
     151        $self->pidl("{");
     152        $self->indent;
     153
     154        $self->pidl("struct tevent_req *req =");
     155        $self->pidl("\ttevent_req_callback_data(subreq,");
     156        $self->pidl("\tstruct tevent_req);");
     157        $self->pidl("NTSTATUS status;");
     158        $self->pidl("");
     159
     160        $self->pidl("status = dcerpc_binding_handle_call_recv(subreq);");
     161        $self->pidl("if (!NT_STATUS_IS_OK(status)) {");
     162        $self->indent;
     163        $self->pidl("tevent_req_nterror(req, status);");
     164        $self->pidl("return;");
     165        $self->deindent;
     166        $self->pidl("}");
     167        $self->pidl("");
     168
     169        $self->pidl("tevent_req_done(req);");
     170        $self->deindent;
     171        $self->pidl("}");
     172        $self->pidl("");
     173}
     174
     175sub ParseFunction_r_Recv($$$$)
     176{
     177        my ($self, $if, $fn, $name) = @_;
     178        my $uname = uc $name;
     179
     180        my $proto = "NTSTATUS dcerpc_$name\_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)";
     181
     182        $self->fn_declare($proto);
     183
     184        $self->pidl("{");
     185        $self->indent;
     186
     187        $self->pidl("struct dcerpc_$name\_r_state *state =");
     188        $self->pidl("\ttevent_req_data(req,");
     189        $self->pidl("\tstruct dcerpc_$name\_r_state);");
     190        $self->pidl("NTSTATUS status;");
     191        $self->pidl("");
     192
     193        $self->pidl("if (tevent_req_is_nterror(req, &status)) {");
     194        $self->indent;
     195        $self->pidl("tevent_req_received(req);");
     196        $self->pidl("return status;");
     197        $self->deindent;
     198        $self->pidl("}");
     199        $self->pidl("");
     200
     201        $self->pidl("talloc_steal(mem_ctx, state->out_mem_ctx);");
     202        $self->pidl("");
     203
     204        $self->pidl("tevent_req_received(req);");
     205        $self->pidl("return NT_STATUS_OK;");
     206        $self->deindent;
     207        $self->pidl("}");
     208        $self->pidl("");
     209}
     210
     211sub ParseFunction_r_Sync($$$$)
     212{
     213        my ($self, $if, $fn, $name) = @_;
     214        my $uname = uc $name;
     215
     216        if ($self->ParseFunctionHasPipes($fn)) {
     217                $self->pidl_both("/*");
     218                $self->pidl_both(" * The following function is skipped because");
     219                $self->pidl_both(" * it uses pipes:");
     220                $self->pidl_both(" *");
     221                $self->pidl_both(" * dcerpc_$name\_r()");
     222                $self->pidl_both(" */");
     223                $self->pidl_both("");
     224                return;
     225        }
     226
     227        my $proto = "NTSTATUS dcerpc_$name\_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct $name *r)";
     228
     229        $self->fn_declare($proto);
     230
     231        $self->pidl("{");
     232        $self->indent;
     233        $self->pidl("NTSTATUS status;");
     234        $self->pidl("");
     235
     236        $self->pidl("status = dcerpc_binding_handle_call(h,");
     237        $self->pidl("\t\tNULL, &ndr_table_$if->{NAME},");
     238        $self->pidl("\t\tNDR_$uname, mem_ctx, r);");
     239        $self->pidl("");
     240        $self->pidl("return status;");
     241
     242        $self->deindent;
     243        $self->pidl("}");
     244        $self->pidl("");
     245}
     246
     247sub ElementDirection($)
     248{
     249        my ($e) = @_;
     250
     251        return "[in,out]" if (has_property($e, "in") and has_property($e, "out"));
     252        return "[in]" if (has_property($e, "in"));
     253        return "[out]" if (has_property($e, "out"));
     254        return "[in,out]";
     255}
     256
     257sub HeaderProperties($$)
     258{
     259        my($props,$ignores) = @_;
     260        my $ret = "";
     261
     262        foreach my $d (keys %{$props}) {
     263                next if (grep(/^$d$/, @$ignores));
     264                if($props->{$d} ne "1") {
     265                        $ret.= "$d($props->{$d}),";
     266                } else {
     267                        $ret.="$d,";
     268                }
     269        }
     270
     271        if ($ret) {
     272                return "[" . substr($ret, 0, -1) . "]";
     273        }
     274}
     275
     276sub ParseCopyArgument($$$$$)
     277{
     278        my ($self, $fn, $e, $r, $i) = @_;
     279        my $l = $e->{LEVELS}[0];
     280
     281        if ($l->{TYPE} eq "ARRAY" and $l->{IS_FIXED} == 1) {
     282                $self->pidl("memcpy(${r}$e->{NAME}, ${i}$e->{NAME}, sizeof(${r}$e->{NAME}));");
    58283        } else {
    59                 $res .= "
    60         NTSTATUS status;
    61 
    62         if (p->conn->flags & DCERPC_DEBUG_PRINT_IN) {
    63                 NDR_PRINT_IN_DEBUG($name, r);
    64         }
    65 
    66         status = dcerpc_ndr_request(p, NULL, &ndr_table_$interface->{NAME},
    67                                     NDR_$uname, mem_ctx, r);
    68 
    69         if (NT_STATUS_IS_OK(status) && (p->conn->flags & DCERPC_DEBUG_PRINT_OUT)) {
    70                 NDR_PRINT_OUT_DEBUG($name, r);         
    71         }
    72 ";
    73    
    74         if (defined($fn->{RETURN_TYPE}) and $fn->{RETURN_TYPE} eq "NTSTATUS") {
    75              $res .= "\tif (NT_STATUS_IS_OK(status)) status = r->out.result;\n";
    76         }
    77         $res .=
    78 "
    79         return status;
    80 ";
    81         }
    82 
    83         $res .= "}\n\n";
     284                $self->pidl("${r}$e->{NAME} = ${i}$e->{NAME};");
     285        }
     286}
     287
     288sub ParseInvalidResponse($$)
     289{
     290        my ($self, $type) = @_;
     291
     292        if ($type eq "sync") {
     293                $self->pidl("return NT_STATUS_INVALID_NETWORK_RESPONSE;");
     294        } elsif ($type eq "async") {
     295                $self->pidl("tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE);");
     296                $self->pidl("return;");
     297        } else {
     298                die("ParseInvalidResponse($type)");
     299        }
     300}
     301
     302sub ParseOutputArgument($$$$$$)
     303{
     304        my ($self, $fn, $e, $r, $o, $invalid_response_type) = @_;
     305        my $level = 0;
     306
     307        if ($e->{LEVELS}[0]->{TYPE} ne "POINTER" and $e->{LEVELS}[0]->{TYPE} ne "ARRAY") {
     308                fatal($e->{ORIGINAL}, "[out] argument is not a pointer or array");
     309                return;
     310        }
     311
     312        if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
     313                $level = 1;
     314                if ($e->{LEVELS}[0]->{POINTER_TYPE} ne "ref") {
     315                        $self->pidl("if ($o$e->{NAME} && ${r}out.$e->{NAME}) {");
     316                        $self->indent;
     317                }
     318        }
     319
     320        if ($e->{LEVELS}[$level]->{TYPE} eq "ARRAY") {
     321                # This is a call to GenerateFunctionInEnv intentionally.
     322                # Since the data is being copied into a user-provided data
     323                # structure, the user should be able to know the size beforehand
     324                # to allocate a structure of the right size.
     325                my $in_env = GenerateFunctionInEnv($fn, $r);
     326                my $out_env = GenerateFunctionOutEnv($fn, $r);
     327                my $l = $e->{LEVELS}[$level];
     328
     329                my $in_var = undef;
     330                if (grep(/in/, @{$e->{DIRECTION}})) {
     331                        $in_var = ParseExpr($e->{NAME}, $in_env, $e->{ORIGINAL});
     332                }
     333                my $out_var = ParseExpr($e->{NAME}, $out_env, $e->{ORIGINAL});
     334
     335                my $in_size_is = undef;
     336                my $out_size_is = undef;
     337                my $out_length_is = undef;
     338
     339                my $avail_len = undef;
     340                my $needed_len = undef;
     341
     342                $self->pidl("{");
     343                $self->indent;
     344                my $copy_len_var = "_copy_len_$e->{NAME}";
     345                $self->pidl("size_t $copy_len_var;");
     346
     347                if (not defined($l->{SIZE_IS})) {
     348                        if (not $l->{IS_ZERO_TERMINATED}) {
     349                                fatal($e->{ORIGINAL}, "no size known for [out] array `$e->{NAME}'");
     350                        }
     351                        if (has_property($e, "charset")) {
     352                                $avail_len = "ndr_charset_length($in_var, CH_UNIX)";
     353                                $needed_len = "ndr_charset_length($out_var, CH_UNIX)";
     354                        } else {
     355                                $avail_len = "ndr_string_length($in_var, sizeof(*$in_var))";
     356                                $needed_len = "ndr_string_length($out_var, sizeof(*$out_var))";
     357                        }
     358                        $in_size_is = "";
     359                        $out_size_is = "";
     360                        $out_length_is = "";
     361                } else {
     362                        $in_size_is = ParseExpr($l->{SIZE_IS}, $in_env, $e->{ORIGINAL});
     363                        $out_size_is = ParseExpr($l->{SIZE_IS}, $out_env, $e->{ORIGINAL});
     364                        $out_length_is = $out_size_is;
     365                        if (defined($l->{LENGTH_IS})) {
     366                                $out_length_is = ParseExpr($l->{LENGTH_IS}, $out_env, $e->{ORIGINAL});
     367                        }
     368                        if (has_property($e, "charset")) {
     369                                if (defined($in_var)) {
     370                                        $avail_len = "ndr_charset_length($in_var, CH_UNIX)";
     371                                } else {
     372                                        $avail_len = $out_length_is;
     373                                }
     374                                $needed_len = "ndr_charset_length($out_var, CH_UNIX)";
     375                        }
     376                }
     377
     378                if ($out_size_is ne $in_size_is) {
     379                        $self->pidl("if (($out_size_is) > ($in_size_is)) {");
     380                        $self->indent;
     381                        $self->ParseInvalidResponse($invalid_response_type);
     382                        $self->deindent;
     383                        $self->pidl("}");
     384                }
     385                if ($out_length_is ne $out_size_is) {
     386                        $self->pidl("if (($out_length_is) > ($out_size_is)) {");
     387                        $self->indent;
     388                        $self->ParseInvalidResponse($invalid_response_type);
     389                        $self->deindent;
     390                        $self->pidl("}");
     391                }
     392                if (defined($needed_len)) {
     393                        $self->pidl("$copy_len_var = $needed_len;");
     394                        $self->pidl("if ($copy_len_var > $avail_len) {");
     395                        $self->indent;
     396                        $self->ParseInvalidResponse($invalid_response_type);
     397                        $self->deindent;
     398                        $self->pidl("}");
     399                } else {
     400                        $self->pidl("$copy_len_var = $out_length_is;");
     401                }
     402
     403                if (has_property($e, "charset")) {
     404                        $self->pidl("memcpy(discard_const_p(uint8_t *, $o$e->{NAME}), $out_var, $copy_len_var * sizeof(*$o$e->{NAME}));");
     405                } else {
     406                        $self->pidl("memcpy($o$e->{NAME}, $out_var, $copy_len_var * sizeof(*$o$e->{NAME}));");
     407                }
     408
     409                $self->deindent;
     410                $self->pidl("}");
     411        } else {
     412                $self->pidl("*$o$e->{NAME} = *${r}out.$e->{NAME};");
     413        }
     414
     415        if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
     416                if ($e->{LEVELS}[0]->{POINTER_TYPE} ne "ref") {
     417                        $self->deindent;
     418                        $self->pidl("}");
     419                }
     420        }
     421}
     422
     423sub ParseFunction_State($$$$)
     424{
     425        my ($self, $if, $fn, $name) = @_;
     426
     427        my $state_str = "struct dcerpc_$name\_state";
     428        my $done_fn = "dcerpc_$name\_done";
     429
     430        $self->pidl("$state_str {");
     431        $self->indent;
     432        $self->pidl("struct $name orig;");
     433        $self->pidl("struct $name tmp;");
     434        $self->pidl("TALLOC_CTX *out_mem_ctx;");
     435        $self->deindent;
     436        $self->pidl("};");
     437        $self->pidl("");
     438        $self->pidl("static void $done_fn(struct tevent_req *subreq);");
     439        $self->pidl("");
     440}
     441
     442sub ParseFunction_Send($$$$)
     443{
     444        my ($self, $if, $fn, $name) = @_;
     445
     446        my $fn_args = "";
     447        my $state_str = "struct dcerpc_$name\_state";
     448        my $done_fn = "dcerpc_$name\_done";
     449        my $out_mem_ctx = "dcerpc_$name\_out_memory";
     450        my $fn_str = "struct tevent_req *dcerpc_$name\_send";
     451        my $pad = genpad($fn_str);
     452
     453        $fn_args .= "TALLOC_CTX *mem_ctx";
     454        $fn_args .= ",\n" . $pad . "struct tevent_context *ev";
     455        $fn_args .= ",\n" . $pad . "struct dcerpc_binding_handle *h";
     456
     457        foreach (@{$fn->{ELEMENTS}}) {
     458                my $dir = ElementDirection($_);
     459                my $prop = HeaderProperties($_->{PROPERTIES}, ["in", "out"]);
     460                $fn_args .= ",\n" . $pad . DeclLong($_, "_") . " /* $dir $prop */";
     461        }
     462
     463        $self->fn_declare("$fn_str($fn_args)");
     464        $self->pidl("{");
     465        $self->indent;
     466        $self->pidl("struct tevent_req *req;");
     467        $self->pidl("$state_str *state;");
     468        $self->pidl("struct tevent_req *subreq;");
     469        $self->pidl("");
     470        $self->pidl("req = tevent_req_create(mem_ctx, &state,");
     471        $self->pidl("\t\t\t$state_str);");
     472        $self->pidl("if (req == NULL) {");
     473        $self->indent;
     474        $self->pidl("return NULL;");
     475        $self->deindent;
     476        $self->pidl("}");
     477        $self->pidl("state->out_mem_ctx = NULL;");
     478        $self->pidl("");
     479
     480        $self->pidl("/* In parameters */");
     481        foreach my $e (@{$fn->{ELEMENTS}}) {
     482                next unless (grep(/in/, @{$e->{DIRECTION}}));
     483
     484                $self->ParseCopyArgument($fn, $e, "state->orig.in.", "_");
     485        }
     486        $self->pidl("");
     487
     488        my $out_params = 0;
     489        $self->pidl("/* Out parameters */");
     490        foreach my $e (@{$fn->{ELEMENTS}}) {
     491                next unless grep(/out/, @{$e->{DIRECTION}});
     492
     493                $self->ParseCopyArgument($fn, $e, "state->orig.out.", "_");
     494
     495                next if ContainsPipe($e, $e->{LEVELS}[0]);
     496
     497                $out_params++;
     498        }
     499        $self->pidl("");
     500
     501        if (defined($fn->{RETURN_TYPE})) {
     502                $self->pidl("/* Result */");
     503                $self->pidl("ZERO_STRUCT(state->orig.out.result);");
     504                $self->pidl("");
     505        }
     506
     507        if ($out_params > 0) {
     508                $self->pidl("state->out_mem_ctx = talloc_named_const(state, 0,");
     509                $self->pidl("\t\t     \"$out_mem_ctx\");");
     510                $self->pidl("if (tevent_req_nomem(state->out_mem_ctx, req)) {");
     511                $self->indent;
     512                $self->pidl("return tevent_req_post(req, ev);");
     513                $self->deindent;
     514                $self->pidl("}");
     515                $self->pidl("");
     516        }
     517
     518        $self->pidl("/* make a temporary copy, that we pass to the dispatch function */");
     519        $self->pidl("state->tmp = state->orig;");
     520        $self->pidl("");
     521
     522        $self->pidl("subreq = dcerpc_$name\_r_send(state, ev, h, &state->tmp);");
     523        $self->pidl("if (tevent_req_nomem(subreq, req)) {");
     524        $self->indent;
     525        $self->pidl("return tevent_req_post(req, ev);");
     526        $self->deindent;
     527        $self->pidl("}");
     528        $self->pidl("tevent_req_set_callback(subreq, $done_fn, req);");
     529        $self->pidl("return req;");
     530        $self->deindent;
     531        $self->pidl("}");
     532        $self->pidl("");
     533}
     534
     535sub ParseFunction_Done($$$$)
     536{
     537        my ($self, $if, $fn, $name) = @_;
     538
     539        my $state_str = "struct dcerpc_$name\_state";
     540        my $done_fn = "dcerpc_$name\_done";
     541
     542        $self->pidl("static void $done_fn(struct tevent_req *subreq)");
     543        $self->pidl("{");
     544        $self->indent;
     545        $self->pidl("struct tevent_req *req = tevent_req_callback_data(");
     546        $self->pidl("\tsubreq, struct tevent_req);");
     547        $self->pidl("$state_str *state = tevent_req_data(");
     548        $self->pidl("\treq, $state_str);");
     549        $self->pidl("NTSTATUS status;");
     550        $self->pidl("TALLOC_CTX *mem_ctx;");
     551        $self->pidl("");
     552
     553        $self->pidl("if (state->out_mem_ctx) {");
     554        $self->indent;
     555        $self->pidl("mem_ctx = state->out_mem_ctx;");
     556        $self->deindent;
     557        $self->pidl("} else {");
     558        $self->indent;
     559        $self->pidl("mem_ctx = state;");
     560        $self->deindent;
     561        $self->pidl("}");
     562        $self->pidl("");
     563
     564        $self->pidl("status = dcerpc_$name\_r_recv(subreq, mem_ctx);");
     565        $self->pidl("TALLOC_FREE(subreq);");
     566        $self->pidl("if (!NT_STATUS_IS_OK(status)) {");
     567        $self->indent;
     568        $self->pidl("tevent_req_nterror(req, status);");
     569        $self->pidl("return;");
     570        $self->deindent;
     571        $self->pidl("}");
     572        $self->pidl("");
     573
     574        $self->pidl("/* Copy out parameters */");
     575        foreach my $e (@{$fn->{ELEMENTS}}) {
     576                next if ContainsPipe($e, $e->{LEVELS}[0]);
     577                next unless (grep(/out/, @{$e->{DIRECTION}}));
     578
     579                $self->ParseOutputArgument($fn, $e,
     580                                           "state->tmp.",
     581                                           "state->orig.out.",
     582                                           "async");
     583        }
     584        $self->pidl("");
     585
     586        if (defined($fn->{RETURN_TYPE})) {
     587                $self->pidl("/* Copy result */");
     588                $self->pidl("state->orig.out.result = state->tmp.out.result;");
     589                $self->pidl("");
     590        }
     591
     592        $self->pidl("/* Reset temporary structure */");
     593        $self->pidl("ZERO_STRUCT(state->tmp);");
     594        $self->pidl("");
     595
     596        $self->pidl("tevent_req_done(req);");
     597        $self->deindent;
     598        $self->pidl("}");
     599        $self->pidl("");
     600}
     601
     602sub ParseFunction_Recv($$$$)
     603{
     604        my ($self, $if, $fn, $name) = @_;
     605
     606        my $fn_args = "";
     607        my $state_str = "struct dcerpc_$name\_state";
     608        my $fn_str = "NTSTATUS dcerpc_$name\_recv";
     609        my $pad = genpad($fn_str);
     610
     611        $fn_args .= "struct tevent_req *req,\n" . $pad . "TALLOC_CTX *mem_ctx";
     612
     613        if (defined($fn->{RETURN_TYPE})) {
     614                $fn_args .= ",\n" . $pad . mapTypeName($fn->{RETURN_TYPE}). " *result";
     615        }
     616
     617        $self->fn_declare("$fn_str($fn_args)");
     618        $self->pidl("{");
     619        $self->indent;
     620        $self->pidl("$state_str *state = tevent_req_data(");
     621        $self->pidl("\treq, $state_str);");
     622        $self->pidl("NTSTATUS status;");
     623        $self->pidl("");
     624        $self->pidl("if (tevent_req_is_nterror(req, &status)) {");
     625        $self->indent;
     626        $self->pidl("tevent_req_received(req);");
     627        $self->pidl("return status;");
     628        $self->deindent;
     629        $self->pidl("}");
     630        $self->pidl("");
     631
     632        $self->pidl("/* Steal possible out parameters to the callers context */");
     633        $self->pidl("talloc_steal(mem_ctx, state->out_mem_ctx);");
     634        $self->pidl("");
     635
     636        if (defined($fn->{RETURN_TYPE})) {
     637                $self->pidl("/* Return result */");
     638                $self->pidl("*result = state->orig.out.result;");
     639                $self->pidl("");
     640        }
     641
     642        $self->pidl("tevent_req_received(req);");
     643        $self->pidl("return NT_STATUS_OK;");
     644        $self->deindent;
     645        $self->pidl("}");
     646        $self->pidl("");
     647}
     648
     649sub ParseFunction_Sync($$$$)
     650{
     651        my ($self, $if, $fn, $name) = @_;
     652
     653        if ($self->ParseFunctionHasPipes($fn)) {
     654                $self->pidl_both("/*");
     655                $self->pidl_both(" * The following function is skipped because");
     656                $self->pidl_both(" * it uses pipes:");
     657                $self->pidl_both(" *");
     658                $self->pidl_both(" * dcerpc_$name()");
     659                $self->pidl_both(" */");
     660                $self->pidl_both("");
     661                return;
     662        }
     663
     664        my $uname = uc $name;
     665        my $fn_args = "";
     666        my $fn_str = "NTSTATUS dcerpc_$name";
     667        my $pad = genpad($fn_str);
     668
     669        $fn_args .= "struct dcerpc_binding_handle *h,\n" . $pad . "TALLOC_CTX *mem_ctx";
     670
     671        foreach (@{$fn->{ELEMENTS}}) {
     672                my $dir = ElementDirection($_);
     673                my $prop = HeaderProperties($_->{PROPERTIES}, ["in", "out"]);
     674                $fn_args .= ",\n" . $pad . DeclLong($_, "_") . " /* $dir $prop */";
     675        }
     676
     677        if (defined($fn->{RETURN_TYPE})) {
     678                $fn_args .= ",\n" . $pad . mapTypeName($fn->{RETURN_TYPE}). " *result";
     679        }
     680
     681        $self->fn_declare("$fn_str($fn_args)");
     682        $self->pidl("{");
     683        $self->indent;
     684        $self->pidl("struct $name r;");
     685        $self->pidl("NTSTATUS status;");
     686        $self->pidl("");
     687
     688        $self->pidl("/* In parameters */");
     689        foreach my $e (@{$fn->{ELEMENTS}}) {
     690                next unless (grep(/in/, @{$e->{DIRECTION}}));
     691
     692                $self->ParseCopyArgument($fn, $e, "r.in.", "_");
     693        }
     694        $self->pidl("");
     695
     696        $self->pidl("status = dcerpc_$name\_r(h, mem_ctx, &r);");
     697        $self->pidl("if (!NT_STATUS_IS_OK(status)) {");
     698        $self->indent;
     699        $self->pidl("return status;");
     700        $self->deindent;
     701        $self->pidl("}");
     702        $self->pidl("");
     703
     704        $self->pidl("/* Return variables */");
     705        foreach my $e (@{$fn->{ELEMENTS}}) {
     706                next if ContainsPipe($e, $e->{LEVELS}[0]);
     707                next unless (grep(/out/, @{$e->{DIRECTION}}));
     708
     709                $self->ParseOutputArgument($fn, $e, "r.", "_", "sync");
     710        }
     711        $self->pidl("");
     712
     713        $self->pidl("/* Return result */");
     714        if ($fn->{RETURN_TYPE}) {
     715                $self->pidl("*result = r.out.result;");
     716        }
     717        $self->pidl("");
     718
     719        $self->pidl("return NT_STATUS_OK;");
     720
     721        $self->deindent;
     722        $self->pidl("}");
     723        $self->pidl("");
    84724}
    85725
    86726#####################################################################
    87727# parse a function
    88 sub ParseFunction($$)
    89 {
    90         my ($interface, $fn) = @_;
    91 
    92         ParseFunctionSend($interface, $fn, $fn->{NAME});
    93         ParseFunctionSync($interface, $fn, $fn->{NAME});
     728sub ParseFunction($$$)
     729{
     730        my ($self, $if, $fn) = @_;
     731
     732        if ($self->ParseFunctionHasPipes($fn)) {
     733                $self->pidl_both("/*");
     734                $self->pidl_both(" * The following function is skipped because");
     735                $self->pidl_both(" * it uses pipes:");
     736                $self->pidl_both(" *");
     737                $self->pidl_both(" * dcerpc_$fn->{NAME}_r_send()");
     738                $self->pidl_both(" * dcerpc_$fn->{NAME}_r_recv()");
     739                $self->pidl_both(" * dcerpc_$fn->{NAME}_r()");
     740                $self->pidl_both(" *");
     741                $self->pidl_both(" * dcerpc_$fn->{NAME}_send()");
     742                $self->pidl_both(" * dcerpc_$fn->{NAME}_recv()");
     743                $self->pidl_both(" * dcerpc_$fn->{NAME}()");
     744                $self->pidl_both(" */");
     745                $self->pidl_both("");
     746                warning($fn->{ORIGINAL}, "$fn->{NAME}: dcerpc client does not support pipe yet");
     747                return;
     748        }
     749
     750        $self->ParseFunction_r_State($if, $fn, $fn->{NAME});
     751        $self->ParseFunction_r_Send($if, $fn, $fn->{NAME});
     752        $self->ParseFunction_r_Done($if, $fn, $fn->{NAME});
     753        $self->ParseFunction_r_Recv($if, $fn, $fn->{NAME});
     754        $self->ParseFunction_r_Sync($if, $fn, $fn->{NAME});
     755
     756        foreach my $e (@{$fn->{ELEMENTS}}) {
     757                next unless (grep(/out/, @{$e->{DIRECTION}}));
     758
     759                my $reason = "is not a pointer or array";
     760
     761                # TODO: make this fatal at NDR level
     762                if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
     763                        if ($e->{LEVELS}[1]->{TYPE} eq "DATA" and
     764                            $e->{LEVELS}[1]->{DATA_TYPE} eq "string") {
     765                                $reason = "is a pointer to type 'string'";
     766                        } elsif ($e->{LEVELS}[1]->{TYPE} eq "ARRAY" and
     767                                 $e->{LEVELS}[1]->{IS_ZERO_TERMINATED}) {
     768                                next;
     769                        } elsif ($e->{LEVELS}[1]->{TYPE} eq "ARRAY" and
     770                                 not defined($e->{LEVELS}[1]->{SIZE_IS})) {
     771                                $reason = "is a pointer to an unsized array";
     772                        } else {
     773                                next;
     774                        }
     775                }
     776                if ($e->{LEVELS}[0]->{TYPE} eq "ARRAY") {
     777                        if (not defined($e->{LEVELS}[0]->{SIZE_IS})) {
     778                                $reason = "is an unsized array";
     779                        } else {
     780                                next;
     781                        }
     782                }
     783
     784                $self->pidl_both("/*");
     785                $self->pidl_both(" * The following functions are skipped because");
     786                $self->pidl_both(" * an [out] argument $e->{NAME} $reason:");
     787                $self->pidl_both(" *");
     788                $self->pidl_both(" * dcerpc_$fn->{NAME}_send()");
     789                $self->pidl_both(" * dcerpc_$fn->{NAME}_recv()");
     790                $self->pidl_both(" * dcerpc_$fn->{NAME}()");
     791                $self->pidl_both(" */");
     792                $self->pidl_both("");
     793
     794                error($e->{ORIGINAL}, "$fn->{NAME}: [out] argument '$e->{NAME}' $reason, skip client functions");
     795                return;
     796        }
     797
     798        $self->ParseFunction_State($if, $fn, $fn->{NAME});
     799        $self->ParseFunction_Send($if, $fn, $fn->{NAME});
     800        $self->ParseFunction_Done($if, $fn, $fn->{NAME});
     801        $self->ParseFunction_Recv($if, $fn, $fn->{NAME});
     802        $self->ParseFunction_Sync($if, $fn, $fn->{NAME});
     803
     804        $self->pidl_hdr("");
    94805}
    95806
     
    98809#####################################################################
    99810# parse the interface definitions
    100 sub ParseInterface($)
    101 {
    102         my($interface) = shift;
    103 
    104         $res_hdr .= "#ifndef _HEADER_RPC_$interface->{NAME}\n";
    105         $res_hdr .= "#define _HEADER_RPC_$interface->{NAME}\n\n";
    106 
    107         if (defined $interface->{PROPERTIES}->{uuid}) {
    108                 $res_hdr .= "extern const struct ndr_interface_table ndr_table_$interface->{NAME};\n";
    109         }
    110 
    111         $res .= "/* $interface->{NAME} - client functions generated by pidl */\n\n";
    112 
    113         foreach my $fn (@{$interface->{FUNCTIONS}}) {
    114                 next if not defined($fn->{OPNUM});
     811sub ParseInterface($$)
     812{
     813        my ($self, $if) = @_;
     814        my $ifu = uc($if->{NAME});
     815
     816        $self->pidl_hdr("#ifndef _HEADER_RPC_$if->{NAME}");
     817        $self->pidl_hdr("#define _HEADER_RPC_$if->{NAME}");
     818        $self->pidl_hdr("");
     819
     820        if (defined $if->{PROPERTIES}->{uuid}) {
     821                $self->pidl_hdr("extern const struct ndr_interface_table ndr_table_$if->{NAME};");
     822                $self->pidl_hdr("");
     823        }
     824
     825        $self->pidl("/* $if->{NAME} - client functions generated by pidl */");
     826        $self->pidl("");
     827
     828        foreach my $fn (@{$if->{FUNCTIONS}}) {
    115829                next if defined($done{$fn->{NAME}});
    116                 ParseFunction($interface, $fn);
     830                next if has_property($fn, "noopnum");
     831                next if has_property($fn, "todo");
     832                $self->ParseFunction($if, $fn);
    117833                $done{$fn->{NAME}} = 1;
    118834        }
    119835
    120         $res_hdr .= "#endif /* _HEADER_RPC_$interface->{NAME} */\n";
    121 
    122         return $res;
    123 }
    124 
    125 sub Parse($$$$)
    126 {
    127         my($ndr,$header,$ndr_header,$client_header) = @_;
    128 
    129         $res = "";
    130         $res_hdr = "";
    131 
    132         $res .= "/* client functions auto-generated by pidl */\n";
    133         $res .= "\n";
     836        $self->pidl_hdr("#endif /* _HEADER_RPC_$if->{NAME} */");
     837}
     838
     839sub Parse($$$$$$)
     840{
     841        my($self,$ndr,$header,$ndr_header,$client_header) = @_;
     842
     843        $self->pidl("/* client functions auto-generated by pidl */");
     844        $self->pidl("");
    134845        if (is_intree()) {
    135                 $res .= "#include \"includes.h\"\n";
     846                $self->pidl("#include \"includes.h\"");
    136847        } else {
    137                 $res .= "#ifndef _GNU_SOURCE\n";
    138                 $res .= "#define _GNU_SOURCE\n";
    139                 $res .= "#endif\n";
    140                 $res .= "#include <stdio.h>\n";
    141                 $res .= "#include <stdbool.h>\n";
    142                 $res .= "#include <stdlib.h>\n";
    143                 $res .= "#include <stdint.h>\n";
    144                 $res .= "#include <stdarg.h>\n";
    145                 $res .= "#include <core/ntstatus.h>\n";
    146         }
    147         $res .= "#include \"$ndr_header\"\n";
    148         $res .= "#include \"$client_header\"\n";
    149         $res .= "\n";
    150 
    151         $res_hdr .= choose_header("librpc/rpc/dcerpc.h", "dcerpc.h")."\n";
    152         $res_hdr .= "#include \"$header\"\n";
     848                $self->pidl("#ifndef _GNU_SOURCE");
     849                $self->pidl("#define _GNU_SOURCE");
     850                $self->pidl("#endif");
     851                $self->pidl("#include <stdio.h>");
     852                $self->pidl("#include <stdbool.h>");
     853                $self->pidl("#include <stdlib.h>");
     854                $self->pidl("#include <stdint.h>");
     855                $self->pidl("#include <stdarg.h>");
     856                $self->pidl("#include <string.h>");
     857                $self->pidl("#include <core/ntstatus.h>");
     858        }
     859        $self->pidl("#include <tevent.h>");
     860        $self->pidl(choose_header("lib/util/tevent_ntstatus.h", "util/tevent_ntstatus.h")."");
     861        $self->pidl("#include \"$ndr_header\"");
     862        $self->pidl("#include \"$client_header\"");
     863        $self->pidl("");
     864
     865        $self->pidl_hdr(choose_header("librpc/rpc/dcerpc.h", "dcerpc.h")."");
     866        $self->pidl_hdr("#include \"$header\"");
    153867
    154868        foreach my $x (@{$ndr}) {
    155                 ($x->{TYPE} eq "INTERFACE") && ParseInterface($x);
    156         }
    157 
    158         return ($res,$res_hdr);
     869                ($x->{TYPE} eq "INTERFACE") && $self->ParseInterface($x);
     870        }
     871
     872        return ($self->{res},$self->{res_hdr});
    159873}
    160874
  • vendor/current/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm

    r414 r740  
    1616use Parse::Pidl::Util qw(has_property ParseExpr ParseExprExt print_uuid unmake_str);
    1717use Parse::Pidl::CUtil qw(get_pointer_to get_value_of get_array_element);
    18 use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred is_charset_array);
     18use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred ContainsPipe is_charset_array);
    1919use Parse::Pidl::Samba4 qw(is_intree choose_header ArrayDynamicallyAllocated);
    2020use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv GenerateFunctionOutEnv EnvSubstituteValue GenerateStructEnv);
     
    207207                $self->pidl("NDR_CHECK(ndr_push_uint3264($ndr, NDR_SCALARS, $size));");
    208208        }
    209        
     209
    210210        if ($l->{IS_VARYING}) {
    211211                $self->pidl("NDR_CHECK(ndr_push_uint3264($ndr, NDR_SCALARS, 0));");  # array offset
    212212                $self->pidl("NDR_CHECK(ndr_push_uint3264($ndr, NDR_SCALARS, $length));");
    213         } 
     213        }
    214214
    215215        return $length;
     
    575575                                $self->pidl("NDR_CHECK(ndr_push_relative_ptr2_start($ndr, $rel_var_name));");
    576576                        }
     577                        if ($l->{POINTER_TYPE} eq "relative_short") {
     578                                $self->pidl("NDR_CHECK(ndr_push_short_relative_ptr2($ndr, $var_name));");
     579                        }
    577580                }
    578581                $var_name = get_value_of($var_name);
     
    628631        my $var_name = $env->{$e->{NAME}};
    629632
     633        return if ContainsPipe($e, $e->{LEVELS}[0]);
     634
    630635        return unless $primitives or ($deferred and ContainsDeferred($e, $e->{LEVELS}[0]));
    631636
     
    675680        } elsif ($l->{POINTER_TYPE} eq "relative") {
    676681                $self->pidl("NDR_CHECK(ndr_push_relative_ptr1($ndr, $var_name));");
     682        } elsif ($l->{POINTER_TYPE} eq "relative_short") {
     683                $self->pidl("NDR_CHECK(ndr_push_short_relative_ptr1($ndr, $var_name));");
    677684        } elsif ($l->{POINTER_TYPE} eq "unique") {
    678685                $self->pidl("NDR_CHECK(ndr_push_unique_ptr($ndr, $var_name));");
     
    787794                                $self->pidl("for ($counter=0;$counter<$length;$counter++) {");
    788795                                $self->indent;
    789                                 $self->pidl("char *idx_$l->{LEVEL_INDEX}=NULL;");
    790                                 $self->pidl("if (asprintf(&idx_$l->{LEVEL_INDEX}, \"[\%d]\", $counter) != -1) {");
    791                                 $self->indent;
    792796
    793797                                $var_name = get_array_element($var_name, $counter);
     
    812816                        and not is_charset_array($e,$l)
    813817                        and not has_fast_array($e,$l)) {
    814                         $self->pidl("free(idx_$l->{LEVEL_INDEX});");
    815                         $self->deindent;
    816                         $self->pidl("}");
    817818                        $self->deindent;
    818819                        $self->pidl("}");
     
    866867                $self->pidl("NDR_CHECK(".TypeFunctionName("ndr_pull", $l->{DATA_TYPE})."($ndr, $ndr_flags, $var_name));");
    867868
    868                 if (my $range = has_property($e, "range")) {
     869                my $pl = GetPrevLevel($e, $l);
     870
     871                my $range = has_property($e, "range");
     872                if ($range and $pl->{TYPE} ne "ARRAY") {
    869873                        $var_name = get_value_of($var_name);
    870874                        my $signed = Parse::Pidl::Typelist::is_signed($l->{DATA_TYPE});
     
    944948        if (($l->{TYPE} eq "POINTER") and ($l->{POINTER_TYPE} eq "ref")) {
    945949                my $nl = GetNextLevel($e, $l);
    946                 my $next_is_array = ($nl->{TYPE} eq "ARRAY");
    947                 my $next_is_string = (($nl->{TYPE} eq "DATA") and
    948                                         ($nl->{DATA_TYPE} eq "string"));
    949                 if ($next_is_array or $next_is_string) {
    950                         return undef;
    951                 } elsif ($l->{LEVEL} eq "TOP") {
     950                return undef if ($nl->{TYPE} eq "PIPE");
     951                return undef if ($nl->{TYPE} eq "ARRAY");
     952                return undef if (($nl->{TYPE} eq "DATA") and ($nl->{DATA_TYPE} eq "string"));
     953
     954                if ($l->{LEVEL} eq "TOP") {
    952955                        $mem_flags = "LIBNDR_FLAG_REF_ALLOC";
    953956                }
     
    10101013                } elsif ($l->{TYPE} eq "ARRAY") {
    10111014                        my $length = $self->ParseArrayPullHeader($e, $l, $ndr, $var_name, $env);
     1015
     1016                        if (my $range = has_property($e, "range")) {
     1017                                my ($low, $high) = split(/,/, $range, 2);
     1018                                if ($low < 0) {
     1019                                        warning(0, "$low is invalid for the range of an array size");
     1020                                }
     1021                                if ($low == 0) {
     1022                                        $self->pidl("if ($length > $high) {");
     1023                                } else {
     1024                                        $self->pidl("if ($length < $low || $length > $high) {");
     1025                                }
     1026                                $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_RANGE, \"value out of range\");");
     1027                                $self->pidl("}");
     1028                        }
    10121029
    10131030                        my $nl = GetNextLevel($e, $l);
     
    10431060                        $self->indent;
    10441061
    1045                         if ($l->{POINTER_TYPE} eq "relative") {
     1062                        if ($l->{POINTER_TYPE} eq "relative" or $l->{POINTER_TYPE} eq "relative_short") {
    10461063                                $self->pidl("uint32_t _relative_save_offset;");
    10471064                                $self->pidl("_relative_save_offset = $ndr->offset;");
     
    10581075
    10591076                if ($l->{POINTER_TYPE} ne "ref") {
    1060                         if ($l->{POINTER_TYPE} eq "relative") {
     1077                        if ($l->{POINTER_TYPE} eq "relative") {
     1078                                $self->pidl("if ($ndr->offset > $ndr->relative_highest_offset) {");
     1079                                $self->indent;
     1080                                $self->pidl("$ndr->relative_highest_offset = $ndr->offset;");
     1081                                $self->deindent;
     1082                                $self->pidl("}");
    10611083                                $self->pidl("$ndr->offset = _relative_save_offset;");
    10621084                        }
     
    10721094                if ($l->{IS_VARYING}) {
    10731095                        $length = "ndr_get_array_length($ndr, " . get_pointer_to($var_name) .")";
     1096                }
     1097
     1098                if (my $range = has_property($e, "range")) {
     1099                        my ($low, $high) = split(/,/, $range, 2);
     1100                        if ($low < 0) {
     1101                                warning(0, "$low is invalid for the range of an array size");
     1102                        }
     1103                        if ($low == 0) {
     1104                                $self->pidl("if ($length > $high) {");
     1105                        } else {
     1106                                $self->pidl("if ($length < $low || $length > $high) {");
     1107                        }
     1108                        $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_RANGE, \"value out of range\");");
     1109                        $self->pidl("}");
    10741110                }
    10751111
     
    11161152        my $represent_name;
    11171153        my $transmit_name;
     1154
     1155        return if ContainsPipe($e, $e->{LEVELS}[0]);
    11181156
    11191157        return unless $primitives or ($deferred and ContainsDeferred($e, $e->{LEVELS}[0]));
     
    11621200                        $self->pidl("}");
    11631201                }
    1164                
     1202
    11651203                return;
    11661204        } elsif ($l->{POINTER_TYPE} eq "ref" and $l->{LEVEL} eq "EMBEDDED") {
     
    11701208                 ($l->{POINTER_TYPE} eq "full")) {
    11711209                $self->pidl("NDR_CHECK(ndr_pull_generic_ptr($ndr, &_ptr_$e->{NAME}));");
     1210        } elsif ($l->{POINTER_TYPE} eq "relative_short") {
     1211                $self->pidl("NDR_CHECK(ndr_pull_relative_ptr_short($ndr, &_ptr_$e->{NAME}));");
    11721212        } else {
    11731213                die("Unhandled pointer type $l->{POINTER_TYPE}");
     
    11901230
    11911231        #$self->pidl("memset($var_name, 0, sizeof($var_name));");
    1192         if ($l->{POINTER_TYPE} eq "relative") {
     1232        if ($l->{POINTER_TYPE} eq "relative" or $l->{POINTER_TYPE} eq "relative_short") {
    11931233                $self->pidl("NDR_CHECK(ndr_pull_relative_ptr1($ndr, $var_name, _ptr_$e->{NAME}));");
    11941234        }
     
    14551495
    14561496        $self->pidl("ndr_print_struct($ndr, name, \"$name\");");
     1497        $self->pidl("if (r == NULL) { ndr_print_null($ndr); return; }");
    14571498
    14581499        $self->start_flags($struct, $ndr);
     
    14711512        my ($self,$e) = @_;
    14721513        foreach my $l (@{$e->{LEVELS}}) {
     1514                my $size = 32;
    14731515                if ($l->{TYPE} eq "POINTER" and
    14741516                        not ($l->{POINTER_TYPE} eq "ref" and $l->{LEVEL} eq "TOP")) {
    1475                         $self->pidl("uint32_t _ptr_$e->{NAME};");
     1517                        if ($l->{POINTER_TYPE} eq "relative_short") {
     1518                                $size = 16;
     1519                        }
     1520                        $self->pidl("uint${size}_t _ptr_$e->{NAME};");
    14761521                        last;
    14771522                }
     
    16031648                $self->pidl("flags |= $flags;");
    16041649        }
    1605         $self->pidl("return ndr_size_struct($varname, flags, (ndr_push_flags_fn_t)ndr_push_$name, ic);");
     1650        $self->pidl("return ndr_size_struct($varname, flags, (ndr_push_flags_fn_t)ndr_push_$name);");
    16061651}
    16071652
     
    16151660{
    16161661        my ($d, $name, $varname) = @_;
    1617         return "const struct $name *$varname, struct smb_iconv_convenience *ic, int flags";
     1662        return "const struct $name *$varname, int flags";
    16181663}
    16191664
     
    16381683        }
    16391684
    1640         $self->pidl("return ndr_size_union($varname, flags, level, (ndr_push_flags_fn_t)ndr_push_$name, ic);");
     1685        $self->pidl("return ndr_size_union($varname, flags, level, (ndr_push_flags_fn_t)ndr_push_$name);");
    16411686}
    16421687
     
    16471692        my $have_default = 0;
    16481693
    1649         $self->pidl("int level = ndr_push_get_switch_value($ndr, $varname);");
     1694        $self->pidl("uint32_t level = ndr_push_get_switch_value($ndr, $varname);");
    16501695
    16511696        if (defined($e->{SWITCH_TYPE})) {
     1697                if (defined($e->{ALIGN})) {
     1698                        $self->pidl("NDR_CHECK(ndr_push_union_align($ndr, $e->{ALIGN}));");
     1699                }
     1700
    16521701                $self->pidl("NDR_CHECK(ndr_push_$e->{SWITCH_TYPE}($ndr, NDR_SCALARS, level));");
    16531702        }
    16541703
    16551704        if (defined($e->{ALIGN})) {
    1656                 $self->pidl("NDR_CHECK(ndr_push_union_align($ndr, $e->{ALIGN}));");
     1705                if ($e->{IS_MS_UNION}) {
     1706                        $self->pidl("/* ms_union is always aligned to the largest union arm*/");
     1707                        $self->pidl("NDR_CHECK(ndr_push_align($ndr, $e->{ALIGN}));");
     1708                } else {
     1709                        $self->pidl("NDR_CHECK(ndr_push_union_align($ndr, $e->{ALIGN}));");
     1710                }
    16571711        }
    16581712
     
    16941748        my $have_default = 0;
    16951749
    1696         $self->pidl("int level = ndr_push_get_switch_value($ndr, $varname);");
     1750        $self->pidl("uint32_t level = ndr_push_get_switch_value($ndr, $varname);");
    16971751        if (defined($e->{PROPERTIES}{relative_base})) {
    16981752                # retrieve the current offset as base for relative pointers
     
    17531807        my $have_default = 0;
    17541808
    1755         $self->pidl("int level;");
     1809        $self->pidl("uint32_t level;");
    17561810        foreach my $el (@{$e->{ELEMENTS}}) {
    17571811                $self->DeclareArrayVariables($el);
     
    17941848        my $have_default = 0;
    17951849
     1850
    17961851        if (defined($switch_type)) {
     1852                if (defined($e->{ALIGN})) {
     1853                        $self->pidl("NDR_CHECK(ndr_pull_union_align($ndr, $e->{ALIGN}));");
     1854                }
     1855
    17971856                $self->pidl("NDR_CHECK(ndr_pull_$switch_type($ndr, NDR_SCALARS, &_level));");
    17981857                $self->pidl("if (_level != level) {");
     
    18021861
    18031862        if (defined($e->{ALIGN})) {
    1804                 $self->pidl("NDR_CHECK(ndr_pull_union_align($ndr, $e->{ALIGN}));");
     1863                if ($e->{IS_MS_UNION}) {
     1864                        $self->pidl("/* ms_union is always aligned to the largest union arm*/");
     1865                        $self->pidl("NDR_CHECK(ndr_pull_align($ndr, $e->{ALIGN}));");
     1866                } else {
     1867                        $self->pidl("NDR_CHECK(ndr_pull_union_align($ndr, $e->{ALIGN}));");
     1868                }
    18051869        }
    18061870
     
    18801944        my $switch_type = $e->{SWITCH_TYPE};
    18811945
    1882         $self->pidl("int level;");
     1946        $self->pidl("uint32_t level;");
    18831947        if (defined($switch_type)) {
    18841948                if (Parse::Pidl::Typelist::typeIs($switch_type, "ENUM")) {
     
    19261990{
    19271991        my ($d,$name) = @_;
    1928         return "const union $name *r, uint32_t level, struct smb_iconv_convenience *ic, int flags";
     1992        return "const union $name *r, uint32_t level, int flags";
    19291993}
    19301994
     
    20042068};
    20052069
     2070sub ParsePipePushChunk($$)
     2071{
     2072        my ($self, $t) = @_;
     2073
     2074        my $pipe = $t;
     2075        $pipe = $t->{DATA} if ($t->{TYPE} eq "TYPEDEF");
     2076        my $struct = $pipe->{DATA};
     2077
     2078        my $name = "$struct->{NAME}";
     2079        my $ndr = "ndr";
     2080        my $varname = "r";
     2081
     2082        my $args = $typefamily{$struct->{TYPE}}->{DECL}->($struct, "push", $name, $varname);
     2083
     2084        $self->fn_declare("push", $struct, "enum ndr_err_code ndr_push_$name(struct ndr_push *$ndr, int ndr_flags, $args)") or return;
     2085
     2086        return if has_property($t, "nopush");
     2087
     2088        $self->pidl("{");
     2089        $self->indent;
     2090
     2091        $self->ParseStructPush($struct, $ndr, $varname);
     2092        $self->pidl("");
     2093
     2094        $self->pidl("NDR_CHECK(ndr_push_pipe_chunk_trailer(ndr, ndr_flags, $varname->count));");
     2095        $self->pidl("");
     2096
     2097        $self->pidl("return NDR_ERR_SUCCESS;");
     2098        $self->deindent;
     2099        $self->pidl("}");
     2100        $self->pidl("");
     2101}
     2102
     2103sub ParsePipePullChunk($$)
     2104{
     2105        my ($self, $t) = @_;
     2106
     2107        my $pipe = $t;
     2108        $pipe = $t->{DATA} if ($t->{TYPE} eq "TYPEDEF");
     2109        my $struct = $pipe->{DATA};
     2110
     2111        my $name = "$struct->{NAME}";
     2112        my $ndr = "ndr";
     2113        my $varname = "r";
     2114
     2115        my $args = $typefamily{$struct->{TYPE}}->{DECL}->($struct, "pull", $name, $varname);
     2116
     2117        $self->fn_declare("pull", $struct, "enum ndr_err_code ndr_pull_$name(struct ndr_pull *$ndr, int ndr_flags, $args)") or return;
     2118
     2119        return if has_property($struct, "nopull");
     2120
     2121        $self->pidl("{");
     2122        $self->indent;
     2123
     2124        $self->ParseStructPull($struct, $ndr, $varname);
     2125        $self->pidl("");
     2126
     2127        $self->pidl("NDR_CHECK(ndr_check_pipe_chunk_trailer($ndr, ndr_flags, $varname->count));");
     2128        $self->pidl("");
     2129
     2130        $self->pidl("return NDR_ERR_SUCCESS;");
     2131        $self->deindent;
     2132        $self->pidl("}");
     2133        $self->pidl("");
     2134}
     2135
     2136sub ParsePipePrintChunk($$)
     2137{
     2138        my ($self, $t) = @_;
     2139
     2140        my $pipe = $t;
     2141        $pipe = $t->{DATA} if ($t->{TYPE} eq "TYPEDEF");
     2142        my $struct = $pipe->{DATA};
     2143
     2144        my $name = "$struct->{NAME}";
     2145        my $ndr = "ndr";
     2146        my $varname = "r";
     2147
     2148        my $args = $typefamily{$struct->{TYPE}}->{DECL}->($struct, "print", $name, $varname);
     2149
     2150        $self->pidl_hdr("void ndr_print_$name(struct ndr_print *ndr, const char *name, $args);");
     2151
     2152        return if (has_property($t, "noprint"));
     2153
     2154        $self->pidl("_PUBLIC_ void ndr_print_$name(struct ndr_print *$ndr, const char *name, $args)");
     2155        $self->pidl("{");
     2156        $self->indent;
     2157        $self->ParseTypePrint($struct, $ndr, $varname);
     2158        $self->deindent;
     2159        $self->pidl("}");
     2160        $self->pidl("");
     2161}
     2162
    20062163#####################################################################
    20072164# parse a function - print side
     
    20242181
    20252182        $self->pidl("ndr_print_struct($ndr, name, \"$fn->{NAME}\");");
     2183        $self->pidl("if (r == NULL) { ndr_print_null($ndr); return; }");
    20262184        $self->pidl("$ndr->depth++;");
    20272185
     
    22052363                next if (($e->{LEVELS}[1]->{TYPE} eq "DATA") and
    22062364                                 ($e->{LEVELS}[1]->{DATA_TYPE} eq "string"));
     2365                next if ($e->{LEVELS}[1]->{TYPE} eq "PIPE");
    22072366                next if (($e->{LEVELS}[1]->{TYPE} eq "ARRAY")
    22082367                        and   $e->{LEVELS}[1]->{IS_ZERO_TERMINATED});
     
    22192378                        } else {
    22202379                                $self->pidl("memset(r->out.$e->{NAME}, 0, ($size) * sizeof(*r->out.$e->{NAME}));");
     2380                        }
     2381                } elsif ($e->{LEVELS}[1]->{TYPE} eq "ARRAY") {
     2382                        if (grep(/in/, @{$e->{DIRECTION}})) {
     2383                                $self->pidl("r->out.$e->{NAME} = r->in.$e->{NAME};");
     2384                        } else {
     2385                                $self->pidl("r->out.$e->{NAME} = NULL;");
    22212386                        }
    22222387                } else {
     
    22782443}
    22792444
     2445sub ParseGeneratePipeArray($$$)
     2446{
     2447        my ($self, $fn, $direction) = @_;
     2448
     2449        $self->pidl("static const struct ndr_interface_call_pipe $fn->{NAME}\_$direction\_pipes[] = {");
     2450        $self->indent;
     2451
     2452        foreach my $e (@{$fn->{ELEMENTS}}) {
     2453                next unless ContainsPipe($e, $e->{LEVELS}[0]);
     2454                next unless (grep(/$direction/, @{$e->{DIRECTION}}));
     2455
     2456                my $cname = "$e->{TYPE}_chunk";
     2457
     2458                $self->pidl("{");
     2459                $self->indent;
     2460                $self->pidl("\"$direction.$e->{NAME}\",");
     2461                $self->pidl("\"$cname\",");
     2462                $self->pidl("sizeof(struct $cname),");
     2463                $self->pidl("(ndr_push_flags_fn_t) ndr_push_$cname,");
     2464                $self->pidl("(ndr_pull_flags_fn_t) ndr_pull_$cname,");
     2465                $self->pidl("(ndr_print_fn_t) ndr_print_$cname,");
     2466                $self->deindent;
     2467                $self->pidl("},");
     2468        }
     2469        $self->pidl("{ NULL, NULL, 0, NULL, NULL, NULL }");
     2470        $self->deindent;
     2471        $self->pidl("};");
     2472        $self->pidl("");
     2473}
     2474
     2475sub FunctionCallPipes($$)
     2476{
     2477        my ($self, $d) = @_;
     2478        return if not defined($d->{OPNUM});
     2479
     2480        my $in_pipes = 0;
     2481        my $out_pipes = 0;
     2482
     2483        foreach my $e (@{$d->{ELEMENTS}}) {
     2484                next unless ContainsPipe($e, $e->{LEVELS}[0]);
     2485
     2486                if (grep(/in/, @{$e->{DIRECTION}})) {
     2487                        $in_pipes++;
     2488                }
     2489                if (grep(/out/, @{$e->{DIRECTION}})) {
     2490                        $out_pipes++;
     2491                }
     2492        }
     2493
     2494        if ($in_pipes) {
     2495                $self->ParseGeneratePipeArray($d, "in");
     2496        }
     2497
     2498        if ($out_pipes) {
     2499                $self->ParseGeneratePipeArray($d, "out");
     2500        }
     2501}
     2502
    22802503sub FunctionCallEntry($$)
    22812504{
    22822505        my ($self, $d) = @_;
    22832506        return 0 if not defined($d->{OPNUM});
     2507
     2508        my $in_pipes = 0;
     2509        my $out_pipes = 0;
     2510
     2511        foreach my $e (@{$d->{ELEMENTS}}) {
     2512                next unless ContainsPipe($e, $e->{LEVELS}[0]);
     2513
     2514                if (grep(/in/, @{$e->{DIRECTION}})) {
     2515                        $in_pipes++;
     2516                }
     2517                if (grep(/out/, @{$e->{DIRECTION}})) {
     2518                        $out_pipes++;
     2519                }
     2520        }
     2521
     2522        my $in_pipes_ptr = "NULL";
     2523        my $out_pipes_ptr = "NULL";
     2524
     2525        if ($in_pipes) {
     2526                $in_pipes_ptr = "$d->{NAME}_in_pipes";
     2527        }
     2528
     2529        if ($out_pipes) {
     2530                $out_pipes_ptr = "$d->{NAME}_out_pipes";
     2531        }
     2532
    22842533        $self->pidl("\t{");
    22852534        $self->pidl("\t\t\"$d->{NAME}\",");
     
    22882537        $self->pidl("\t\t(ndr_pull_flags_fn_t) ndr_pull_$d->{NAME},");
    22892538        $self->pidl("\t\t(ndr_print_function_t) ndr_print_$d->{NAME},");
    2290         $self->pidl("\t\t".($d->{ASYNC}?"true":"false").",");
     2539        $self->pidl("\t\t{ $in_pipes, $in_pipes_ptr },");
     2540        $self->pidl("\t\t{ $out_pipes, $out_pipes_ptr },");
    22912541        $self->pidl("\t},");
    22922542        return 1;
     
    23042554        return unless defined ($interface->{PROPERTIES}->{uuid});
    23052555
     2556        foreach my $d (@{$interface->{INHERITED_FUNCTIONS}},@{$interface->{FUNCTIONS}}) {
     2557                $self->FunctionCallPipes($d);
     2558        }
     2559
    23062560        $self->pidl("static const struct ndr_interface_call $interface->{NAME}\_calls[] = {");
    23072561
     
    23092563                $count += $self->FunctionCallEntry($d);
    23102564        }
    2311         $self->pidl("\t{ NULL, 0, NULL, NULL, NULL, false }");
     2565        $self->pidl("\t{ NULL, 0, NULL, NULL, NULL }");
    23122566        $self->pidl("};");
    23132567        $self->pidl("");
     
    25572811        # Typedefs
    25582812        foreach my $d (@{$interface->{TYPES}}) {
     2813                if (Parse::Pidl::Typelist::typeIs($d, "PIPE")) {
     2814                        ($needed->{TypeFunctionName("ndr_push", $d)}) &&
     2815                                $self->ParsePipePushChunk($d);
     2816                        ($needed->{TypeFunctionName("ndr_pull", $d)}) &&
     2817                                $self->ParsePipePullChunk($d);
     2818                        ($needed->{TypeFunctionName("ndr_print", $d)}) &&
     2819                                $self->ParsePipePrintChunk($d);
     2820
     2821                        $needed->{TypeFunctionName("ndr_pull", $d)} = 0;
     2822                        $needed->{TypeFunctionName("ndr_push", $d)} = 0;
     2823                        $needed->{TypeFunctionName("ndr_print", $d)} = 0;
     2824                        next;
     2825                }
     2826
    25592827                next unless(typeHasBody($d));
    25602828
     
    25762844                ($needed->{"ndr_pull_$d->{NAME}"}) && $self->ParseFunctionPull($d);
    25772845                ($needed->{"ndr_print_$d->{NAME}"}) && $self->ParseFunctionPrint($d);
    2578 
    2579                 # Make sure we don't generate a function twice...
    2580                 $needed->{"ndr_push_$d->{NAME}"} = $needed->{"ndr_pull_$d->{NAME}"} =
    2581                         $needed->{"ndr_print_$d->{NAME}"} = 0;
    25822846        }
    25832847
     
    27022966
    27032967        NeededType($t->{DATA}, $needed, $req) if ($t->{TYPE} eq "TYPEDEF");
     2968        NeededType($t->{DATA}, $needed, $req) if ($t->{TYPE} eq "PIPE");
    27042969
    27052970        if ($t->{TYPE} eq "STRUCT" or $t->{TYPE} eq "UNION") {
     
    27232988        NeededFunction($_, $needed) foreach (@{$interface->{FUNCTIONS}});
    27242989        foreach (reverse @{$interface->{TYPES}}) {
     2990
    27252991                if (has_property($_, "public")) {
    27262992                        $needed->{TypeFunctionName("ndr_pull", $_)} = $needed->{TypeFunctionName("ndr_push", $_)} =
  • vendor/current/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm

    r414 r740  
    8282
    8383        pidl "
    84 static NTSTATUS $name\__op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface)
     84static NTSTATUS $name\__op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface, uint32_t if_version)
    8585{
    8686#ifdef DCESRV_INTERFACE_$uname\_BIND
  • vendor/current/pidl/lib/Parse/Pidl/Samba4/Python.pm

    r414 r740  
    1313use Parse::Pidl::Typelist qw(hasType resolveType getType mapTypeName expandAlias);
    1414use Parse::Pidl::Util qw(has_property ParseExpr unmake_str);
    15 use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred is_charset_array);
     15use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred ContainsPipe is_charset_array);
    1616use Parse::Pidl::CUtil qw(get_value_of get_pointer_to);
    1717use Parse::Pidl::Samba4 qw(ArrayDynamicallyAllocated);
     
    2525        my $self = { res => "", res_hdr => "", tabs => "", constants => {},
    2626                     module_methods => [], module_objects => [], ready_types => [],
    27                                  module_imports => [], type_imports => {},
    28                                  patch_type_calls => [], readycode => [] };
     27                                 module_imports => {}, type_imports => {},
     28                                 patch_type_calls => [], prereadycode => [],
     29                                 postreadycode => []};
    2930        bless($self, $class);
    3031}
     
    6465        my ($name, $basename) = @_;
    6566
     67        $basename =~ s/^.*\.([^.]+)$/\1/;
     68
    6669        $name =~ s/^$basename\_//;
     70
    6771
    6872        return $name;
     
    7781                s/\.idl$//;
    7882                $self->pidl_hdr("#include \"librpc/gen_ndr/$_\.h\"\n");
    79                 $self->register_module_import($_);
     83                $self->register_module_import("samba.dcerpc.$_");
    8084        }
    8185}
     
    127131                } else {
    128132                        $self->pidl("ret = Py_None;");
     133                        $self->pidl("Py_INCREF(ret);");
    129134                }
    130135
     
    214219                                not ($nl->{TYPE} eq "ARRAY" and ($nl->{IS_FIXED} or is_charset_array($e, $nl))) and
    215220                                not ($nl->{TYPE} eq "DATA" and Parse::Pidl::Typelist::scalar_is_reference($nl->{DATA_TYPE}))) {
    216                                 $self->pidl("talloc_free($varname);");
     221                                $self->pidl("talloc_unlink(py_talloc_get_mem_ctx(py_obj), $varname);");
    217222                        }
    218223                        $self->ConvertObjectFromPython($env, $mem_ctx, $e, "value", $varname, "return -1;");
     
    254259                $self->pidl("DATA_BLOB blob;");
    255260                $self->pidl("enum ndr_err_code err;");
    256                 $self->pidl("err = ndr_push_struct_blob(&blob, py_talloc_get_mem_ctx(py_obj), NULL, object, (ndr_push_flags_fn_t)ndr_push_$name);");
     261                $self->pidl("err = ndr_push_struct_blob(&blob, py_talloc_get_mem_ctx(py_obj), object, (ndr_push_flags_fn_t)ndr_push_$name);");
    257262                $self->pidl("if (err != NDR_ERR_SUCCESS) {");
    258263                $self->indent;
     
    276281                $self->pidl("\treturn NULL;");
    277282                $self->pidl("");
    278 
    279                 # This disgusting hack works around the fact that ndr_pull_struct_blob_all will always fail on structures with relative pointers. 
    280                 # So, map ndr_unpack to ndr_pull_struct_blob_all only if we don't have any relative pointers in this
    281                 my $got_relative = 0;
    282                 if ($#{$d->{ELEMENTS}} > -1) {
    283                         foreach my $e (@{$d->{ELEMENTS}}) {
    284                                 my $l = $e->{LEVELS}[0];
    285                                 if ($l->{TYPE} eq "POINTER" and ($l->{POINTER_TYPE} eq "relative")) {
    286                                         $got_relative = 1;
    287                                         last;
    288                                 }
    289                         }
    290                 }
    291                 if ($got_relative == 0) {
    292                         $self->pidl("err = ndr_pull_struct_blob_all(&blob, py_talloc_get_mem_ctx(py_obj), NULL, object, (ndr_pull_flags_fn_t)ndr_pull_$name);");
    293                 } else {
    294                         $self->pidl("err = ndr_pull_struct_blob(&blob, py_talloc_get_mem_ctx(py_obj), NULL, object, (ndr_pull_flags_fn_t)ndr_pull_$name);");
    295                 }
     283                $self->pidl("err = ndr_pull_struct_blob_all(&blob, py_talloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_$name);");
    296284                $self->pidl("if (err != NDR_ERR_SUCCESS) {");
    297285                $self->indent;
     
    305293                $self->pidl("}");
    306294                $self->pidl("");
     295
     296                $self->pidl("static PyObject *py_$name\_ndr_print(PyObject *py_obj)");
     297                $self->pidl("{");
     298                $self->indent;
     299                $self->pidl("$cname *object = ($cname *)py_talloc_get_ptr(py_obj);");
     300                $self->pidl("PyObject *ret;");
     301                $self->pidl("char *retstr;");
     302                $self->pidl("");
     303                $self->pidl("retstr = ndr_print_struct_string(py_talloc_get_mem_ctx(py_obj), (ndr_print_fn_t)ndr_print_$name, \"$name\", object);");
     304                $self->pidl("ret = PyString_FromString(retstr);");
     305                $self->pidl("talloc_free(retstr);");
     306                $self->pidl("");
     307                $self->pidl("return ret;");
     308                $self->deindent;
     309                $self->pidl("}");
     310                $self->pidl("");
     311
    307312                $py_methods = "py_$name\_methods";
    308313                $self->pidl("static PyMethodDef $py_methods\[] = {");
    309314                $self->indent;
    310                 $self->pidl("{ \"__ndr_pack__\", (PyCFunction)py_$name\_ndr_pack, METH_NOARGS, \"S.pack() -> blob\\nNDR pack\" },");
    311                 $self->pidl("{ \"__ndr_unpack__\", (PyCFunction)py_$name\_ndr_unpack, METH_VARARGS, \"S.unpack(blob) -> None\\nNDR unpack\" },");
     315                $self->pidl("{ \"__ndr_pack__\", (PyCFunction)py_$name\_ndr_pack, METH_NOARGS, \"S.ndr_pack(object) -> blob\\nNDR pack\" },");
     316                $self->pidl("{ \"__ndr_unpack__\", (PyCFunction)py_$name\_ndr_unpack, METH_VARARGS, \"S.ndr_unpack(class, blob) -> None\\nNDR unpack\" },");
     317                $self->pidl("{ \"__ndr_print__\", (PyCFunction)py_$name\_ndr_print, METH_VARARGS, \"S.ndr_print(object) -> None\\nNDR print\" },");
    312318                $self->pidl("{ NULL, NULL, 0, NULL }");
    313319                $self->deindent;
     
    324330        $self->pidl("PyObject_HEAD_INIT(NULL) 0,");
    325331        $self->pidl(".tp_name = \"$modulename.$prettyname\",");
    326         $self->pidl(".tp_basicsize = sizeof(py_talloc_Object),");
    327         $self->pidl(".tp_dealloc = py_talloc_dealloc,");
    328332        $self->pidl(".tp_getset = $getsetters,");
    329         $self->pidl(".tp_repr = py_talloc_default_repr,");
    330333        if ($docstring) {
    331334                $self->pidl(".tp_doc = $docstring,");
     
    333336        $self->pidl(".tp_methods = $py_methods,");
    334337        $self->pidl(".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,");
     338        $self->pidl(".tp_basicsize = sizeof(py_talloc_Object),");
    335339        $self->pidl(".tp_new = py_$name\_new,");
    336340        $self->deindent;
     
    338342
    339343        $self->pidl("");
     344
     345        my $talloc_typename = $self->import_type_variable("talloc", "Object");
     346        $self->register_module_prereadycode(["$name\_Type.tp_base = $talloc_typename;", ""]);
    340347
    341348        return "&$typeobject";
     
    389396        $self->pidl("{");
    390397        $self->indent;
    391         $self->pidl("PyObject *result = Py_None;");
     398        $self->pidl("PyObject *result;");
    392399        foreach my $e (@{$fn->{ELEMENTS}}) {
    393400                next unless (grep(/out/,@{$e->{DIRECTION}}));
     
    408415                $signature .= "(";
    409416        } elsif ($result_size == 0) {
     417                $self->pidl("result = Py_None;");
     418                $self->pidl("Py_INCREF(result);");
    410419                $signature .= "None";
    411420        }
     
    506515                        my $py_var = "py_".$metadata_args->{in}->{$e->{NAME}};
    507516                        $self->pidl("PY_CHECK_TYPE(&PyList_Type, $py_var, $fail);");
    508                         my $val = "PyList_Size($py_var)";
     517                        my $val = "PyList_GET_SIZE($py_var)";
    509518                        if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
    510519                                $self->pidl("r->in.$e->{NAME} = talloc_ptrtype(r, r->in.$e->{NAME});");
     
    531540        my $docstring = $self->DocString($fn, $fn->{NAME});
    532541
    533         my ($insignature, $outsignature);
    534         my ($infn, $outfn);
    535 
    536         if (has_property($fn, "todo")) {
    537                 unless ($docstring) { $docstring = "NULL"; }
    538                 $infn = "NULL";
    539                 $outfn = "NULL";
     542        my ($infn, $insignature) = $self->PythonFunctionPackIn($fn, $fnname);
     543        my ($outfn, $outsignature) = $self->PythonFunctionUnpackOut($fn, $fnname);
     544        my $signature = "S.$prettyname($insignature) -> $outsignature";
     545        if ($docstring) {
     546                $docstring = "\"$signature\\n\\n\"$docstring";
    540547        } else {
    541                 ($infn, $insignature) = $self->PythonFunctionPackIn($fn, $fnname);
    542                 ($outfn, $outsignature) = $self->PythonFunctionUnpackOut($fn, $fnname);
    543                 my $signature = "S.$prettyname($insignature) -> $outsignature";
    544                 if ($docstring) {
    545                         $docstring = "\"$signature\\n\\n\"$docstring";
    546                 } else {
    547                         $docstring = "\"$signature\"";
    548                 }
     548                $docstring = "\"$signature\"";
    549549        }
    550550
     
    664664
    665665                foreach my $d (@{$interface->{FUNCTIONS}}) {
    666                         next if not defined($d->{OPNUM});
     666                        next if has_property($d, "noopnum");
    667667                        next if has_property($d, "nopython");
     668                        next if has_property($d, "todo");
     669
     670                        my $skip = 0;
     671                        foreach my $e (@{$d->{ELEMENTS}}) {
     672                                if (ContainsPipe($e, $e->{LEVELS}[0])) {
     673                                        $skip = 1;
     674                                        last;
     675                                }
     676                        }
     677                        next if $skip;
    668678
    669679                        my $prettyname = $d->{NAME};
     
    674684                        my ($infn, $outfn, $fndocstring) = $self->PythonFunction($d, $interface->{NAME}, $prettyname);
    675685
    676                         push (@fns, [$infn, $outfn, "dcerpc_$d->{NAME}", $prettyname, $fndocstring, $d->{OPNUM}]);
     686                        push (@fns, [$infn, $outfn, "dcerpc_$d->{NAME}_r", $prettyname, $fndocstring, $d->{OPNUM}]);
    677687                }
    678688
     
    681691                foreach my $d (@fns) {
    682692                        my ($infn, $outfn, $callfn, $prettyname, $docstring, $opnum) = @$d;
    683                         $self->pidl("{ \"$prettyname\", $docstring, (dcerpc_call_fn)$callfn, (py_data_pack_fn)$infn, (py_data_unpack_fn)$outfn, $opnum, &ndr_table_$interface->{NAME} },");
     693                        $self->pidl("{ \"$prettyname\", $docstring, (py_dcerpc_call_fn)$callfn, (py_data_pack_fn)$infn, (py_data_unpack_fn)$outfn, $opnum, &ndr_table_$interface->{NAME} },");
    684694                }
    685695                $self->pidl("{ NULL }");
     
    712722                }
    713723
    714                 $self->pidl("static PyTypeObject $interface->{NAME}_InterfaceType = {");
     724                my $if_typename = "$interface->{NAME}_InterfaceType";
     725
     726                $self->pidl("static PyTypeObject $if_typename = {");
    715727                $self->indent;
    716728                $self->pidl("PyObject_HEAD_INIT(NULL) 0,");
    717729                $self->pidl(".tp_name = \"$basename.$interface->{NAME}\",");
    718730                $self->pidl(".tp_basicsize = sizeof(dcerpc_InterfaceObject),");
    719                 $self->pidl(".tp_base = &dcerpc_InterfaceType,");
    720731                $self->pidl(".tp_doc = $docstring,");
    721732                $self->pidl(".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,");
     
    726737                $self->pidl("");
    727738
    728                 $self->register_module_typeobject($interface->{NAME}, "&$interface->{NAME}_InterfaceType");
    729                 $self->register_module_readycode(["if (!PyInterface_AddNdrRpcMethods(&$interface->{NAME}_InterfaceType, py_ndr_$interface->{NAME}\_methods))", "\treturn;", ""]);
     739                $self->register_module_typeobject($interface->{NAME}, "&$if_typename");
     740                my $dcerpc_typename = $self->import_type_variable("samba.dcerpc.base", "ClientConnection");
     741                $self->register_module_prereadycode(["$if_typename.tp_base = $dcerpc_typename;", ""]);
     742                $self->register_module_postreadycode(["if (!PyInterface_AddNdrRpcMethods(&$if_typename, py_ndr_$interface->{NAME}\_methods))", "\treturn;", ""]);
    730743        }
    731744
     
    744757        my ($self, $name, $py_name) = @_;
    745758
    746         $self->register_module_object($name, "(PyObject *)$py_name");
     759        $self->register_module_object($name, "(PyObject *)(void *)$py_name");
    747760
    748761        $self->check_ready_type($py_name);
     
    759772sub register_module_import($$)
    760773{
    761         my ($self, $basename) = @_;
    762 
    763         push (@{$self->{module_imports}}, $basename) unless (grep(/^$basename$/,@{$self->{module_imports}}));
     774        my ($self, $module_path) = @_;
     775
     776        my $var_name = $module_path;
     777        $var_name =~ s/\./_/g;
     778        $var_name = "dep_$var_name";
     779
     780        $self->{module_imports}->{$var_name} = $module_path;
     781
     782        return $var_name;
     783}
     784
     785sub import_type_variable($$$)
     786{
     787        my ($self, $module, $name) = @_;
     788
     789        $self->register_module_import($module);
     790        unless (defined($self->{type_imports}->{$name})) {
     791                $self->{type_imports}->{$name} = $module;
     792        }
     793        return "$name\_Type";
    764794}
    765795
     
    769799        # FIXME: Have a global lookup table for types that look different on the
    770800        # wire than they are named in C?
    771         if ($orig_ctype->{NAME} eq "dom_sid2") {
     801        if ($orig_ctype->{NAME} eq "dom_sid2" or $orig_ctype->{NAME} eq "dom_sid28") {
    772802                $orig_ctype->{NAME} = "dom_sid";
    773803        }
     
    778808        # If this is an external type, make sure we do the right imports.
    779809        if (($ctype->{BASEFILE} ne $self->{BASENAME})) {
    780                 $self->register_module_import($ctype->{BASEFILE});
    781                 unless (defined($self->{type_imports}->{$ctype->{NAME}})) {
    782                         $self->{type_imports}->{$ctype->{NAME}} = $ctype->{BASEFILE};
    783                 }
    784                 return "$ctype->{NAME}_Type";
     810                return $self->import_type_variable("samba.dcerpc.$ctype->{BASEFILE}", $ctype->{NAME});
    785811        }
    786812        return "&$ctype->{NAME}_Type";
     
    795821}
    796822
    797 sub register_module_readycode($$)
     823sub register_module_prereadycode($$)
    798824{
    799825        my ($self, $code) = @_;
    800826
    801         push (@{$self->{readycode}}, @$code);
     827        push (@{$self->{prereadycode}}, @$code);
     828}
     829
     830sub register_module_postreadycode($$)
     831{
     832        my ($self, $code) = @_;
     833
     834        push (@{$self->{postreadycode}}, @$code);
    802835}
    803836
     
    815848                $self->pidl("memset($dest, 0, sizeof(" . get_value_of($dest) . "));");
    816849        } elsif ($dest =~ /^\&/) {
    817                 $self->pidl("memcpy($dest, $src, sizeof(" . get_value_of($dest) . "));");
     850                my $destvar = get_value_of($dest);
     851                $self->pidl("$destvar = *$src;");
    818852        } else {
    819853                $self->pidl("$dest = $src;");
     
    834868        }
    835869
    836         if ($actual_ctype->{TYPE} eq "ENUM" or $actual_ctype->{TYPE} eq "BITMAP" or
    837                 $actual_ctype->{TYPE} eq "SCALAR" and (
    838                 expandAlias($actual_ctype->{NAME}) =~ /^(u?int[0-9]*|hyper|NTTIME|time_t|NTTIME_hyper|NTTIME_1sec|dlong|udlong|udlongr)$/)) {
    839                 $self->pidl("PY_CHECK_TYPE(&PyInt_Type, $cvar, $fail);");
     870        if ($actual_ctype->{TYPE} eq "ENUM" or $actual_ctype->{TYPE} eq "BITMAP") {
     871                $self->pidl("if (PyLong_Check($cvar)) {");
     872                $self->indent;
     873                $self->pidl("$target = PyLong_AsLongLong($cvar);");
     874                $self->deindent;
     875                $self->pidl("} else if (PyInt_Check($cvar)) {");
     876                $self->indent;
    840877                $self->pidl("$target = PyInt_AsLong($cvar);");
     878                $self->deindent;
     879                $self->pidl("} else {");
     880                $self->indent;
     881                $self->pidl("PyErr_Format(PyExc_TypeError, \"Expected type %s or %s\",\\");
     882                $self->pidl("  PyInt_Type.tp_name, PyLong_Type.tp_name);");
     883                $self->pidl($fail);
     884                $self->deindent;
     885                $self->pidl("}");
    841886                return;
     887        }
     888        if ($actual_ctype->{TYPE} eq "SCALAR" ) {
     889                if (expandAlias($actual_ctype->{NAME}) =~ /^(u?int64|hyper|dlong|udlong|udlongr|NTTIME_hyper|NTTIME|NTTIME_1sec)$/) {
     890                        $self->pidl("if (PyLong_Check($cvar)) {");
     891                        $self->indent;
     892                        $self->pidl("$target = PyLong_AsLongLong($cvar);");
     893                        $self->deindent;
     894                        $self->pidl("} else if (PyInt_Check($cvar)) {");
     895                        $self->indent;
     896                        $self->pidl("$target = PyInt_AsLong($cvar);");
     897                        $self->deindent;
     898                        $self->pidl("} else {");
     899                        $self->indent;
     900                        $self->pidl("PyErr_Format(PyExc_TypeError, \"Expected type %s or %s\",\\");
     901                        $self->pidl("  PyInt_Type.tp_name, PyLong_Type.tp_name);");
     902                        $self->pidl($fail);
     903                        $self->deindent;
     904                        $self->pidl("}");
     905                        return;
     906                }
     907                if (expandAlias($actual_ctype->{NAME}) =~ /^(char|u?int[0-9]*|time_t|uid_t|gid_t)$/) {
     908                        $self->pidl("PY_CHECK_TYPE(&PyInt_Type, $cvar, $fail);");
     909                        $self->pidl("$target = PyInt_AsLong($cvar);");
     910                        return;
     911                }
    842912        }
    843913
     
    846916                unless (defined ($ctype_name)) {
    847917                        error($location, "Unable to determine origin of type `" . mapTypeName($ctype) . "'");
    848                         $self->pidl("PyErr_SetString(PyExc_TypeError, \"Can not convert C Type " . mapTypeName($ctype) . " to Python\");");
     918                        $self->pidl("PyErr_SetString(PyExc_TypeError, \"Can not convert C Type " . mapTypeName($ctype) . " from Python\");");
    849919                        return;
    850920                }
    851921                $self->pidl("PY_CHECK_TYPE($ctype_name, $cvar, $fail);");
    852                 $self->assign($target, "py_talloc_get_ptr($cvar)");
     922                $self->pidl("if (talloc_reference($mem_ctx, py_talloc_get_mem_ctx($cvar)) == NULL) {");
     923                $self->indent;
     924                $self->pidl("PyErr_NoMemory();");
     925                $self->pidl("$fail");
     926                $self->deindent;
     927                $self->pidl("}");
     928                $self->assign($target, "(".mapTypeName($ctype)." *)py_talloc_get_ptr($cvar)");
    853929                return;
    854930        }
    855931
    856932        if ($actual_ctype->{TYPE} eq "SCALAR" and $actual_ctype->{NAME} eq "DATA_BLOB") {
    857                 $self->pidl("$target = data_blob_talloc($mem_ctx, PyString_AsString($cvar), PyString_Size($cvar));");
     933                $self->pidl("$target = data_blob_talloc($mem_ctx, PyString_AS_STRING($cvar), PyString_GET_SIZE($cvar));");
    858934                return;
    859935        }
     
    861937        if ($actual_ctype->{TYPE} eq "SCALAR" and
    862938                ($actual_ctype->{NAME} eq "string" or $actual_ctype->{NAME} eq "nbt_string" or $actual_ctype->{NAME} eq "nbt_name" or $actual_ctype->{NAME} eq "wrepl_nbt_name")) {
    863                 $self->pidl("$target = talloc_strdup($mem_ctx, PyString_AsString($cvar));");
     939                $self->pidl("$target = talloc_strdup($mem_ctx, PyString_AS_STRING($cvar));");
    864940                return;
    865941        }
    866942
     943        if ($actual_ctype->{TYPE} eq "SCALAR" and ($actual_ctype->{NAME} eq "dns_string" or $actual_ctype->{NAME} eq "dns_name")) {
     944                $self->pidl("$target = talloc_strdup($mem_ctx, PyString_AS_STRING($cvar));");
     945                return;
     946        }
     947
    867948        if ($actual_ctype->{TYPE} eq "SCALAR" and $actual_ctype->{NAME} eq "ipv4address") {
     949                $self->pidl("$target = PyString_AS_STRING($cvar);");
     950                return;
     951        }
     952
     953        if ($actual_ctype->{TYPE} eq "SCALAR" and $actual_ctype->{NAME} eq "ipv6address") {
    868954                $self->pidl("$target = PyString_AsString($cvar);");
    869955                return;
    870                 }
    871 
     956        }
     957
     958        if ($actual_ctype->{TYPE} eq "SCALAR" and $actual_ctype->{NAME} eq "dnsp_name") {
     959                $self->pidl("$target = PyString_AS_STRING($cvar);");
     960                return;
     961        }
     962
     963        if ($actual_ctype->{TYPE} eq "SCALAR" and $actual_ctype->{NAME} eq "dnsp_string") {
     964                $self->pidl("$target = PyString_AS_STRING($cvar);");
     965                return;
     966        }
    872967
    873968        if ($actual_ctype->{TYPE} eq "SCALAR" and $actual_ctype->{NAME} eq "NTSTATUS") {
     
    899994        my ($self, $env, $mem_ctx, $py_var, $e, $l, $var_name, $fail) = @_;
    900995        my $nl = GetNextLevel($e, $l);
     996        if ($nl and $nl->{TYPE} eq "SUBCONTEXT") {
     997                $nl = GetNextLevel($e, $nl);
     998        }
     999        my $pl = GetPrevLevel($e, $l);
     1000        if ($pl and $pl->{TYPE} eq "SUBCONTEXT") {
     1001                $pl = GetPrevLevel($e, $pl);
     1002        }
    9011003
    9021004        if ($l->{TYPE} eq "POINTER") {
    903                 if ($nl->{TYPE} eq "DATA" and Parse::Pidl::Typelist::scalar_is_reference($nl->{DATA_TYPE})) {
    904                         $self->ConvertObjectFromPythonLevel($env, $mem_ctx, $py_var, $e, $nl, $var_name, $fail);
    905                         return;
    906                 }
    9071005                if ($l->{POINTER_TYPE} ne "ref") {
    9081006                        $self->pidl("if ($py_var == Py_None) {");
     
    9131011                        $self->indent;
    9141012                }
    915                 $self->pidl("$var_name = talloc_ptrtype($mem_ctx, $var_name);");
    916                 $self->ConvertObjectFromPythonLevel($env, $mem_ctx, $py_var, $e, $nl, get_value_of($var_name), $fail);
     1013                # if we want to handle more than one level of pointer in python interfaces
     1014                # then this is where we would need to allocate it
     1015                if ($l->{POINTER_TYPE} eq "ref") {
     1016                        $self->pidl("$var_name = talloc_ptrtype($mem_ctx, $var_name);");
     1017                } elsif ($nl->{TYPE} eq "DATA" and Parse::Pidl::Typelist::is_scalar($nl->{DATA_TYPE})
     1018                         and not Parse::Pidl::Typelist::scalar_is_reference($nl->{DATA_TYPE})) {
     1019                        $self->pidl("$var_name = talloc_ptrtype($mem_ctx, $var_name);");
     1020                } else {
     1021                        $self->pidl("$var_name = NULL;");
     1022                }
     1023                unless ($nl->{TYPE} eq "DATA" and Parse::Pidl::Typelist::scalar_is_reference($nl->{DATA_TYPE})) {
     1024                        $var_name = get_value_of($var_name);
     1025                }
     1026                $self->ConvertObjectFromPythonLevel($env, $mem_ctx, $py_var, $e, $nl, $var_name, $fail);
    9171027                if ($l->{POINTER_TYPE} ne "ref") {
    9181028                        $self->deindent;
     
    9201030                }
    9211031        } elsif ($l->{TYPE} eq "ARRAY") {
    922                 my $pl = GetPrevLevel($e, $l);
    9231032                if ($pl && $pl->{TYPE} eq "POINTER") {
    9241033                        $var_name = get_pointer_to($var_name);
     
    9261035
    9271036                if (is_charset_array($e, $l)) {
    928                         $self->pidl("PY_CHECK_TYPE(&PyUnicode_Type, $py_var, $fail);");
     1037                        $self->pidl("if (PyUnicode_Check($py_var)) {");
     1038                        $self->indent;
    9291039                        # FIXME: Use Unix charset setting rather than utf-8
    930                         $self->pidl($var_name . " = PyString_AsString(PyUnicode_AsEncodedString($py_var, \"utf-8\", \"ignore\"));");
     1040                        $self->pidl($var_name . " = PyString_AS_STRING(PyUnicode_AsEncodedString($py_var, \"utf-8\", \"ignore\"));");
     1041                        $self->deindent;
     1042                        $self->pidl("} else if (PyString_Check($py_var)) {");
     1043                        $self->indent;
     1044                        $self->pidl($var_name . " = PyString_AS_STRING($py_var);");
     1045                        $self->deindent;
     1046                        $self->pidl("} else {");
     1047                        $self->indent;
     1048                        $self->pidl("PyErr_Format(PyExc_TypeError, \"Expected string or unicode object, got %s\", Py_TYPE($py_var)->tp_name);");
     1049                        $self->pidl("$fail");
     1050                        $self->deindent;
     1051                        $self->pidl("}");
    9311052                } else {
    9321053                        my $counter = "$e->{NAME}_cntr_$l->{LEVEL_INDEX}";
     
    9361057                        $self->pidl("int $counter;");
    9371058                        if (ArrayDynamicallyAllocated($e, $l)) {
    938                                 $self->pidl("$var_name = talloc_array_ptrtype($mem_ctx, $var_name, PyList_Size($py_var));");
     1059                                $self->pidl("$var_name = talloc_array_ptrtype($mem_ctx, $var_name, PyList_GET_SIZE($py_var));");
     1060                                $self->pidl("if (!$var_name) { $fail; }");
     1061                                $self->pidl("talloc_set_name_const($var_name, \"ARRAY: $var_name\");");
    9391062                        }
    940                         $self->pidl("for ($counter = 0; $counter < PyList_Size($py_var); $counter++) {");
    941                         $self->indent;
    942                         $self->ConvertObjectFromPythonLevel($env, $var_name, "PyList_GetItem($py_var, $counter)", $e, GetNextLevel($e, $l), $var_name."[$counter]", $fail);
     1063                        $self->pidl("for ($counter = 0; $counter < PyList_GET_SIZE($py_var); $counter++) {");
     1064                        $self->indent;
     1065                        $self->ConvertObjectFromPythonLevel($env, $var_name, "PyList_GET_ITEM($py_var, $counter)", $e, $nl, $var_name."[$counter]", $fail);
    9431066                        $self->deindent;
    9441067                        $self->pidl("}");
     
    9471070                }
    9481071        } elsif ($l->{TYPE} eq "DATA") {
    949 
    9501072                if (not Parse::Pidl::Typelist::is_scalar($l->{DATA_TYPE})) {
    9511073                        $var_name = get_pointer_to($var_name);
     
    9551077                $var_name = get_pointer_to($var_name);
    9561078                my $switch = ParseExpr($l->{SWITCH_IS}, $env, $e);
    957                 $self->assign($var_name, "py_export_" . GetNextLevel($e, $l)->{DATA_TYPE} . "($mem_ctx, $switch, $py_var)");
     1079                my $switch_ptr = "$e->{NAME}_switch_$l->{LEVEL_INDEX}";
     1080                $self->pidl("{");
     1081                $self->indent;
     1082                my $union_type = mapTypeName($nl->{DATA_TYPE});
     1083                $self->pidl("$union_type *$switch_ptr;");
     1084                $self->pidl("$switch_ptr = py_export_" . $nl->{DATA_TYPE} . "($mem_ctx, $switch, $py_var);");
     1085                $self->fail_on_null($switch_ptr, $fail);
     1086                $self->assign($var_name, "$switch_ptr");
     1087                $self->deindent;
     1088                $self->pidl("}");
    9581089        } elsif ($l->{TYPE} eq "SUBCONTEXT") {
    959                 $self->ConvertObjectFromPythonLevel($env, $mem_ctx, $py_var, $e, GetNextLevel($e, $l), $var_name, $fail);
     1090                $self->ConvertObjectFromPythonLevel($env, $mem_ctx, $py_var, $e, $nl, $var_name, $fail);
    9601091        } else {
    9611092                fatal($e->{ORIGINAL}, "unknown level type $l->{TYPE}");
     
    9781109        $ctypename = expandAlias($ctypename);
    9791110
    980         if ($ctypename =~ /^(char|u?int[0-9]*|hyper|dlong|udlong|udlongr|time_t|NTTIME_hyper|NTTIME|NTTIME_1sec)$/) {
     1111        if ($ctypename =~ /^(u?int64|hyper|dlong|udlong|udlongr|NTTIME_hyper|NTTIME|NTTIME_1sec)$/) {
     1112                return "PyLong_FromLongLong($cvar)";
     1113        }
     1114
     1115        if ($ctypename =~ /^(char|u?int[0-9]*|time_t|uid_t|gid_t)$/) {
    9811116                return "PyInt_FromLong($cvar)";
    9821117        }
     
    9951130
    9961131        if (($ctypename eq "string" or $ctypename eq "nbt_string" or $ctypename eq "nbt_name" or $ctypename eq "wrepl_nbt_name")) {
    997                 return "PyString_FromString($cvar)";
     1132                return "PyString_FromStringOrNULL($cvar)";
     1133        }
     1134
     1135        if (($ctypename eq "dns_string" or $ctypename eq "dns_name")) {
     1136                return "PyString_FromStringOrNULL($cvar)";
    9981137        }
    9991138
    10001139        # Not yet supported
    10011140        if ($ctypename eq "string_array") { return "PyCObject_FromTallocPtr($cvar)"; }
    1002         if ($ctypename eq "ipv4address") { return "PyString_FromString($cvar)"; }
     1141        if ($ctypename eq "ipv4address") { return "PyString_FromStringOrNULL($cvar)"; }
     1142        if ($ctypename eq "ipv6address") { return "PyString_FromStringOrNULL($cvar)"; }
     1143        if ($ctypename eq "dnsp_name") { return "PyString_FromStringOrNULL($cvar)"; }
     1144        if ($ctypename eq "dnsp_string") { return "PyString_FromStringOrNULL($cvar)"; }
    10031145        if ($ctypename eq "pointer") {
    10041146                return "PyCObject_FromTallocPtr($cvar)";
     
    10551197        my ($self, $mem_ctx, $env, $e, $l, $var_name, $py_var, $fail) = @_;
    10561198        my $nl = GetNextLevel($e, $l);
     1199        if ($nl and $nl->{TYPE} eq "SUBCONTEXT") {
     1200                $nl = GetNextLevel($e, $nl);
     1201        }
     1202        my $pl = GetPrevLevel($e, $l);
     1203        if ($pl and $pl->{TYPE} eq "SUBCONTEXT") {
     1204                $pl = GetPrevLevel($e, $pl);
     1205        }
    10571206
    10581207        if ($l->{TYPE} eq "POINTER") {
    1059                 if ($nl->{TYPE} eq "DATA" and Parse::Pidl::Typelist::scalar_is_reference($nl->{DATA_TYPE})) {
    1060                         $self->ConvertObjectToPythonLevel($var_name, $env, $e, $nl, $var_name, $py_var, $fail);
    1061                         return;
    1062                 }
    10631208                if ($l->{POINTER_TYPE} ne "ref") {
    10641209                        $self->pidl("if ($var_name == NULL) {");
    10651210                        $self->indent;
    10661211                        $self->pidl("$py_var = Py_None;");
     1212                        $self->pidl("Py_INCREF($py_var);");
    10671213                        $self->deindent;
    10681214                        $self->pidl("} else {");
    10691215                        $self->indent;
    10701216                }
    1071                 $self->ConvertObjectToPythonLevel($var_name, $env, $e, $nl, get_value_of($var_name), $py_var, $fail);
     1217                my $var_name2 = $var_name;
     1218                unless ($nl->{TYPE} eq "DATA" and Parse::Pidl::Typelist::scalar_is_reference($nl->{DATA_TYPE})) {
     1219                        $var_name2 = get_value_of($var_name);
     1220                }
     1221                $self->ConvertObjectToPythonLevel($var_name, $env, $e, $nl, $var_name2, $py_var, $fail);
    10721222                if ($l->{POINTER_TYPE} ne "ref") {
    10731223                        $self->deindent;
     
    10751225                }
    10761226        } elsif ($l->{TYPE} eq "ARRAY") {
    1077                 my $pl = GetPrevLevel($e, $l);
    10781227                if ($pl && $pl->{TYPE} eq "POINTER") {
    10791228                        $var_name = get_pointer_to($var_name);
     
    10821231                if (is_charset_array($e, $l)) {
    10831232                        # FIXME: Use Unix charset setting rather than utf-8
     1233                        $self->pidl("if ($var_name == NULL) {");
     1234                        $self->indent;
     1235                        $self->pidl("$py_var = Py_None;");
     1236                        $self->pidl("Py_INCREF($py_var);");
     1237                        $self->deindent;
     1238                        $self->pidl("} else {");
     1239                        $self->indent;
    10841240                        $self->pidl("$py_var = PyUnicode_Decode($var_name, strlen($var_name), \"utf-8\", \"ignore\");");
     1241                        $self->deindent;
     1242                        $self->pidl("}");
    10851243                } else {
    10861244                        die("No SIZE_IS for array $var_name") unless (defined($l->{SIZE_IS}));
     
    11011259                        my $member_var = "py_$e->{NAME}_$l->{LEVEL_INDEX}";
    11021260                        $self->pidl("PyObject *$member_var;");
    1103                         $self->ConvertObjectToPythonLevel($var_name, $env, $e, GetNextLevel($e, $l), $var_name."[$counter]", $member_var, $fail);
     1261                        $self->ConvertObjectToPythonLevel($var_name, $env, $e, $nl, $var_name."[$counter]", $member_var, $fail);
    11041262                        $self->pidl("PyList_SetItem($py_var, $counter, $member_var);");
    11051263                        $self->deindent;
     
    11111269                $var_name = get_pointer_to($var_name);
    11121270                my $switch = ParseExpr($l->{SWITCH_IS}, $env, $e);
    1113                 $self->pidl("$py_var = py_import_" . GetNextLevel($e, $l)->{DATA_TYPE} . "($mem_ctx, $switch, $var_name);");
     1271                $self->pidl("$py_var = py_import_" . $nl->{DATA_TYPE} . "($mem_ctx, $switch, $var_name);");
    11141272                $self->fail_on_null($py_var, $fail);
    11151273
     
    11211279                $self->pidl("$py_var = $conv;");
    11221280        } elsif ($l->{TYPE} eq "SUBCONTEXT") {
    1123                 $self->ConvertObjectToPythonLevel($mem_ctx, $env, $e, GetNextLevel($e, $l), $var_name, $py_var, $fail);
     1281                $self->ConvertObjectToPythonLevel($mem_ctx, $env, $e, $nl, $var_name, $py_var, $fail);
    11241282        } else {
    11251283                fatal($e->{ORIGINAL}, "Unknown level type $l->{TYPE} $var_name");
     
    11421300    $self->pidl_hdr("
    11431301/* Python wrapper functions auto-generated by pidl */
     1302#include <Python.h>
    11441303#include \"includes.h\"
    1145 #include <Python.h>
    1146 #include \"librpc/rpc/dcerpc.h\"
    1147 #include \"lib/talloc/pytalloc.h\"
     1304#include <pytalloc.h>
    11481305#include \"librpc/rpc/pyrpc.h\"
     1306#include \"librpc/rpc/pyrpc_util.h\"
    11491307#include \"$hdr\"
    11501308#include \"$ndr_hdr\"
    1151 
    1152 #ifndef Py_RETURN_NONE
    1153 #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
    1154 #endif
    11551309
    11561310");
     
    11741328        $self->pidl("");
    11751329
     1330        $self->pidl_hdr("void init$basename(void);");
    11761331        $self->pidl("void init$basename(void)");
    11771332        $self->pidl("{");
    11781333        $self->indent;
    11791334        $self->pidl("PyObject *m;");
    1180         foreach (@{$self->{module_imports}}) {
    1181                 $self->pidl("PyObject *dep_$_;");
    1182         }
    1183         $self->pidl("");
    1184 
    1185         foreach (@{$self->{module_imports}}) {
    1186                 $self->pidl("dep_$_ = PyImport_ImportModule(\"samba.dcerpc.$_\");");
    1187                 $self->pidl("if (dep_$_ == NULL)");
     1335        foreach (keys %{$self->{module_imports}}) {
     1336                $self->pidl("PyObject *$_;");
     1337        }
     1338        $self->pidl("");
     1339
     1340        foreach (keys %{$self->{module_imports}}) {
     1341                my $var_name = $_;
     1342                my $module_path = $self->{module_imports}->{$var_name};
     1343                $self->pidl("$var_name = PyImport_ImportModule(\"$module_path\");");
     1344                $self->pidl("if ($var_name == NULL)");
    11881345                $self->pidl("\treturn;");
    11891346                $self->pidl("");
     
    11911348
    11921349        foreach (keys %{$self->{type_imports}}) {
    1193                 my $basefile = $self->{type_imports}->{$_};
    1194                 $self->pidl_hdr("static PyTypeObject *$_\_Type;\n");
    1195                 my $pretty_name = PrettifyTypeName($_, $basefile);
    1196                 $self->pidl("$_\_Type = (PyTypeObject *)PyObject_GetAttrString(dep_$basefile, \"$pretty_name\");");
    1197                 $self->pidl("if ($_\_Type == NULL)");
     1350                my $type_var = "$_\_Type";
     1351                my $module_path = $self->{type_imports}->{$_};
     1352                $self->pidl_hdr("static PyTypeObject *$type_var;\n");
     1353                my $pretty_name = PrettifyTypeName($_, $module_path);
     1354                my $module_var = "dep_$module_path";
     1355                $module_var =~ s/\./_/g;
     1356                $self->pidl("$type_var = (PyTypeObject *)PyObject_GetAttrString($module_var, \"$pretty_name\");");
     1357                $self->pidl("if ($type_var == NULL)");
    11981358                $self->pidl("\treturn;");
    11991359                $self->pidl("");
    12001360        }
     1361
     1362        $self->pidl($_) foreach (@{$self->{prereadycode}});
    12011363
    12021364        foreach (@{$self->{ready_types}}) {
     
    12051367        }
    12061368
    1207         $self->pidl($_) foreach (@{$self->{readycode}});
     1369        $self->pidl($_) foreach (@{$self->{postreadycode}});
    12081370
    12091371        foreach (@{$self->{patch_type_calls}}) {
  • vendor/current/pidl/lib/Parse/Pidl/Typelist.pm

    r414 r740  
    99@ISA = qw(Exporter);
    1010@EXPORT_OK = qw(hasType getType resolveType mapTypeName scalar_is_reference expandAlias
    11                             mapScalarType addType typeIs is_signed is_scalar enum_type_fn
    12                                 bitmap_type_fn mapType typeHasBody
     11        mapScalarType addType typeIs is_signed is_scalar enum_type_fn
     12        bitmap_type_fn mapType typeHasBody is_fixed_size_scalar
    1313);
    1414use vars qw($VERSION);
     
    2121
    2222my @reference_scalars = (
    23         "string", "string_array", "nbt_string",
    24         "wrepl_nbt_name", "ipv4address"
     23        "string", "string_array", "nbt_string", "dns_string",
     24        "wrepl_nbt_name", "dnsp_name", "dnsp_string",
     25        "ipv4address", "ipv6address"
     26);
     27
     28my @non_fixed_size_scalars = (
     29        "string", "string_array", "nbt_string", "dns_string",
     30        "wrepl_nbt_name", "dnsp_name", "dnsp_string"
    2531);
    2632
     
    3743        "int32"         => "int32_t",
    3844        "uint32"        => "uint32_t",
     45        "int3264"       => "int32_t",
     46        "uint3264"      => "uint32_t",
    3947        "hyper"         => "uint64_t",
    4048        "dlong"         => "int64_t",
     
    4755        "string_array"  => "const char **",
    4856        "time_t"        => "time_t",
     57        "uid_t"         => "uid_t",
     58        "gid_t"         => "gid_t",
    4959        "NTTIME"        => "NTTIME",
    5060        "NTTIME_1sec"   => "NTTIME",
     
    5363        "NTSTATUS"      => "NTSTATUS",
    5464        "COMRESULT" => "COMRESULT",
     65        "dns_string"    => "const char *",
    5566        "nbt_string"    => "const char *",
    5667        "wrepl_nbt_name"=> "struct nbt_name *",
    5768        "ipv4address"   => "const char *",
     69        "ipv6address"   => "const char *",
     70        "dnsp_name"     => "const char *",
     71        "dnsp_string"   => "const char *",
    5872);
    5973
     
    123137}
    124138
     139sub typeIs($$);
    125140sub typeIs($$)
    126141{
    127142        my ($t,$tt) = @_;
    128        
     143
    129144        if (ref($t) eq "HASH") {
     145                return 1 if ($t->{TYPE} eq "TYPEDEF" and $t->{DATA}->{TYPE} eq $tt);
    130146                return 1 if ($t->{TYPE} eq $tt);
    131147                return 0;
    132148        }
    133         return 1 if (hasType($t) and getType($t)->{TYPE} eq "TYPEDEF" and
    134                          getType($t)->{DATA}->{TYPE} eq $tt);
     149        if (hasType($t) and getType($t)->{TYPE} eq "TYPEDEF") {
     150                return typeIs(getType($t)->{DATA}, $tt);
     151         }
    135152        return 0;
    136153}
     
    178195
    179196        return 0;
     197}
     198
     199sub is_fixed_size_scalar($)
     200{
     201        my $name = shift;
     202
     203        return 0 unless is_scalar($name);
     204        return 0 if (grep(/^$name$/, @non_fixed_size_scalars));
     205        return 1;
    180206}
    181207
     
    266292        return "union $n" if ($t->{TYPE} eq "UNION");
    267293        return mapScalarType(bitmap_type_fn($t)) if ($t->{TYPE} eq "BITMAP");
     294        return "struct $n" if ($t->{TYPE} eq "PIPE");
    268295        die("Unknown type $t->{TYPE}");
    269296}
     
    304331
    305332                foreach my $y (@{$x->{DATA}}) {
    306                         if ($y->{TYPE} eq "TYPEDEF"
    307                                 or $y->{TYPE} eq "UNION"
    308                                 or $y->{TYPE} eq "STRUCT"
    309                         or $y->{TYPE} eq "ENUM"
    310                         or $y->{TYPE} eq "BITMAP") {
     333                        if ($y->{TYPE} eq "TYPEDEF"
     334                            or $y->{TYPE} eq "UNION"
     335                            or $y->{TYPE} eq "STRUCT"
     336                            or $y->{TYPE} eq "ENUM"
     337                            or $y->{TYPE} eq "BITMAP"
     338                            or $y->{TYPE} eq "PIPE") {
    311339                                $y->{BASEFILE} = $basename;
    312340                                addType($y);
  • vendor/current/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm

    r414 r740  
    111111use Parse::Pidl qw(fatal warning error);
    112112use Parse::Pidl::Util qw(has_property);
     113use Parse::Pidl::Typelist qw(addType);
    113114
    114115sub handle_type($$$$$$$$$$)
     
    150151                ALIGNMENT => $alignment
    151152        };
     153
     154        addType({
     155                NAME => $name,
     156                TYPE => "CONFORMANCE",
     157                BASEFILE => "conformance file",
     158                DATA => {
     159                        NAME => $name,
     160                        TYPE => "CONFORMANCE",
     161                        ALIGN => $alignment
     162                }
     163        });
    152164}
    153165
  • vendor/current/pidl/lib/Parse/Pidl/Wireshark/NDR.pm

    r414 r740  
    11##################################################
    2 # Samba4 NDR parser generator for IDL structures
     2# Wireshark NDR parser generator for IDL structures
    33# Copyright tridge@samba.org 2000-2003
    44# Copyright tpot@samba.org 2001,2005
     
    546546        $self->pidl_code("proto_item *item = NULL;");
    547547        $self->pidl_code("proto_tree *tree = NULL;");
     548        if ($e->{ALIGN} > 1) {
     549                $self->pidl_code("dcerpc_info *di = pinfo->private_data;");
     550        }
    548551        $self->pidl_code("int old_offset;");
    549552        $self->pidl_code("");
     
    566569
    567570        $self->pidl_code("proto_item_set_len(item, offset-old_offset);\n");
     571        if ($e->{ALIGN} > 1) {
     572                $self->pidl_code("");
     573                $self->pidl_code("if (di->call_data->flags & DCERPC_IS_NDR64) {");
     574                $self->indent;
     575                $self->pidl_code("ALIGN_TO_$e->{ALIGN}_BYTES;");
     576                $self->deindent;
     577                $self->pidl_code("}");
     578        }
     579        $self->pidl_code("");
    568580        $self->pidl_code("return offset;");
    569581        $self->deindent;
     
    635647        $self->pidl_code("switch(level) {$res\t}");
    636648        $self->pidl_code("proto_item_set_len(item, offset-old_offset);\n");
     649        $self->pidl_code("");
     650
    637651        $self->pidl_code("return offset;");
    638652        $self->deindent;
     
    873887        $self->register_type("GUID", "offset = dissect_ndr_uuid_t(tvb, offset, pinfo, tree, drep, \@HF\@, NULL);","FT_GUID", "BASE_NONE", 0, "NULL", 4);
    874888        $self->register_type("policy_handle", "offset = PIDL_dissect_policy_hnd(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);","FT_BYTES", "BASE_NONE", 0, "NULL", 4);
    875         $self->register_type("NTTIME", "offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep, \@HF\@);","FT_ABSOLUTE_TIME", "BASE_NONE", 0, "NULL", 4);
    876         $self->register_type("NTTIME_hyper", "offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep, \@HF\@);","FT_ABSOLUTE_TIME", "BASE_NONE", 0, "NULL", 4);
    877         $self->register_type("time_t", "offset = dissect_ndr_time_t(tvb, offset, pinfo,tree, drep, \@HF\@, NULL);","FT_ABSOLUTE_TIME", "BASE_NONE", 0, "NULL", 4);
    878         $self->register_type("NTTIME_1sec", "offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep, \@HF\@);", "FT_ABSOLUTE_TIME", "BASE_NONE", 0, "NULL", 4);
     889        $self->register_type("NTTIME", "offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep, \@HF\@);","FT_ABSOLUTE_TIME", "ABSOLUTE_TIME_LOCAL", 0, "NULL", 4);
     890        $self->register_type("NTTIME_hyper", "offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep, \@HF\@);","FT_ABSOLUTE_TIME", "ABSOLUTE_TIME_LOCAL", 0, "NULL", 4);
     891        $self->register_type("time_t", "offset = dissect_ndr_time_t(tvb, offset, pinfo,tree, drep, \@HF\@, NULL);","FT_ABSOLUTE_TIME", "ABSOLUTE_TIME_LOCAL", 0, "NULL", 4);
     892        $self->register_type("NTTIME_1sec", "offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep, \@HF\@);", "FT_ABSOLUTE_TIME", "ABSOLUTE_TIME_LOCAL", 0, "NULL", 4);
    879893        $self->register_type("SID", "
    880894                dcerpc_info *di = (dcerpc_info *)pinfo->private_data;
     
    896910{
    897911        my($self,$ndr,$idl_file,$h_filename,$cnf_file) = @_;
    898        
     912
    899913        $self->Initialize($cnf_file);
    900914
  • vendor/current/pidl/pidl

    r414 r740  
    1 #!/usr/bin/perl -w
     1#!/usr/bin/env perl
    22
    33###################################################
     
    654654        $pidl = Parse::Pidl::ODL::ODL2IDL($pidl, dirname($idl_file), \@opt_incdirs);
    655655
    656         if (defined($opt_ws_parser) or
     656        if (defined($opt_ws_parser)) {
     657          require Parse::Pidl::Wireshark::NDR;
     658
     659          my $cnffile = $idl_file;
     660          $cnffile =~ s/\.idl$/\.cnf/;
     661
     662          my $generator = new Parse::Pidl::Wireshark::NDR();
     663          $generator->Initialize($cnffile);
     664        }
     665
     666
     667        if (defined($opt_ws_parser) or
    657668            defined($opt_client) or
    658669            defined($opt_server) or
     
    682693
    683694        my $h_filename = "$outputdir/ndr_$basename.h";
    684         if (defined($opt_client)) {
     695        my $c_header = "$outputdir/ndr_$basename\_c.h";
     696        if (defined($opt_client) or defined($opt_samba3_ndr_client)) {
    685697                require Parse::Pidl::Samba4::NDR::Client;
    686698                my ($c_client) = ($opt_client or "$outputdir/ndr_$basename\_c.c");
    687                 my ($c_header) = $c_client;
     699                $c_header = $c_client;
    688700                $c_header =~ s/\.c$/.h/;
    689701
    690                 my ($srcd,$hdrd) = Parse::Pidl::Samba4::NDR::Client::Parse(
     702                my $generator = new Parse::Pidl::Samba4::NDR::Client();
     703                my ($srcd,$hdrd) = $generator->Parse(
    691704                        $ndr,$gen_header,$h_filename,$c_header);
    692705
     
    761774                require Parse::Pidl::Samba3::ClientNDR;
    762775                my $generator = new Parse::Pidl::Samba3::ClientNDR();
    763                 my ($c_code,$h_code) = $generator->Parse($ndr, $header, $h_filename);
     776                my ($c_code,$h_code) = $generator->Parse($ndr, $header, $c_header);
    764777                FileSave($client, $c_code);
    765778                FileSave($header, $h_code);
  • vendor/current/pidl/tests/Util.pm

    r414 r740  
    7777
    7878        my $main = "
    79 #define uint_t unsigned int
    8079#include <stdint.h>
    8180#include <stdlib.h>
  • vendor/current/pidl/tests/ndr.pl

    r414 r740  
    2323        'LINE' => 42 };
    2424
    25 is_deeply(GetElementLevelTable($e, "unique"), [
     25is_deeply(GetElementLevelTable($e, "unique", 0), [
    2626        {
    2727                'IS_DEFERRED' => 0,
     
    3434]);
    3535
    36 my $ne = ParseElement($e, "unique");
     36my $ne = ParseElement($e, "unique", 0);
    3737is($ne->{ORIGINAL}, $e);
    3838is($ne->{NAME}, "v");
     
    6161        'LINE' => 42 };
    6262
    63 is_deeply(GetElementLevelTable($e, "unique"), [
     63is_deeply(GetElementLevelTable($e, "unique", 0), [
    6464        {
    6565                LEVEL_INDEX => 0,
     
    9191        'LINE' => 42 };
    9292
    93 is_deeply(GetElementLevelTable($e, "unique"), [
     93is_deeply(GetElementLevelTable($e, "unique", 0), [
    9494        {
    9595                LEVEL_INDEX => 0,
     
    129129        'LINE' => 42 };
    130130
    131 is_deeply(GetElementLevelTable($e, "unique"), [
     131is_deeply(GetElementLevelTable($e, "unique", 0), [
    132132        {
    133133                LEVEL_INDEX => 0,
     
    159159        'LINE' => 42 };
    160160
    161 is_deeply(GetElementLevelTable($e, "unique"), [
     161is_deeply(GetElementLevelTable($e, "unique", 0), [
    162162        {
    163163                LEVEL_INDEX => 0,
     
    205205        'LINE' => 42 };
    206206
    207 is_deeply(GetElementLevelTable($e, "ref"), [
     207is_deeply(GetElementLevelTable($e, "ref", 0), [
    208208        {
    209209                LEVEL_INDEX => 0,
     
    251251        'LINE' => 42 };
    252252
    253 is_deeply(GetElementLevelTable($e, "unique"), [
     253is_deeply(GetElementLevelTable($e, "unique", 0), [
    254254        {
    255255                LEVEL_INDEX => 0,
     
    281281        'LINE' => 42 };
    282282
    283 is_deeply(GetElementLevelTable($e, "unique"), [
     283is_deeply(GetElementLevelTable($e, "unique", 0), [
    284284        {
    285285                LEVEL_INDEX => 0,
     
    327327        'LINE' => 42 };
    328328
    329 is_deeply(GetElementLevelTable($e, "unique"), [
     329is_deeply(GetElementLevelTable($e, "unique", 0), [
    330330        {
    331331                LEVEL_INDEX => 0,
     
    373373        'LINE' => 42 };
    374374
    375 is_deeply(GetElementLevelTable($e, "ref"), [
     375is_deeply(GetElementLevelTable($e, "ref", 0), [
    376376        {
    377377                LEVEL_INDEX => 0,
     
    419419        'LINE' => 42 };
    420420
    421 is_deeply(GetElementLevelTable($e, "ref"), [
     421is_deeply(GetElementLevelTable($e, "ref", 0), [
    422422        {
    423423                LEVEL_INDEX => 0,
     
    464464        'LINE' => 42 };
    465465
    466 $ne = ParseElement($e, undef);
     466$ne = ParseElement($e, undef, 0);
    467467is($ne->{REPRESENTATION_TYPE}, "bar");
    468468
     
    477477        'LINE' => 42 };
    478478
    479 $ne = ParseElement($e, undef);
     479$ne = ParseElement($e, undef, 0);
    480480is($ne->{REPRESENTATION_TYPE}, "uint8");
    481481
     
    522522        ALIGN => undef
    523523};
    524 is_deeply(ParseType($t->{ORIGINAL}, "ref"), $t);
     524is_deeply(ParseType($t->{ORIGINAL}, "ref", 0), $t);
    525525
    526526$t = {
     
    531531        PROPERTIES => undef,
    532532        HAS_DEFAULT => 0,
     533        IS_MS_UNION => 0,
    533534        ORIGINAL => {
    534535                TYPE => "UNION",
    535536                NAME => "foo"
    536         }
     537        },
     538        ALIGN => undef
    537539};
    538 is_deeply(ParseType($t->{ORIGINAL}, "ref"), $t);
     540is_deeply(ParseType($t->{ORIGINAL}, "ref", 0), $t);
    539541
    540542ok(not can_contain_deferred("uint32"));
     
    553555                ELEMENTS => [ { TYPE => "someunknowntype" } ]}));
    554556# Make sure the elements for a enum without body aren't filled in
    555 ok(not defined(ParseType({TYPE => "ENUM", NAME => "foo" }, "ref")->{ELEMENTS}));
     557ok(not defined(ParseType({TYPE => "ENUM", NAME => "foo" }, "ref", 0)->{ELEMENTS}));
    556558# Make sure the elements for a bitmap without body aren't filled in
    557 ok(not defined(ParseType({TYPE => "BITMAP", NAME => "foo" }, "ref")->{ELEMENTS}));
     559ok(not defined(ParseType({TYPE => "BITMAP", NAME => "foo" }, "ref", 0)->{ELEMENTS}));
    558560# Make sure the elements for a union without body aren't filled in
    559 ok(not defined(ParseType({TYPE => "UNION", NAME => "foo" }, "ref")->{ELEMENTS}));
     561ok(not defined(ParseType({TYPE => "UNION", NAME => "foo" }, "ref", 0)->{ELEMENTS}));
  • vendor/current/pidl/tests/ndr_string.pl

    r414 r740  
    1515        uint8_t data[] = { 0x00, 0x00, 0x00, 0x00 };
    1616        DATA_BLOB b = { data, 4 };
    17         struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL,
    18                 smb_iconv_convenience_init(NULL, "ASCII", "UTF8", true));
     17        struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
    1918        struct TestString r;
    2019        r.in.data = NULL;
     
    3837                                           \'f\', \'o\', \'o\', 0 };
    3938        DATA_BLOB b = { data, 8 };
    40         struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL,
    41                 smb_iconv_convenience_init(NULL, "ASCII", "UTF8", true));
     39        struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
    4240        struct TestString r;
    4341        r.in.data = NULL;
     
    7573        };
    7674        DATA_BLOB b = { data, sizeof(data) };
    77         struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL,
    78                 smb_iconv_convenience_init(NULL, "ASCII", "UTF8", true));
     75        struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
    7976        struct TestString r;
    8077        struct TestStringStruct str;
     
    121118        };
    122119        DATA_BLOB b = { data, sizeof(data) };
    123         struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL,
    124                 smb_iconv_convenience_init(NULL, "ASCII", "UTF8", true));
     120        struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
    125121        struct TestString r;
    126122        struct TestStringStruct str;
     
    153149        };
    154150        DATA_BLOB b = { data, sizeof(data) };
    155         struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL,
    156                 smb_iconv_convenience_init(NULL, "ASCII", "UTF8", true));
     151        struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
    157152        struct TestString r;
    158153        struct TestStringStruct str;
     
    175170                                           \'f\', \'o\', \'o\', 0 };
    176171        DATA_BLOB b = { data, 8 };
    177         struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL,
    178                 smb_iconv_convenience_init(NULL, "ASCII", "UTF8", true));
     172        struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
    179173        struct TestString r;
    180174        char *str = NULL;
  • vendor/current/pidl/tests/parse_idl.pl

    r414 r740  
    159159                'TYPE' => 'TYPEDEF',
    160160                'NAME' => 'y',
     161                'POINTERS' => 0,
    161162                'DATA' => {
    162163                        'TYPE' => 'STRUCT',
     
    181182                'TYPE' => 'TYPEDEF',
    182183                'NAME' => 'y',
     184                'POINTERS' => 0,
    183185                'DATA' => {
    184186                        'TYPE' => 'STRUCT',
     
    203205                'TYPE' => 'TYPEDEF',
    204206                'NAME' => 'y',
     207                'POINTERS' => 0,
    205208                'DATA' => {
    206209                        'TYPE' => 'BITMAP',
     
    226229                'TYPE' => 'TYPEDEF',
    227230                'NAME' => 'y',
     231                'POINTERS' => 0,
    228232                'DATA' => {
    229233                        'TYPE' => 'UNION',
  • vendor/current/pidl/tests/samba-ndr.pl

    r414 r740  
    224224is($generator->{res}, "if (ndr_flags & NDR_SCALARS) {
    225225        NDR_CHECK(ndr_push_align(ndr, 4));
     226        NDR_CHECK(ndr_push_trailer_align(ndr, 4));
    226227}
    227228if (ndr_flags & NDR_BUFFERS) {
     
    249250        NDR_CHECK(ndr_push_align(ndr, 4));
    250251        NDR_CHECK(ndr_push_mytype(ndr, NDR_SCALARS, &x->el1));
     252        NDR_CHECK(ndr_push_trailer_align(ndr, 4));
    251253}
    252254if (ndr_flags & NDR_BUFFERS) {
  • vendor/current/pidl/tests/samba3-cli.pl

    r414 r740  
    55use warnings;
    66
    7 use Test::More tests => 9;
     7use Test::More tests => 8;
    88use FindBin qw($RealBin);
    99use lib "$RealBin";
    1010use Util;
    1111use Parse::Pidl::Util qw(MyDumper);
    12 use Parse::Pidl::Samba3::ClientNDR qw(ParseFunction ParseOutputArgument);
     12use Parse::Pidl::Samba3::ClientNDR qw(ParseFunction);
    1313use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv GenerateFunctionOutEnv);
    1414
     
    3232is($x->{res},
    3333"struct rpccli_bar_state {
    34         struct bar orig;
    35         struct bar tmp;
    3634        TALLOC_CTX *out_mem_ctx;
    37         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
    3835};
    3936
     
    5451        }
    5552        state->out_mem_ctx = NULL;
    56         state->dispatch_recv = cli->dispatch_recv;
    57 
    58         /* In parameters */
    59 
    60         /* Out parameters */
    61 
    62         if (DEBUGLEVEL >= 10) {
    63                 NDR_PRINT_IN_DEBUG(bar, &state->orig);
    64         }
    65 
    66         /* make a temporary copy, that we pass to the dispatch function */
    67         state->tmp = state->orig;
    68 
    69         subreq = cli->dispatch_send(state, ev, cli,
    70                                     &ndr_table_foo,
    71                                     NDR_BAR,
    72                                     &state->tmp);
     53
     54        subreq = dcerpc_bar_send(state,
     55                                 ev,
     56                                 cli->binding_handle);
    7357        if (tevent_req_nomem(subreq, req)) {
    7458                return tevent_req_post(req, ev);
     
    9377        }
    9478
    95         status = state->dispatch_recv(subreq, mem_ctx);
     79        status = dcerpc_bar_recv(subreq,
     80                                 mem_ctx);
    9681        TALLOC_FREE(subreq);
    9782        if (!NT_STATUS_IS_OK(status)) {
     
    10085        }
    10186
    102         /* Copy out parameters */
    103 
    104         /* Reset temporary structure */
    105         ZERO_STRUCT(state->tmp);
    106 
    107         if (DEBUGLEVEL >= 10) {
    108                 NDR_PRINT_OUT_DEBUG(bar, &state->orig);
    109         }
    110 
    11187        tevent_req_done(req);
    11288}
     
    124100        }
    125101
    126         /* Steal possbile out parameters to the callers context */
     102        /* Steal possible out parameters to the callers context */
    127103        talloc_steal(mem_ctx, state->out_mem_ctx);
    128104
     
    134110                    TALLOC_CTX *mem_ctx)
    135111{
    136 \tstruct bar r;
    137 \tNTSTATUS status;
    138 
    139 \t/* In parameters */
    140 
    141 \tif (DEBUGLEVEL >= 10) {
    142 \t\tNDR_PRINT_IN_DEBUG(bar, &r);
    143 \t}
    144 
    145         status = cli->dispatch(cli,
    146                                 mem_ctx,
    147                                 &ndr_table_foo,
    148                                 NDR_BAR,
    149                                 &r);
    150 
    151 \tif (!NT_STATUS_IS_OK(status)) {
    152 \t\treturn status;
    153 \t}
    154 
    155 \tif (DEBUGLEVEL >= 10) {
    156 \t\tNDR_PRINT_OUT_DEBUG(bar, &r);
    157 \t}
    158 
    159 \tif (NT_STATUS_IS_ERR(status)) {
    160 \t\treturn status;
    161 \t}
    162 
    163 \t/* Return variables */
    164 
    165 \t/* Return result */
    166 \treturn NT_STATUS_OK;
     112        NTSTATUS status;
     113
     114        status = dcerpc_bar(cli->binding_handle,
     115                            mem_ctx);
     116        if (!NT_STATUS_IS_OK(status)) {
     117                return status;
     118        }
     119
     120        /* Return result */
     121        return NT_STATUS_OK;
    167122}
    168123
     
    175130is($x->{res},
    176131"struct rpccli_bar_state {
    177         struct bar orig;
    178         struct bar tmp;
    179132        TALLOC_CTX *out_mem_ctx;
    180         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
     133        WERROR result;
    181134};
    182135
     
    197150        }
    198151        state->out_mem_ctx = NULL;
    199         state->dispatch_recv = cli->dispatch_recv;
    200 
    201         /* In parameters */
    202 
    203         /* Out parameters */
    204 
    205         /* Result */
    206         ZERO_STRUCT(state->orig.out.result);
    207 
    208         if (DEBUGLEVEL >= 10) {
    209                 NDR_PRINT_IN_DEBUG(bar, &state->orig);
    210         }
    211 
    212         /* make a temporary copy, that we pass to the dispatch function */
    213         state->tmp = state->orig;
    214 
    215         subreq = cli->dispatch_send(state, ev, cli,
    216                                     &ndr_table_foo,
    217                                     NDR_BAR,
    218                                     &state->tmp);
     152
     153        subreq = dcerpc_bar_send(state,
     154                                 ev,
     155                                 cli->binding_handle);
    219156        if (tevent_req_nomem(subreq, req)) {
    220157                return tevent_req_post(req, ev);
     
    239176        }
    240177
    241         status = state->dispatch_recv(subreq, mem_ctx);
     178        status = dcerpc_bar_recv(subreq,
     179                                 mem_ctx,
     180                                 &state->result);
    242181        TALLOC_FREE(subreq);
    243182        if (!NT_STATUS_IS_OK(status)) {
    244183                tevent_req_nterror(req, status);
    245184                return;
    246         }
    247 
    248         /* Copy out parameters */
    249 
    250         /* Copy result */
    251         state->orig.out.result = state->tmp.out.result;
    252 
    253         /* Reset temporary structure */
    254         ZERO_STRUCT(state->tmp);
    255 
    256         if (DEBUGLEVEL >= 10) {
    257                 NDR_PRINT_OUT_DEBUG(bar, &state->orig);
    258185        }
    259186
     
    274201        }
    275202
    276         /* Steal possbile out parameters to the callers context */
     203        /* Steal possible out parameters to the callers context */
    277204        talloc_steal(mem_ctx, state->out_mem_ctx);
    278205
    279206        /* Return result */
    280         *result = state->orig.out.result;
     207        *result = state->result;
    281208
    282209        tevent_req_received(req);
     
    288215                    WERROR *werror)
    289216{
    290 \tstruct bar r;
    291 \tNTSTATUS status;
    292 
    293 \t/* In parameters */
    294 
    295 \tif (DEBUGLEVEL >= 10) {
    296 \t\tNDR_PRINT_IN_DEBUG(bar, &r);
    297 \t}
    298 
    299         status = cli->dispatch(cli,
    300                                 mem_ctx,
    301                                 &ndr_table_foo,
    302                                 NDR_BAR,
    303                                 &r);
    304 
    305 \tif (!NT_STATUS_IS_OK(status)) {
    306 \t\treturn status;
    307 \t}
    308 
    309 \tif (DEBUGLEVEL >= 10) {
    310 \t\tNDR_PRINT_OUT_DEBUG(bar, &r);
    311 \t}
    312 
    313 \tif (NT_STATUS_IS_ERR(status)) {
    314 \t\treturn status;
    315 \t}
    316 
    317 \t/* Return variables */
    318 
    319 \t/* Return result */
    320 \tif (werror) {
    321 \t\t*werror = r.out.result;
    322 \t}
    323 
    324 \treturn werror_to_ntstatus(r.out.result);
     217        WERROR result;
     218        NTSTATUS status;
     219
     220        status = dcerpc_bar(cli->binding_handle,
     221                            mem_ctx,
     222                            &result);
     223        if (!NT_STATUS_IS_OK(status)) {
     224                return status;
     225        }
     226
     227        /* Return result */
     228        if (werror) {
     229                *werror = result;
     230        }
     231
     232        return werror_to_ntstatus(result);
    325233}
    326234
    327235");
    328236
    329 $x = new Parse::Pidl::Samba3::ClientNDR();
    330 
    331 $fn = { NAME => "bar", ELEMENTS => [ ], RETURN_TYPE => "WERROR" };
    332 my $e = { NAME => "foo", ORIGINAL => { FILE => "f", LINE => -1 },
    333           LEVELS => [ { TYPE => "ARRAY", SIZE_IS => "mysize" }, { TYPE => "DATA", DATA_TYPE => "int" } ]};
    334 
    335 $x->ParseOutputArgument($fn, $e);
    336 is($x->{res}, "memcpy(foo, r.out.foo, (mysize) * sizeof(*foo));\n");
Note: See TracChangeset for help on using the changeset viewer.