Changeset 740 for vendor/current/pidl/lib
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (13 years ago)
- Location:
- vendor/current/pidl/lib
- Files:
-
- 1 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/pidl/lib/Parse/Pidl/Compat.pm
r414 r740 20 20 "endpoint" => ["INTERFACE"], 21 21 "pointer_default" => ["INTERFACE"], 22 "no_srv_register" => ["INTERFACE"], 22 23 23 24 # dcom … … 45 46 "nopull" => ["FUNCTION", "TYPEDEF"], 46 47 "noprint" => ["FUNCTION", "TYPEDEF"], 48 "nopython" => ["FUNCTION", "TYPEDEF"], 47 49 48 50 # union … … 126 128 } 127 129 130 if (has_property($e, "relative_short")) { 131 warning($e, "relative_short() pointer property not supported"); 132 } 133 128 134 if (has_property($e, "flag")) { 129 135 warning($e, "ignoring flag() property"); -
vendor/current/pidl/lib/Parse/Pidl/Expr.pm
r414 r740 1128 1128 'exp', 1, 1129 1129 sub 1130 #line 24 " ./../pidl/expr.yp"1130 #line 24 "expr.yp" 1131 1131 { "\"$_[1]\"" } 1132 1132 ], … … 1140 1140 'exp', 2, 1141 1141 sub 1142 #line 30 " ./../pidl/expr.yp"1142 #line 30 "expr.yp" 1143 1143 { "~$_[2]" } 1144 1144 ], … … 1146 1146 'exp', 3, 1147 1147 sub 1148 #line 32 " ./../pidl/expr.yp"1148 #line 32 "expr.yp" 1149 1149 { "$_[1] + $_[3]" } 1150 1150 ], … … 1152 1152 'exp', 3, 1153 1153 sub 1154 #line 34 " ./../pidl/expr.yp"1154 #line 34 "expr.yp" 1155 1155 { "$_[1] - $_[3]" } 1156 1156 ], … … 1158 1158 'exp', 3, 1159 1159 sub 1160 #line 36 " ./../pidl/expr.yp"1160 #line 36 "expr.yp" 1161 1161 { "$_[1] * $_[3]" } 1162 1162 ], … … 1164 1164 'exp', 3, 1165 1165 sub 1166 #line 38 " ./../pidl/expr.yp"1166 #line 38 "expr.yp" 1167 1167 { "$_[1] % $_[3]" } 1168 1168 ], … … 1170 1170 'exp', 3, 1171 1171 sub 1172 #line 40 " ./../pidl/expr.yp"1172 #line 40 "expr.yp" 1173 1173 { "$_[1] < $_[3]" } 1174 1174 ], … … 1176 1176 'exp', 3, 1177 1177 sub 1178 #line 42 " ./../pidl/expr.yp"1178 #line 42 "expr.yp" 1179 1179 { "$_[1] > $_[3]" } 1180 1180 ], … … 1182 1182 'exp', 3, 1183 1183 sub 1184 #line 44 " ./../pidl/expr.yp"1184 #line 44 "expr.yp" 1185 1185 { "$_[1] | $_[3]" } 1186 1186 ], … … 1188 1188 'exp', 3, 1189 1189 sub 1190 #line 46 " ./../pidl/expr.yp"1190 #line 46 "expr.yp" 1191 1191 { "$_[1] == $_[3]" } 1192 1192 ], … … 1194 1194 'exp', 3, 1195 1195 sub 1196 #line 48 " ./../pidl/expr.yp"1196 #line 48 "expr.yp" 1197 1197 { "$_[1] <= $_[3]" } 1198 1198 ], … … 1200 1200 'exp', 3, 1201 1201 sub 1202 #line 50 " ./../pidl/expr.yp"1202 #line 50 "expr.yp" 1203 1203 { "$_[1] => $_[3]" } 1204 1204 ], … … 1206 1206 'exp', 3, 1207 1207 sub 1208 #line 52 " ./../pidl/expr.yp"1208 #line 52 "expr.yp" 1209 1209 { "$_[1] << $_[3]" } 1210 1210 ], … … 1212 1212 'exp', 3, 1213 1213 sub 1214 #line 54 " ./../pidl/expr.yp"1214 #line 54 "expr.yp" 1215 1215 { "$_[1] >> $_[3]" } 1216 1216 ], … … 1218 1218 'exp', 3, 1219 1219 sub 1220 #line 56 " ./../pidl/expr.yp"1220 #line 56 "expr.yp" 1221 1221 { "$_[1] != $_[3]" } 1222 1222 ], … … 1224 1224 'exp', 3, 1225 1225 sub 1226 #line 58 " ./../pidl/expr.yp"1226 #line 58 "expr.yp" 1227 1227 { "$_[1] || $_[3]" } 1228 1228 ], … … 1230 1230 'exp', 3, 1231 1231 sub 1232 #line 60 " ./../pidl/expr.yp"1232 #line 60 "expr.yp" 1233 1233 { "$_[1] && $_[3]" } 1234 1234 ], … … 1236 1236 'exp', 3, 1237 1237 sub 1238 #line 62 " ./../pidl/expr.yp"1238 #line 62 "expr.yp" 1239 1239 { "$_[1] & $_[3]" } 1240 1240 ], … … 1242 1242 'exp', 5, 1243 1243 sub 1244 #line 64 " ./../pidl/expr.yp"1244 #line 64 "expr.yp" 1245 1245 { "$_[1]?$_[3]:$_[5]" } 1246 1246 ], … … 1248 1248 'exp', 2, 1249 1249 sub 1250 #line 66 " ./../pidl/expr.yp"1250 #line 66 "expr.yp" 1251 1251 { "~$_[1]" } 1252 1252 ], … … 1254 1254 'exp', 2, 1255 1255 sub 1256 #line 68 " ./../pidl/expr.yp"1256 #line 68 "expr.yp" 1257 1257 { "not $_[1]" } 1258 1258 ], … … 1260 1260 'exp', 3, 1261 1261 sub 1262 #line 70 " ./../pidl/expr.yp"1262 #line 70 "expr.yp" 1263 1263 { "$_[1] / $_[3]" } 1264 1264 ], … … 1266 1266 'exp', 2, 1267 1267 sub 1268 #line 72 " ./../pidl/expr.yp"1268 #line 72 "expr.yp" 1269 1269 { "-$_[2]" } 1270 1270 ], … … 1272 1272 'exp', 2, 1273 1273 sub 1274 #line 74 " ./../pidl/expr.yp"1274 #line 74 "expr.yp" 1275 1275 { "&$_[2]" } 1276 1276 ], … … 1278 1278 'exp', 3, 1279 1279 sub 1280 #line 76 " ./../pidl/expr.yp"1280 #line 76 "expr.yp" 1281 1281 { "$_[1]^$_[3]" } 1282 1282 ], … … 1284 1284 'exp', 3, 1285 1285 sub 1286 #line 78 " ./../pidl/expr.yp"1286 #line 78 "expr.yp" 1287 1287 { "($_[2])" } 1288 1288 ], … … 1290 1290 'possible_pointer', 1, 1291 1291 sub 1292 #line 82 " ./../pidl/expr.yp"1292 #line 82 "expr.yp" 1293 1293 { $_[0]->_Lookup($_[1]) } 1294 1294 ], … … 1296 1296 'possible_pointer', 2, 1297 1297 sub 1298 #line 84 " ./../pidl/expr.yp"1298 #line 84 "expr.yp" 1299 1299 { $_[0]->_Dereference($_[2]); "*$_[2]" } 1300 1300 ], … … 1302 1302 'var', 1, 1303 1303 sub 1304 #line 88 " ./../pidl/expr.yp"1304 #line 88 "expr.yp" 1305 1305 { $_[0]->_Use($_[1]) } 1306 1306 ], … … 1308 1308 'var', 3, 1309 1309 sub 1310 #line 90 " ./../pidl/expr.yp"1310 #line 90 "expr.yp" 1311 1311 { $_[0]->_Use("$_[1].$_[3]") } 1312 1312 ], … … 1314 1314 'var', 3, 1315 1315 sub 1316 #line 92 " ./../pidl/expr.yp"1316 #line 92 "expr.yp" 1317 1317 { "($_[2])" } 1318 1318 ], … … 1320 1320 'var', 3, 1321 1321 sub 1322 #line 94 " ./../pidl/expr.yp"1322 #line 94 "expr.yp" 1323 1323 { $_[0]->_Use("*$_[1]"); $_[1]."->".$_[3] } 1324 1324 ], … … 1326 1326 'func', 4, 1327 1327 sub 1328 #line 99 " ./../pidl/expr.yp"1328 #line 99 "expr.yp" 1329 1329 { "$_[1]($_[3])" } 1330 1330 ], … … 1332 1332 'opt_args', 0, 1333 1333 sub 1334 #line 104 " ./../pidl/expr.yp"1334 #line 104 "expr.yp" 1335 1335 { "" } 1336 1336 ], … … 1350 1350 'args', 3, 1351 1351 sub 1352 #line 118 " ./../pidl/expr.yp"1352 #line 118 "expr.yp" 1353 1353 { "$_[1], $_[3]" } 1354 1354 ] … … 1358 1358 } 1359 1359 1360 #line 121 " ./../pidl/expr.yp"1360 #line 121 "expr.yp" 1361 1361 1362 1362 -
vendor/current/pidl/lib/Parse/Pidl/IDL.pm
r414 r740 1066 1066 }, 1067 1067 {#State 125 1068 ACTIONS => { 1069 'IDENTIFIER' => 26 1070 }, 1071 GOTOS => { 1072 'identifier' => 137 1068 DEFAULT => -75, 1069 GOTOS => { 1070 'pointers' => 137 1073 1071 } 1074 1072 }, … … 1166 1164 {#State 137 1167 1165 ACTIONS => { 1168 "[" => 1551169 },1170 DEFAULT => -86,1171 GOTOS => { 1172 ' array_len' => 1561166 'IDENTIFIER' => 26, 1167 "*" => 152 1168 }, 1169 GOTOS => { 1170 'identifier' => 155 1173 1171 } 1174 1172 }, … … 1179 1177 DEFAULT => -68, 1180 1178 GOTOS => { 1181 'union_elements' => 15 71179 'union_elements' => 156 1182 1180 } 1183 1181 }, … … 1191 1189 DEFAULT => -78, 1192 1190 GOTOS => { 1193 'element_list1' => 15 81191 'element_list1' => 157 1194 1192 } 1195 1193 }, … … 1202 1200 }, 1203 1201 GOTOS => { 1204 'identifier' => 15 9,1205 'enum_element' => 1 60,1206 'enum_elements' => 16 11202 'identifier' => 158, 1203 'enum_element' => 159, 1204 'enum_elements' => 160 1207 1205 } 1208 1206 }, … … 1222 1220 DEFAULT => -57, 1223 1221 GOTOS => { 1224 'identifier' => 16 4,1225 'bitmap_element' => 16 3,1226 'bitmap_elements' => 16 2,1227 'opt_bitmap_elements' => 16 51222 'identifier' => 163, 1223 'bitmap_element' => 162, 1224 'bitmap_elements' => 161, 1225 'opt_bitmap_elements' => 164 1228 1226 } 1229 1227 }, … … 1234 1232 ACTIONS => { 1235 1233 "," => -82, 1236 "void" => 16 9,1237 "const" => 16 7,1234 "void" => 168, 1235 "const" => 166, 1238 1236 ")" => -82 1239 1237 }, 1240 1238 DEFAULT => -80, 1241 1239 GOTOS => { 1242 'optional_const' => 16 6,1243 'element_list2' => 16 81240 'optional_const' => 165, 1241 'element_list2' => 167 1244 1242 } 1245 1243 }, 1246 1244 {#State 151 1247 1245 ACTIONS => { 1248 "[" => 1 55,1246 "[" => 169, 1249 1247 "=" => 171 1250 1248 }, … … 1289 1287 {#State 155 1290 1288 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 => { 1291 1371 'CONSTANT' => 48, 1292 1372 'TEXT' => 16, 1293 "]" => 1 72,1373 "]" => 188, 1294 1374 'IDENTIFIER' => 26 1295 1375 }, … … 1297 1377 GOTOS => { 1298 1378 'identifier' => 50, 1299 'anytext' => 1 73,1379 'anytext' => 189, 1300 1380 'text' => 51, 1301 1381 'constant' => 47 1302 1382 } 1303 },1304 {#State 1561305 ACTIONS => {1306 ";" => 1741307 }1308 },1309 {#State 1571310 ACTIONS => {1311 "}" => 1751312 },1313 DEFAULT => -89,1314 GOTOS => {1315 'optional_base_element' => 177,1316 'property_list' => 1761317 }1318 },1319 {#State 1581320 ACTIONS => {1321 "}" => 1781322 },1323 DEFAULT => -89,1324 GOTOS => {1325 'base_element' => 179,1326 'property_list' => 1801327 }1328 },1329 {#State 1591330 ACTIONS => {1331 "=" => 1811332 },1333 DEFAULT => -491334 },1335 {#State 1601336 DEFAULT => -471337 },1338 {#State 1611339 ACTIONS => {1340 "}" => 182,1341 "," => 1831342 }1343 },1344 {#State 1621345 ACTIONS => {1346 "," => 1841347 },1348 DEFAULT => -581349 },1350 {#State 1631351 DEFAULT => -551352 },1353 {#State 1641354 ACTIONS => {1355 "=" => 1851356 }1357 },1358 {#State 1651359 ACTIONS => {1360 "}" => 1861361 }1362 },1363 {#State 1661364 DEFAULT => -89,1365 GOTOS => {1366 'base_element' => 187,1367 'property_list' => 1801368 }1369 },1370 {#State 1671371 DEFAULT => -811372 },1373 {#State 1681374 ACTIONS => {1375 "," => 188,1376 ")" => 1891377 }1378 },1379 {#State 1691380 DEFAULT => -831381 1383 }, 1382 1384 {#State 170 … … 1401 1403 {#State 172 1402 1404 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 1404 1529 }, 1405 1530 DEFAULT => -86, 1406 1531 GOTOS => { 1407 'array_len' => 1921408 } 1409 }, 1410 {#State 1 731532 'array_len' => 205 1533 } 1534 }, 1535 {#State 189 1411 1536 ACTIONS => { 1412 1537 "-" => 69, … … 1424 1549 "*" => 80, 1425 1550 "." => 81, 1426 "]" => 193,1551 "]" => 206, 1427 1552 ">" => 82 1428 1553 } 1429 1554 }, 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 1483 1556 ACTIONS => { 1484 1557 'CONSTANT' => 48, … … 1489 1562 GOTOS => { 1490 1563 '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, 1561 1565 'text' => 51, 1562 1566 'constant' => 47 … … 1569 1573 "?" => 70, 1570 1574 "<" => 71, 1571 ";" => 20 7,1575 ";" => 208, 1572 1576 "+" => 73, 1573 1577 "~" => 72, … … 1584 1588 }, 1585 1589 {#State 192 1586 DEFAULT => - 871590 DEFAULT => -29 1587 1591 }, 1588 1592 {#State 193 1589 ACTIONS => { 1590 "[" => 155 1591 }, 1592 DEFAULT => -86, 1593 GOTOS => { 1594 'array_len' => 208 1595 } 1593 DEFAULT => -67 1596 1594 }, 1597 1595 {#State 194 1598 DEFAULT => -67 1596 ACTIONS => { 1597 ";" => 209 1598 } 1599 1599 }, 1600 1600 {#State 195 1601 ACTIONS => { 1602 ";" => 209 1603 } 1601 DEFAULT => -66 1604 1602 }, 1605 1603 {#State 196 1606 DEFAULT => -661607 },1608 {#State 1971609 1604 ACTIONS => { 1610 1605 'IDENTIFIER' => 26, … … 1625 1620 'struct' => 62, 1626 1621 'enum' => 65, 1627 'type' => 19 9,1622 'type' => 198, 1628 1623 'union' => 67, 1629 1624 'sign' => 97 1630 1625 } 1631 1626 }, 1627 {#State 197 1628 DEFAULT => -79 1629 }, 1632 1630 {#State 198 1633 DEFAULT => -79 1631 DEFAULT => -75, 1632 GOTOS => { 1633 'pointers' => 211 1634 } 1634 1635 }, 1635 1636 {#State 199 1636 DEFAULT => -75,1637 GOTOS => {1638 'pointers' => 2111639 }1640 },1641 {#State 2001642 1637 ACTIONS => { 1643 1638 "-" => 69, … … 1659 1654 DEFAULT => -50 1660 1655 }, 1656 {#State 200 1657 DEFAULT => -48 1658 }, 1661 1659 {#State 201 1662 DEFAULT => - 481660 DEFAULT => -56 1663 1661 }, 1664 1662 {#State 202 1665 DEFAULT => -561666 },1667 {#State 2031668 1663 ACTIONS => { 1669 1664 "-" => 69, … … 1685 1680 DEFAULT => -59 1686 1681 }, 1682 {#State 203 1683 DEFAULT => -89, 1684 GOTOS => { 1685 'base_element' => 212, 1686 'property_list' => 178 1687 } 1688 }, 1687 1689 {#State 204 1688 DEFAULT => -89, 1689 GOTOS => { 1690 'base_element' => 212, 1691 'property_list' => 180 1692 } 1690 DEFAULT => -28 1693 1691 }, 1694 1692 {#State 205 1695 DEFAULT => - 281693 DEFAULT => -87 1696 1694 }, 1697 1695 {#State 206 1696 ACTIONS => { 1697 "[" => 169 1698 }, 1699 DEFAULT => -86, 1700 GOTOS => { 1701 'array_len' => 213 1702 } 1703 }, 1704 {#State 207 1698 1705 ACTIONS => { 1699 1706 "-" => 69, … … 1701 1708 "?" => 70, 1702 1709 "<" => 71, 1703 ";" => 21 3,1710 ";" => 214, 1704 1711 "+" => 73, 1705 1712 "~" => 72, … … 1715 1722 } 1716 1723 }, 1717 {#State 20 71724 {#State 208 1718 1725 DEFAULT => -26 1719 },1720 {#State 2081721 DEFAULT => -881722 1726 }, 1723 1727 {#State 209 … … 1733 1737 }, 1734 1738 GOTOS => { 1735 'identifier' => 21 41739 'identifier' => 215 1736 1740 } 1737 1741 }, … … 1740 1744 }, 1741 1745 {#State 213 1746 DEFAULT => -88 1747 }, 1748 {#State 214 1742 1749 DEFAULT => -27 1743 1750 }, 1744 {#State 21 41745 ACTIONS => { 1746 "[" => 1 551751 {#State 215 1752 ACTIONS => { 1753 "[" => 169 1747 1754 }, 1748 1755 DEFAULT => -86, 1749 1756 GOTOS => { 1750 'array_len' => 21 51751 } 1752 }, 1753 {#State 21 51757 'array_len' => 216 1758 } 1759 }, 1760 {#State 216 1754 1761 DEFAULT => -74 1755 1762 } … … 1766 1773 'idl', 2, 1767 1774 sub 1768 #line 20 " ./../pidl/idl.yp"1775 #line 20 "idl.yp" 1769 1776 { push(@{$_[1]}, $_[2]); $_[1] } 1770 1777 ], … … 1772 1779 'idl', 2, 1773 1780 sub 1774 #line 22 " ./../pidl/idl.yp"1781 #line 22 "idl.yp" 1775 1782 { push(@{$_[1]}, $_[2]); $_[1] } 1776 1783 ], … … 1778 1785 'idl', 2, 1779 1786 sub 1780 #line 24 " ./../pidl/idl.yp"1787 #line 24 "idl.yp" 1781 1788 { push(@{$_[1]}, $_[2]); $_[1] } 1782 1789 ], … … 1784 1791 'idl', 2, 1785 1792 sub 1786 #line 26 " ./../pidl/idl.yp"1793 #line 26 "idl.yp" 1787 1794 { push(@{$_[1]}, $_[2]); $_[1] } 1788 1795 ], … … 1790 1797 'idl', 2, 1791 1798 sub 1792 #line 28 " ./../pidl/idl.yp"1799 #line 28 "idl.yp" 1793 1800 { push(@{$_[1]}, $_[2]); $_[1] } 1794 1801 ], … … 1796 1803 'idl', 2, 1797 1804 sub 1798 #line 30 " ./../pidl/idl.yp"1805 #line 30 "idl.yp" 1799 1806 { push(@{$_[1]}, $_[2]); $_[1] } 1800 1807 ], … … 1802 1809 'import', 3, 1803 1810 sub 1804 #line 35 " ./../pidl/idl.yp"1811 #line 35 "idl.yp" 1805 1812 {{ 1806 1813 "TYPE" => "IMPORT", … … 1813 1820 'include', 3, 1814 1821 sub 1815 #line 45 " ./../pidl/idl.yp"1822 #line 45 "idl.yp" 1816 1823 {{ 1817 1824 "TYPE" => "INCLUDE", … … 1824 1831 'importlib', 3, 1825 1832 sub 1826 #line 55 " ./../pidl/idl.yp"1833 #line 55 "idl.yp" 1827 1834 {{ 1828 1835 "TYPE" => "IMPORTLIB", … … 1835 1842 'commalist', 1, 1836 1843 sub 1837 #line 64 " ./../pidl/idl.yp"1844 #line 64 "idl.yp" 1838 1845 { [ $_[1] ] } 1839 1846 ], … … 1841 1848 'commalist', 3, 1842 1849 sub 1843 #line 66 " ./../pidl/idl.yp"1850 #line 66 "idl.yp" 1844 1851 { push(@{$_[1]}, $_[3]); $_[1] } 1845 1852 ], … … 1847 1854 'coclass', 7, 1848 1855 sub 1849 #line 71 " ./../pidl/idl.yp"1856 #line 71 "idl.yp" 1850 1857 {{ 1851 1858 "TYPE" => "COCLASS", … … 1863 1870 'interface_names', 4, 1864 1871 sub 1865 #line 84 " ./../pidl/idl.yp"1872 #line 84 "idl.yp" 1866 1873 { push(@{$_[1]}, $_[2]); $_[1] } 1867 1874 ], … … 1869 1876 'interface', 8, 1870 1877 sub 1871 #line 89 " ./../pidl/idl.yp"1878 #line 89 "idl.yp" 1872 1879 {{ 1873 1880 "TYPE" => "INTERFACE", … … 1886 1893 'base_interface', 2, 1887 1894 sub 1888 #line 103 " ./../pidl/idl.yp"1895 #line 103 "idl.yp" 1889 1896 { $_[2] } 1890 1897 ], … … 1892 1899 'cpp_quote', 4, 1893 1900 sub 1894 #line 109 " ./../pidl/idl.yp"1901 #line 109 "idl.yp" 1895 1902 {{ 1896 1903 "TYPE" => "CPP_QUOTE", … … 1903 1910 'definitions', 1, 1904 1911 sub 1905 #line 118 " ./../pidl/idl.yp"1912 #line 118 "idl.yp" 1906 1913 { [ $_[1] ] } 1907 1914 ], … … 1909 1916 'definitions', 2, 1910 1917 sub 1911 #line 120 " ./../pidl/idl.yp"1918 #line 120 "idl.yp" 1912 1919 { push(@{$_[1]}, $_[2]); $_[1] } 1913 1920 ], … … 1927 1934 'const', 7, 1928 1935 sub 1929 #line 135 " ./../pidl/idl.yp"1936 #line 135 "idl.yp" 1930 1937 {{ 1931 1938 "TYPE" => "CONST", … … 1941 1948 'const', 8, 1942 1949 sub 1943 #line 146 " ./../pidl/idl.yp"1950 #line 146 "idl.yp" 1944 1951 {{ 1945 1952 "TYPE" => "CONST", … … 1956 1963 'function', 7, 1957 1964 sub 1958 #line 160 " ./../pidl/idl.yp"1965 #line 160 "idl.yp" 1959 1966 {{ 1960 1967 "TYPE" => "FUNCTION", … … 1968 1975 ], 1969 1976 [#Rule 29 1970 'typedef', 6,1971 sub 1972 #line 173 " ./../pidl/idl.yp"1977 'typedef', 7, 1978 sub 1979 #line 173 "idl.yp" 1973 1980 {{ 1974 1981 "TYPE" => "TYPEDEF", 1975 1982 "PROPERTIES" => $_[1], 1976 "NAME" => $_[ 4],1983 "NAME" => $_[5], 1977 1984 "DATA" => $_[3], 1978 "ARRAY_LEN" => $_[5], 1985 "POINTERS" => $_[4], 1986 "ARRAY_LEN" => $_[6], 1979 1987 "FILE" => $_[0]->YYData->{FILE}, 1980 1988 "LINE" => $_[0]->YYData->{LINE}, … … 1999 2007 'typedecl', 2, 2000 2008 sub 2001 #line 19 7 "./../pidl/idl.yp"2009 #line 198 "idl.yp" 2002 2010 { $_[1] } 2003 2011 ], … … 2011 2019 'existingtype', 2, 2012 2020 sub 2013 #line 20 7 "./../pidl/idl.yp"2021 #line 208 "idl.yp" 2014 2022 { ($_[1]?$_[1]:"signed") ." $_[2]" } 2015 2023 ], … … 2026 2034 'type', 1, 2027 2035 sub 2028 #line 21 7 "./../pidl/idl.yp"2036 #line 218 "idl.yp" 2029 2037 { "void" } 2030 2038 ], … … 2032 2040 'enum_body', 3, 2033 2041 sub 2034 #line 22 1 "./../pidl/idl.yp"2042 #line 222 "idl.yp" 2035 2043 { $_[2] } 2036 2044 ], … … 2044 2052 'enum', 4, 2045 2053 sub 2046 #line 23 2 "./../pidl/idl.yp"2054 #line 233 "idl.yp" 2047 2055 {{ 2048 2056 "TYPE" => "ENUM", … … 2057 2065 'enum_elements', 1, 2058 2066 sub 2059 #line 24 3 "./../pidl/idl.yp"2067 #line 244 "idl.yp" 2060 2068 { [ $_[1] ] } 2061 2069 ], … … 2063 2071 'enum_elements', 3, 2064 2072 sub 2065 #line 24 5 "./../pidl/idl.yp"2073 #line 246 "idl.yp" 2066 2074 { push(@{$_[1]}, $_[3]); $_[1] } 2067 2075 ], … … 2072 2080 'enum_element', 3, 2073 2081 sub 2074 #line 25 1 "./../pidl/idl.yp"2082 #line 252 "idl.yp" 2075 2083 { "$_[1]$_[2]$_[3]" } 2076 2084 ], … … 2078 2086 'bitmap_body', 3, 2079 2087 sub 2080 #line 25 5 "./../pidl/idl.yp"2088 #line 256 "idl.yp" 2081 2089 { $_[2] } 2082 2090 ], … … 2090 2098 'bitmap', 4, 2091 2099 sub 2092 #line 26 6 "./../pidl/idl.yp"2100 #line 267 "idl.yp" 2093 2101 {{ 2094 2102 "TYPE" => "BITMAP", … … 2103 2111 'bitmap_elements', 1, 2104 2112 sub 2105 #line 27 7 "./../pidl/idl.yp"2113 #line 278 "idl.yp" 2106 2114 { [ $_[1] ] } 2107 2115 ], … … 2109 2117 'bitmap_elements', 3, 2110 2118 sub 2111 #line 2 79 "./../pidl/idl.yp"2119 #line 280 "idl.yp" 2112 2120 { push(@{$_[1]}, $_[3]); $_[1] } 2113 2121 ], … … 2121 2129 'bitmap_element', 3, 2122 2130 sub 2123 #line 2 89 "./../pidl/idl.yp"2131 #line 290 "idl.yp" 2124 2132 { "$_[1] ( $_[3] )" } 2125 2133 ], … … 2127 2135 'struct_body', 3, 2128 2136 sub 2129 #line 29 3 "./../pidl/idl.yp"2137 #line 294 "idl.yp" 2130 2138 { $_[2] } 2131 2139 ], … … 2139 2147 'struct', 4, 2140 2148 sub 2141 #line 30 4 "./../pidl/idl.yp"2149 #line 305 "idl.yp" 2142 2150 {{ 2143 2151 "TYPE" => "STRUCT", … … 2152 2160 'empty_element', 2, 2153 2161 sub 2154 #line 31 6 "./../pidl/idl.yp"2162 #line 317 "idl.yp" 2155 2163 {{ 2156 2164 "NAME" => "", … … 2172 2180 'optional_base_element', 2, 2173 2181 sub 2174 #line 33 3 "./../pidl/idl.yp"2182 #line 334 "idl.yp" 2175 2183 { $_[2]->{PROPERTIES} = FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] } 2176 2184 ], … … 2181 2189 'union_elements', 2, 2182 2190 sub 2183 #line 3 39 "./../pidl/idl.yp"2191 #line 340 "idl.yp" 2184 2192 { push(@{$_[1]}, $_[2]); $_[1] } 2185 2193 ], … … 2187 2195 'union_body', 3, 2188 2196 sub 2189 #line 34 3 "./../pidl/idl.yp"2197 #line 344 "idl.yp" 2190 2198 { $_[2] } 2191 2199 ], … … 2199 2207 'union', 4, 2200 2208 sub 2201 #line 35 4 "./../pidl/idl.yp"2209 #line 355 "idl.yp" 2202 2210 {{ 2203 2211 "TYPE" => "UNION", … … 2212 2220 'base_element', 5, 2213 2221 sub 2214 #line 36 6 "./../pidl/idl.yp"2222 #line 367 "idl.yp" 2215 2223 {{ 2216 2224 "NAME" => $_[4], … … 2226 2234 'pointers', 0, 2227 2235 sub 2228 #line 3 79 "./../pidl/idl.yp"2236 #line 380 "idl.yp" 2229 2237 { 0 } 2230 2238 ], … … 2232 2240 'pointers', 2, 2233 2241 sub 2234 #line 38 1 "./../pidl/idl.yp"2242 #line 382 "idl.yp" 2235 2243 { $_[1]+1 } 2236 2244 ], … … 2238 2246 'pipe', 3, 2239 2247 sub 2240 #line 38 6 "./../pidl/idl.yp"2248 #line 387 "idl.yp" 2241 2249 {{ 2242 2250 "TYPE" => "PIPE", 2243 2251 "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 }, 2246 2277 "FILE" => $_[0]->YYData->{FILE}, 2247 2278 "LINE" => $_[0]->YYData->{LINE}, … … 2251 2282 'element_list1', 0, 2252 2283 sub 2253 #line 398 "./../pidl/idl.yp"2284 #line 422 "idl.yp" 2254 2285 { [] } 2255 2286 ], … … 2257 2288 'element_list1', 3, 2258 2289 sub 2259 #line 4 00 "./../pidl/idl.yp"2290 #line 424 "idl.yp" 2260 2291 { push(@{$_[1]}, $_[2]); $_[1] } 2261 2292 ], … … 2275 2306 'element_list2', 2, 2276 2307 sub 2277 #line 4 14 "./../pidl/idl.yp"2308 #line 438 "idl.yp" 2278 2309 { [ $_[2] ] } 2279 2310 ], … … 2281 2312 'element_list2', 4, 2282 2313 sub 2283 #line 4 16 "./../pidl/idl.yp"2314 #line 440 "idl.yp" 2284 2315 { push(@{$_[1]}, $_[4]); $_[1] } 2285 2316 ], … … 2290 2321 'array_len', 3, 2291 2322 sub 2292 #line 4 22 "./../pidl/idl.yp"2323 #line 446 "idl.yp" 2293 2324 { push(@{$_[3]}, "*"); $_[3] } 2294 2325 ], … … 2296 2327 'array_len', 4, 2297 2328 sub 2298 #line 4 24 "./../pidl/idl.yp"2329 #line 448 "idl.yp" 2299 2330 { push(@{$_[4]}, "$_[2]"); $_[4] } 2300 2331 ], … … 2305 2336 'property_list', 4, 2306 2337 sub 2307 #line 4 30 "./../pidl/idl.yp"2338 #line 454 "idl.yp" 2308 2339 { FlattenHash([$_[1],$_[3]]); } 2309 2340 ], … … 2311 2342 'properties', 1, 2312 2343 sub 2313 #line 4 34 "./../pidl/idl.yp"2344 #line 458 "idl.yp" 2314 2345 { $_[1] } 2315 2346 ], … … 2317 2348 'properties', 3, 2318 2349 sub 2319 #line 4 36 "./../pidl/idl.yp"2350 #line 460 "idl.yp" 2320 2351 { FlattenHash([$_[1], $_[3]]); } 2321 2352 ], … … 2323 2354 'property', 1, 2324 2355 sub 2325 #line 4 40 "./../pidl/idl.yp"2356 #line 464 "idl.yp" 2326 2357 {{ "$_[1]" => "1" }} 2327 2358 ], … … 2329 2360 'property', 4, 2330 2361 sub 2331 #line 4 42 "./../pidl/idl.yp"2362 #line 466 "idl.yp" 2332 2363 {{ "$_[1]" => "$_[3]" }} 2333 2364 ], … … 2338 2369 'commalisttext', 3, 2339 2370 sub 2340 #line 4 48 "./../pidl/idl.yp"2371 #line 472 "idl.yp" 2341 2372 { "$_[1],$_[3]" } 2342 2373 ], … … 2344 2375 'anytext', 0, 2345 2376 sub 2346 #line 4 53 "./../pidl/idl.yp"2377 #line 477 "idl.yp" 2347 2378 { "" } 2348 2379 ], … … 2359 2390 'anytext', 3, 2360 2391 sub 2361 #line 4 61 "./../pidl/idl.yp"2392 #line 485 "idl.yp" 2362 2393 { "$_[1]$_[2]$_[3]" } 2363 2394 ], … … 2365 2396 'anytext', 3, 2366 2397 sub 2367 #line 4 63 "./../pidl/idl.yp"2398 #line 487 "idl.yp" 2368 2399 { "$_[1]$_[2]$_[3]" } 2369 2400 ], … … 2371 2402 'anytext', 3, 2372 2403 sub 2373 #line 4 65 "./../pidl/idl.yp"2404 #line 489 "idl.yp" 2374 2405 { "$_[1]$_[2]$_[3]" } 2375 2406 ], … … 2377 2408 'anytext', 3, 2378 2409 sub 2379 #line 4 67 "./../pidl/idl.yp"2410 #line 491 "idl.yp" 2380 2411 { "$_[1]$_[2]$_[3]" } 2381 2412 ], … … 2383 2414 'anytext', 3, 2384 2415 sub 2385 #line 4 69 "./../pidl/idl.yp"2416 #line 493 "idl.yp" 2386 2417 { "$_[1]$_[2]$_[3]" } 2387 2418 ], … … 2389 2420 'anytext', 3, 2390 2421 sub 2391 #line 4 71 "./../pidl/idl.yp"2422 #line 495 "idl.yp" 2392 2423 { "$_[1]$_[2]$_[3]" } 2393 2424 ], … … 2395 2426 'anytext', 3, 2396 2427 sub 2397 #line 4 73 "./../pidl/idl.yp"2428 #line 497 "idl.yp" 2398 2429 { "$_[1]$_[2]$_[3]" } 2399 2430 ], … … 2401 2432 'anytext', 3, 2402 2433 sub 2403 #line 4 75 "./../pidl/idl.yp"2434 #line 499 "idl.yp" 2404 2435 { "$_[1]$_[2]$_[3]" } 2405 2436 ], … … 2407 2438 'anytext', 3, 2408 2439 sub 2409 #line 477 "./../pidl/idl.yp"2440 #line 501 "idl.yp" 2410 2441 { "$_[1]$_[2]$_[3]" } 2411 2442 ], … … 2413 2444 'anytext', 3, 2414 2445 sub 2415 #line 479 "./../pidl/idl.yp"2446 #line 503 "idl.yp" 2416 2447 { "$_[1]$_[2]$_[3]" } 2417 2448 ], … … 2419 2450 'anytext', 3, 2420 2451 sub 2421 #line 481 "./../pidl/idl.yp"2452 #line 505 "idl.yp" 2422 2453 { "$_[1]$_[2]$_[3]" } 2423 2454 ], … … 2425 2456 'anytext', 3, 2426 2457 sub 2427 #line 483 "./../pidl/idl.yp"2458 #line 507 "idl.yp" 2428 2459 { "$_[1]$_[2]$_[3]" } 2429 2460 ], … … 2431 2462 'anytext', 3, 2432 2463 sub 2433 #line 485 "./../pidl/idl.yp"2464 #line 509 "idl.yp" 2434 2465 { "$_[1]$_[2]$_[3]" } 2435 2466 ], … … 2437 2468 'anytext', 5, 2438 2469 sub 2439 #line 487 "./../pidl/idl.yp"2470 #line 511 "idl.yp" 2440 2471 { "$_[1]$_[2]$_[3]$_[4]$_[5]" } 2441 2472 ], … … 2443 2474 'anytext', 5, 2444 2475 sub 2445 #line 489 "./../pidl/idl.yp"2476 #line 513 "idl.yp" 2446 2477 { "$_[1]$_[2]$_[3]$_[4]$_[5]" } 2447 2478 ], … … 2461 2492 'text', 1, 2462 2493 sub 2463 #line 5 07 "./../pidl/idl.yp"2494 #line 531 "idl.yp" 2464 2495 { "\"$_[1]\"" } 2465 2496 ], … … 2475 2506 } 2476 2507 2477 #line 5 19 "./../pidl/idl.yp"2508 #line 543 "idl.yp" 2478 2509 2479 2510 … … 2613 2644 undef $/; 2614 2645 my $cpp = $ENV{CPP}; 2646 my $options = ""; 2615 2647 if (! defined $cpp) { 2616 $cpp = "cpp"; 2648 if (defined $ENV{CC}) { 2649 $cpp = "$ENV{CC}"; 2650 $options = "-E"; 2651 } else { 2652 $cpp = "cpp"; 2653 } 2617 2654 } 2618 2655 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"`; 2620 2657 $/ = $saved_delim; 2621 2658 -
vendor/current/pidl/lib/Parse/Pidl/NDR.pm
r414 r740 35 35 $VERSION = '0.01'; 36 36 @ISA = qw(Exporter); 37 @EXPORT = qw(GetPrevLevel GetNextLevel ContainsDeferred Contains String);37 @EXPORT = qw(GetPrevLevel GetNextLevel ContainsDeferred ContainsPipe ContainsString); 38 38 @EXPORT_OK = qw(GetElementLevelTable ParseElement ValidElement align_type mapToScalar ParseType can_contain_deferred is_charset_array); 39 39 40 40 use strict; 41 41 use Parse::Pidl qw(warning fatal); 42 use Parse::Pidl::Typelist qw(hasType getType expandAlias);42 use Parse::Pidl::Typelist qw(hasType getType typeIs expandAlias mapScalarType is_fixed_size_scalar); 43 43 use Parse::Pidl::Util qw(has_property property_matches); 44 44 … … 55 55 'int32' => 4, 56 56 'uint32' => 4, 57 'int3264' => 5, 58 'uint3264' => 5, 57 59 'hyper' => 8, 58 60 'double' => 8, … … 65 67 'string_array' => 4, #??? 66 68 'time_t' => 4, 69 'uid_t' => 8, 70 'gid_t' => 8, 67 71 'NTTIME' => 4, 68 72 'NTTIME_1sec' => 4, … … 71 75 'NTSTATUS' => 4, 72 76 'COMRESULT' => 4, 77 'dns_string' => 4, 73 78 'nbt_string' => 4, 74 79 'wrepl_nbt_name' => 4, 75 'ipv4address' => 4 80 'ipv4address' => 4, 81 'ipv6address' => 4, #16? 82 'dnsp_name' => 1, 83 'dnsp_string' => 1 76 84 }; 77 85 78 sub GetElementLevelTable($$ )79 { 80 my ($e, $pointer_default ) = @_;86 sub GetElementLevelTable($$$) 87 { 88 my ($e, $pointer_default, $ms_union) = @_; 81 89 82 90 my $order = []; … … 102 110 my $needptrs = 1; 103 111 104 if (has_property($e, "string") ) { $needptrs++; }112 if (has_property($e, "string") and not has_property($e, "in")) { $needptrs++; } 105 113 if ($#bracket_array >= 0) { $needptrs = 0; } 106 114 107 115 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 } 108 161 } 109 162 … … 123 176 $is_conformant = 1; 124 177 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 } 125 182 } elsif ((scalar(@size_is) == 0) and has_property($e, "string")) { 126 183 $is_string = 1; … … 248 305 } 249 306 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 250 320 if (defined(has_property($e, "subcontext"))) { 251 321 my $hdr_size = has_property($e, "subcontext"); … … 298 368 } 299 369 300 sub GetTypedefLevelTable($$$ )301 { 302 my ($e, $data, $pointer_default ) = @_;370 sub GetTypedefLevelTable($$$$) 371 { 372 my ($e, $data, $pointer_default, $ms_union) = @_; 303 373 304 374 my $order = []; … … 350 420 return "unique" if (has_property($e, "unique")); 351 421 return "relative" if (has_property($e, "relative")); 422 return "relative_short" if (has_property($e, "relative_short")); 352 423 return "ignore" if (has_property($e, "ignore")); 353 424 … … 407 478 if ($dt->{TYPE} eq "TYPEDEF") { 408 479 return align_type($dt->{DATA}); 480 } elsif ($dt->{TYPE} eq "CONFORMANCE") { 481 return $dt->{DATA}->{ALIGN}; 409 482 } elsif ($dt->{TYPE} eq "ENUM") { 410 483 return align_type(Parse::Pidl::Typelist::enum_type_fn($dt)); … … 415 488 return 4 unless (defined($dt->{ELEMENTS})); 416 489 return find_largest_alignment($dt); 490 } elsif (($dt->{TYPE} eq "PIPE")) { 491 return 5; 417 492 } 418 493 … … 420 495 } 421 496 422 sub ParseElement($$ )423 { 424 my ($e, $pointer_default ) = @_;497 sub ParseElement($$$) 498 { 499 my ($e, $pointer_default, $ms_union) = @_; 425 500 426 501 $e->{TYPE} = expandAlias($e->{TYPE}); 427 502 428 503 if (ref($e->{TYPE}) eq "HASH") { 429 $e->{TYPE} = ParseType($e->{TYPE}, $pointer_default );504 $e->{TYPE} = ParseType($e->{TYPE}, $pointer_default, $ms_union); 430 505 } 431 506 … … 434 509 TYPE => $e->{TYPE}, 435 510 PROPERTIES => $e->{PROPERTIES}, 436 LEVELS => GetElementLevelTable($e, $pointer_default ),511 LEVELS => GetElementLevelTable($e, $pointer_default, $ms_union), 437 512 REPRESENTATION_TYPE => ($e->{PROPERTIES}->{represent_as} or $e->{TYPE}), 438 513 ALIGN => align_type($e->{TYPE}), … … 441 516 } 442 517 443 sub ParseStruct($$ )444 { 445 my ($struct, $pointer_default ) = @_;518 sub ParseStruct($$$) 519 { 520 my ($struct, $pointer_default, $ms_union) = @_; 446 521 my @elements = (); 447 522 my $surrounding = undef; … … 461 536 foreach my $x (@{$struct->{ELEMENTS}}) 462 537 { 463 my $e = ParseElement($x, $pointer_default );538 my $e = ParseElement($x, $pointer_default, $ms_union); 464 539 if ($x != $struct->{ELEMENTS}[-1] and 465 540 $e->{LEVELS}[0]->{IS_SURROUNDING}) { … … 498 573 sub ParseUnion($$) 499 574 { 500 my ($e, $pointer_default ) = @_;575 my ($e, $pointer_default, $ms_union) = @_; 501 576 my @elements = (); 577 my $is_ms_union = $ms_union; 578 $is_ms_union = 1 if has_property($e, "ms_union"); 502 579 my $hasdefault = 0; 503 580 my $switch_type = has_property($e, "switch_type"); … … 512 589 PROPERTIES => $e->{PROPERTIES}, 513 590 HAS_DEFAULT => $hasdefault, 591 IS_MS_UNION => $is_ms_union, 514 592 ORIGINAL => $e, 515 593 ALIGN => undef … … 524 602 $t = { TYPE => "EMPTY" }; 525 603 } else { 526 $t = ParseElement($x, $pointer_default );604 $t = ParseElement($x, $pointer_default, $ms_union); 527 605 } 528 606 if (has_property($x, "default")) { … … 549 627 PROPERTIES => $e->{PROPERTIES}, 550 628 HAS_DEFAULT => $hasdefault, 629 IS_MS_UNION => $is_ms_union, 551 630 ORIGINAL => $e, 552 631 ALIGN => $align … … 556 635 sub ParseEnum($$) 557 636 { 558 my ($e, $pointer_default ) = @_;637 my ($e, $pointer_default, $ms_union) = @_; 559 638 560 639 return { … … 568 647 } 569 648 570 sub ParseBitmap($$ )571 { 572 my ($e, $pointer_default ) = @_;649 sub ParseBitmap($$$) 650 { 651 my ($e, $pointer_default, $ms_union) = @_; 573 652 574 653 return { … … 582 661 } 583 662 584 sub ParseType($$) 585 { 586 my ($d, $pointer_default) = @_; 663 sub 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 714 sub ParseType($$$) 715 { 716 my ($d, $pointer_default, $ms_union) = @_; 587 717 588 718 my $data = { … … 592 722 BITMAP => \&ParseBitmap, 593 723 TYPEDEF => \&ParseTypedef, 594 }->{$d->{TYPE}}->($d, $pointer_default); 724 PIPE => \&ParsePipe, 725 }->{$d->{TYPE}}->($d, $pointer_default, $ms_union); 595 726 596 727 return $data; … … 599 730 sub ParseTypedef($$) 600 731 { 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 } 609 747 610 748 return { … … 612 750 TYPE => $d->{TYPE}, 613 751 PROPERTIES => $d->{PROPERTIES}, 614 LEVELS => GetTypedefLevelTable($d, $data, $pointer_default ),752 LEVELS => GetTypedefLevelTable($d, $data, $pointer_default, $ms_union), 615 753 DATA => $data, 616 754 ORIGINAL => $d … … 625 763 } 626 764 627 sub ParseFunction($$$ )628 { 629 my ($ndr,$d,$opnum ) = @_;765 sub ParseFunction($$$$) 766 { 767 my ($ndr,$d,$opnum,$ms_union) = @_; 630 768 my @elements = (); 631 769 my $rettype = undef; … … 640 778 641 779 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); 643 781 push (@{$e->{DIRECTION}}, "in") if (has_property($x, "in")); 644 782 push (@{$e->{DIRECTION}}, "out") if (has_property($x, "out")); … … 650 788 $rettype = expandAlias($d->{RETURN_TYPE}); 651 789 } 652 653 my $async = 0;654 if (has_property($d, "async")) { $async = 1; }655 790 656 791 return { … … 658 793 TYPE => "FUNCTION", 659 794 OPNUM => $thisopnum, 660 ASYNC => $async,661 795 RETURN_TYPE => $rettype, 662 796 PROPERTIES => $d->{PROPERTIES}, … … 705 839 my $opnum = 0; 706 840 my $version; 841 my $ms_union = 0; 842 $ms_union = 1 if has_property($idl, "ms_union"); 707 843 708 844 if (not has_property($idl, "pointer_default")) { … … 714 850 foreach my $d (@{$idl->{DATA}}) { 715 851 if ($d->{TYPE} eq "FUNCTION") { 716 push (@functions, ParseFunction($idl, $d, \$opnum ));852 push (@functions, ParseFunction($idl, $d, \$opnum, $ms_union)); 717 853 } elsif ($d->{TYPE} eq "CONST") { 718 854 push (@consts, ParseConst($idl, $d)); 719 855 } else { 720 push (@types, ParseType($d, $idl->{PROPERTIES}->{pointer_default} ));856 push (@types, ParseType($d, $idl->{PROPERTIES}->{pointer_default}, $ms_union)); 721 857 FindNestedTypes(\@types, $d); 722 858 } … … 830 966 } 831 967 968 sub 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 832 982 sub el_name($) 833 983 { … … 878 1028 "pyhelper" => ["INTERFACE"], 879 1029 "authservice" => ["INTERFACE"], 880 "restricted" => ["INTERFACE"], 1030 "restricted" => ["INTERFACE"], 1031 "no_srv_register" => ["INTERFACE"], 881 1032 882 1033 # dcom … … 891 1042 "in" => ["ELEMENT"], 892 1043 "out" => ["ELEMENT"], 893 "async" => ["FUNCTION"],894 1044 895 1045 # pointer 896 "ref" => ["ELEMENT" ],897 "ptr" => ["ELEMENT" ],898 "unique" => ["ELEMENT" ],1046 "ref" => ["ELEMENT", "TYPEDEF"], 1047 "ptr" => ["ELEMENT", "TYPEDEF"], 1048 "unique" => ["ELEMENT", "TYPEDEF"], 899 1049 "ignore" => ["ELEMENT"], 900 "relative" => ["ELEMENT"], 901 "null_is_ffffffff" => ["ELEMENT"], 1050 "relative" => ["ELEMENT", "TYPEDEF"], 1051 "relative_short" => ["ELEMENT", "TYPEDEF"], 1052 "null_is_ffffffff" => ["ELEMENT"], 902 1053 "relative_base" => ["TYPEDEF", "STRUCT", "UNION"], 903 1054 904 1055 "gensize" => ["TYPEDEF", "STRUCT", "UNION"], 905 1056 "value" => ["ELEMENT"], 906 "flag" => ["ELEMENT", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP" ],1057 "flag" => ["ELEMENT", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP", "PIPE"], 907 1058 908 1059 # 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"], 912 1063 "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"], 914 1066 "todo" => ["FUNCTION"], 915 1067 … … 918 1070 "switch_type" => ["ELEMENT", "UNION"], 919 1071 "nodiscriminant" => ["UNION"], 1072 "ms_union" => ["INTERFACE", "UNION"], 920 1073 "case" => ["ELEMENT"], 921 1074 "default" => ["ELEMENT"], … … 1007 1160 $discriminator_type = "uint32" unless defined ($discriminator_type); 1008 1161 1009 my $t1 = map ToScalar($discriminator_type);1162 my $t1 = mapScalarType(mapToScalar($discriminator_type)); 1010 1163 1011 1164 if (not defined($t1)) { … … 1013 1166 } 1014 1167 1015 my $t2 = map ToScalar($e2->{TYPE});1168 my $t2 = mapScalarType(mapToScalar($e2->{TYPE})); 1016 1169 if (not defined($t2)) { 1017 1170 fatal($e, el_name($e) . ": unable to map variable used for switch_is() to scalar"); … … 1056 1209 has_property($e, "unique") or 1057 1210 has_property($e, "relative") or 1211 has_property($e, "relative_short") or 1058 1212 has_property($e, "ref"))) { 1059 1213 fatal($e, el_name($e) . " : pointer properties on non-pointer element\n"); … … 1137 1291 { 1138 1292 my ($pipe) = @_; 1139 my $ data= $pipe->{DATA};1293 my $struct = $pipe->{DATA}; 1140 1294 1141 1295 ValidProperties($pipe, "PIPE"); 1142 1296 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); 1144 1303 } 1145 1304 … … 1153 1312 ValidProperties($typedef, "TYPEDEF"); 1154 1313 1314 return unless (ref($data) eq "HASH"); 1315 1155 1316 $data->{PARENT} = $typedef; 1156 1317 … … 1158 1319 $data->{LINE} = $typedef->{LINE} unless defined($data->{LINE}); 1159 1320 1160 ValidType($data) if (ref($data) eq "HASH");1321 ValidType($data); 1161 1322 } 1162 1323 -
vendor/current/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm
r587 r740 10 10 use Exporter; 11 11 @ISA = qw(Exporter); 12 @EXPORT_OK = qw(ParseFunction $res $res_hdr ParseOutputArgument);12 @EXPORT_OK = qw(ParseFunction $res $res_hdr); 13 13 14 14 use strict; 15 15 use Parse::Pidl qw(fatal warning error); 16 16 use Parse::Pidl::Util qw(has_property ParseExpr); 17 use Parse::Pidl::NDR qw(ContainsPipe); 18 use Parse::Pidl::Typelist qw(mapTypeName); 17 19 use Parse::Pidl::Samba4 qw(DeclLong); 18 20 use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv GenerateFunctionOutEnv); … … 86 88 } 87 89 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 data113 # structure, the user should be able to know the size beforehand114 # 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 160 90 sub ParseFunctionAsyncState($$$) 161 91 { … … 167 97 $self->pidl("$state_str {"); 168 98 $self->indent; 169 $self->pidl("struct $fn->{NAME} orig;");170 $self->pidl("struct $fn->{NAME} tmp;");171 99 $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 } 173 103 $self->deindent; 174 104 $self->pidl("};"); … … 216 146 $self->pidl("}"); 217 147 $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 }227 148 $self->pidl(""); 228 149 229 150 my $out_params = 0; 230 $self->pidl("/* Out parameters */");231 151 foreach (@{$fn->{ELEMENTS}}) { 232 152 if (grep(/out/, @{$_->{DIRECTION}})) { 233 $self->pidl("state->orig.out.$_->{NAME} = _$_->{NAME};");234 153 $out_params++; 235 154 } 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("");243 155 } 244 156 … … 254 166 } 255 167 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);"); 264 176 $self->pidl("if (tevent_req_nomem(subreq, req)) {"); 265 177 $self->indent; … … 303 215 $self->pidl(""); 304 216 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);"); 306 225 $self->pidl("TALLOC_FREE(subreq);"); 307 226 $self->pidl("if (!NT_STATUS_IS_OK(status)) {"); … … 311 230 $self->deindent; 312 231 $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);");334 232 $self->pidl(""); 335 233 … … 370 268 $self->pidl(""); 371 269 372 $self->pidl("/* Steal poss bile out parameters to the callers context */");270 $self->pidl("/* Steal possible out parameters to the callers context */"); 373 271 $self->pidl("talloc_steal(mem_ctx, state->out_mem_ctx);"); 374 272 $self->pidl(""); … … 376 274 if (defined($fn->{RETURN_TYPE})) { 377 275 $self->pidl("/* Return result */"); 378 $self->pidl("*result = state-> orig.out.result;");276 $self->pidl("*result = state->result;"); 379 277 $self->pidl(""); 380 278 } … … 402 300 my $dir = ElementDirection($_); 403 301 my $prop = HeaderProperties($_->{PROPERTIES}, ["in", "out"]); 404 $fn_args .= ",\n" . $pad . DeclLong($_ ) . " /* $dir $prop */";302 $fn_args .= ",\n" . $pad . DeclLong($_, "_") . " /* $dir $prop */"; 405 303 } 406 304 … … 412 310 $self->pidl("{"); 413 311 $self->indent; 414 $self->pidl("struct $fn->{NAME} r;"); 312 if (defined($fn->{RETURN_TYPE})) { 313 $self->pidl(mapTypeName($fn->{RETURN_TYPE})." result;"); 314 } 415 315 $self->pidl("NTSTATUS status;"); 416 316 $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"; 419 321 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);"); 433 329 $self->pidl("if (!NT_STATUS_IS_OK(status)) {"); 434 330 $self->indent; … … 436 332 $self->deindent; 437 333 $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 455 336 $self->pidl("/* Return result */"); 456 337 if (not $fn->{RETURN_TYPE}) { 457 338 $self->pidl("return NT_STATUS_OK;"); 458 339 } elsif ($fn->{RETURN_TYPE} eq "NTSTATUS") { 459 $self->pidl("return r .out.result;");340 $self->pidl("return result;"); 460 341 } elsif ($fn->{RETURN_TYPE} eq "WERROR") { 461 342 $self->pidl("if (werror) {"); 462 343 $self->indent; 463 $self->pidl("*werror = r .out.result;");344 $self->pidl("*werror = result;"); 464 345 $self->deindent; 465 346 $self->pidl("}"); 466 347 $self->pidl(""); 467 $self->pidl("return werror_to_ntstatus(r .out.result);");348 $self->pidl("return werror_to_ntstatus(result);"); 468 349 } else { 469 350 warning($fn->{ORIGINAL}, "Unable to convert $fn->{RETURN_TYPE} to NTSTATUS"); … … 496 377 $self->pidl_hdr("#ifndef __CLI_$uif\__"); 497 378 $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); 501 393 } 502 394 $self->pidl_hdr("#endif /* __CLI_$uif\__ */"); … … 505 397 sub Parse($$$$) 506 398 { 507 my($self,$ndr,$header,$ ndr_header) = @_;399 my($self,$ndr,$header,$c_header) = @_; 508 400 509 401 $self->pidl("/*"); … … 514 406 $self->pidl("#include \"includes.h\""); 515 407 $self->pidl("#include \"$header\""); 516 $self->pidl_hdr("#include \"$ ndr_header\"");408 $self->pidl_hdr("#include \"$c_header\""); 517 409 $self->pidl(""); 518 410 -
vendor/current/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm
r414 r740 101 101 pidl "ZERO_STRUCT(r->out);" if ($hasout); 102 102 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"; 104 104 my $ret = "_$fn->{NAME}($pipes_struct, r"; 105 105 foreach (@{$fn->{ELEMENTS}}) { … … 139 139 my $op = "NDR_".uc($fn->{NAME}); 140 140 141 pidl "static bool api_$fn->{NAME}( pipes_struct *p)";141 pidl "static bool api_$fn->{NAME}(struct pipes_struct *p)"; 142 142 pidl "{"; 143 143 indent; … … 146 146 pidl "struct ndr_push *push;"; 147 147 pidl "enum ndr_err_code ndr_err;"; 148 pidl "DATA_BLOB blob;";149 148 pidl "struct $fn->{NAME} *r;"; 150 149 pidl ""; … … 156 155 pidl "}"; 157 156 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);"; 164 158 pidl "if (pull == NULL) {"; 165 159 pidl "\ttalloc_free(r);"; … … 168 162 pidl ""; 169 163 pidl "pull->flags |= LIBNDR_FLAG_REF_ALLOC;"; 164 pidl "if (p->endian) {"; 165 pidl "\tpull->flags |= LIBNDR_FLAG_BIGENDIAN;"; 166 pidl "}"; 170 167 pidl "ndr_err = call->ndr_pull(pull, NDR_IN, r);"; 171 168 pidl "if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {"; … … 175 172 pidl ""; 176 173 pidl "if (DEBUGLEVEL >= 10) {"; 177 pidl "\tNDR_PRINT_ IN_DEBUG($fn->{NAME}, r);";174 pidl "\tNDR_PRINT_FUNCTION_DEBUG($fn->{NAME}, NDR_IN, r);"; 178 175 pidl "}"; 179 176 pidl ""; … … 194 191 pidl ""; 195 192 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);"; 200 197 pidl "if (push == NULL) {"; 201 198 pidl "\ttalloc_free(r);"; 202 199 pidl "\treturn false;"; 203 200 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;"; 204 207 pidl ""; 205 208 pidl "ndr_err = call->ndr_push(push, NDR_OUT, r);"; … … 209 212 pidl "}"; 210 213 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);"; 216 216 pidl ""; 217 217 pidl "talloc_free(r);"; … … 220 220 deindent; 221 221 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 261 222 pidl ""; 262 223 } … … 302 263 pidl ""; 303 264 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 } 312 281 pidl_hdr "#endif /* __SRV_$uif\__ */"; 313 282 } … … 326 295 pidl ""; 327 296 pidl "#include \"includes.h\""; 297 pidl "#include \"ntdomain.h\""; 328 298 pidl "#include \"$header\""; 329 299 pidl_hdr "#include \"$ndr_header\""; -
vendor/current/pidl/lib/Parse/Pidl/Samba4.pm
r414 r740 19 19 $VERSION = '0.01'; 20 20 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 21 25 sub is_intree() 22 26 { 23 27 my $srcdir = $ENV{srcdir}; 24 28 $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"); 27 32 return 0; 28 33 } -
vendor/current/pidl/lib/Parse/Pidl/Samba4/COM/Stub.pm
r414 r740 90 90 91 91 pidl " 92 static NTSTATUS $name\__op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface )92 static NTSTATUS $name\__op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface, uint32_t if_version) 93 93 { 94 94 #ifdef DCESRV_INTERFACE_$uname\_BIND -
vendor/current/pidl/lib/Parse/Pidl/Samba4/Header.pm
r414 r740 6 6 7 7 package Parse::Pidl::Samba4::Header; 8 9 8 require Exporter; 10 9 … … 218 217 219 218 ##################################################################### 219 # parse a pipe 220 sub 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 ##################################################################### 220 243 # parse a type 221 244 sub HeaderType($$$;$) … … 227 250 ($data->{TYPE} eq "STRUCT") && HeaderStruct($data, $name, $tail); 228 251 ($data->{TYPE} eq "UNION") && HeaderUnion($data, $name, $tail); 252 ($data->{TYPE} eq "PIPE") && HeaderPipe($data, $name, $tail); 229 253 return; 230 254 } … … 387 411 HeaderEnum($t, $t->{NAME}, ";\n\n") if ($t->{TYPE} eq "ENUM"); 388 412 HeaderBitmap($t, $t->{NAME}) if ($t->{TYPE} eq "BITMAP"); 413 HeaderPipe($t, $t->{NAME}, "\n\n") if ($t->{TYPE} eq "PIPE"); 389 414 } 390 415 … … 413 438 %headerstructs = (); 414 439 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 415 454 if (!is_intree()) { 416 455 pidl "#include <util/data_blob.h>\n"; … … 429 468 } 430 469 470 pidl "#endif /* _PIDL_HEADER_$ifacename */\n"; 471 431 472 return $res; 432 473 } -
vendor/current/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
r414 r740 7 7 package Parse::Pidl::Samba4::NDR::Client; 8 8 9 use Parse::Pidl::Samba4 qw(choose_header is_intree); 10 use Parse::Pidl::Util qw(has_property); 9 use Exporter; 10 @ISA = qw(Exporter); 11 @EXPORT_OK = qw(Parse); 12 13 use Parse::Pidl qw(fatal warning error); 14 use Parse::Pidl::Util qw(has_property ParseExpr); 15 use Parse::Pidl::NDR qw(ContainsPipe); 16 use Parse::Pidl::Typelist qw(mapTypeName); 17 use Parse::Pidl::Samba4 qw(choose_header is_intree DeclLong); 18 use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv GenerateFunctionOutEnv); 11 19 12 20 use vars qw($VERSION); … … 15 23 use strict; 16 24 17 my($res,$res_hdr); 18 19 sub ParseFunctionSend($$$) 20 { 21 my ($interface, $fn, $name) = @_; 25 sub indent($) { my ($self) = @_; $self->{tabs}.="\t"; } 26 sub deindent($) { my ($self) = @_; $self->{tabs} = substr($self->{tabs}, 1); } 27 sub pidl($$) { my ($self,$txt) = @_; $self->{res} .= $txt ? "$self->{tabs}$txt\n" : "\n"; } 28 sub pidl_hdr($$) { my ($self, $txt) = @_; $self->{res_hdr} .= "$txt\n"; } 29 sub pidl_both($$) { my ($self, $txt) = @_; $self->{hdr} .= "$txt\n"; $self->{res_hdr} .= "$txt\n"; } 30 sub fn_declare($$) { my ($self,$n) = @_; $self->pidl($n); $self->pidl_hdr("$n;"); } 31 32 sub 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 41 sub new($) 42 { 43 my ($class) = shift; 44 my $self = { res => "", res_hdr => "", tabs => "" }; 45 bless($self, $class); 46 } 47 48 sub 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 59 sub ParseFunction_r_State($$$$) 60 { 61 my ($self, $if, $fn, $name) = @_; 22 62 my $uname = uc $name; 23 63 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 74 sub 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"; 32 120 } 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 143 sub ParseFunction_r_Done($$$$) 144 { 145 my ($self, $if, $fn, $name) = @_; 49 146 my $uname = uc $name; 50 147 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 175 sub 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 211 sub 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 247 sub 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 257 sub 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 276 sub 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}));"); 58 283 } 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 288 sub 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 302 sub 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 423 sub 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 442 sub 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 535 sub 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 602 sub 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 649 sub 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(""); 84 724 } 85 725 86 726 ##################################################################### 87 727 # parse a function 88 sub ParseFunction($$) 89 { 90 my ($interface, $fn) = @_; 91 92 ParseFunctionSend($interface, $fn, $fn->{NAME}); 93 ParseFunctionSync($interface, $fn, $fn->{NAME}); 728 sub 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(""); 94 805 } 95 806 … … 98 809 ##################################################################### 99 810 # 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}); 811 sub 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}}) { 115 829 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); 117 833 $done{$fn->{NAME}} = 1; 118 834 } 119 835 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 839 sub Parse($$$$$$) 840 { 841 my($self,$ndr,$header,$ndr_header,$client_header) = @_; 842 843 $self->pidl("/* client functions auto-generated by pidl */"); 844 $self->pidl(""); 134 845 if (is_intree()) { 135 $ res .= "#include \"includes.h\"\n";846 $self->pidl("#include \"includes.h\""); 136 847 } 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\""); 153 867 154 868 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}); 159 873 } 160 874 -
vendor/current/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
r414 r740 16 16 use Parse::Pidl::Util qw(has_property ParseExpr ParseExprExt print_uuid unmake_str); 17 17 use 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);18 use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred ContainsPipe is_charset_array); 19 19 use Parse::Pidl::Samba4 qw(is_intree choose_header ArrayDynamicallyAllocated); 20 20 use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv GenerateFunctionOutEnv EnvSubstituteValue GenerateStructEnv); … … 207 207 $self->pidl("NDR_CHECK(ndr_push_uint3264($ndr, NDR_SCALARS, $size));"); 208 208 } 209 209 210 210 if ($l->{IS_VARYING}) { 211 211 $self->pidl("NDR_CHECK(ndr_push_uint3264($ndr, NDR_SCALARS, 0));"); # array offset 212 212 $self->pidl("NDR_CHECK(ndr_push_uint3264($ndr, NDR_SCALARS, $length));"); 213 } 213 } 214 214 215 215 return $length; … … 575 575 $self->pidl("NDR_CHECK(ndr_push_relative_ptr2_start($ndr, $rel_var_name));"); 576 576 } 577 if ($l->{POINTER_TYPE} eq "relative_short") { 578 $self->pidl("NDR_CHECK(ndr_push_short_relative_ptr2($ndr, $var_name));"); 579 } 577 580 } 578 581 $var_name = get_value_of($var_name); … … 628 631 my $var_name = $env->{$e->{NAME}}; 629 632 633 return if ContainsPipe($e, $e->{LEVELS}[0]); 634 630 635 return unless $primitives or ($deferred and ContainsDeferred($e, $e->{LEVELS}[0])); 631 636 … … 675 680 } elsif ($l->{POINTER_TYPE} eq "relative") { 676 681 $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));"); 677 684 } elsif ($l->{POINTER_TYPE} eq "unique") { 678 685 $self->pidl("NDR_CHECK(ndr_push_unique_ptr($ndr, $var_name));"); … … 787 794 $self->pidl("for ($counter=0;$counter<$length;$counter++) {"); 788 795 $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;792 796 793 797 $var_name = get_array_element($var_name, $counter); … … 812 816 and not is_charset_array($e,$l) 813 817 and not has_fast_array($e,$l)) { 814 $self->pidl("free(idx_$l->{LEVEL_INDEX});");815 $self->deindent;816 $self->pidl("}");817 818 $self->deindent; 818 819 $self->pidl("}"); … … 866 867 $self->pidl("NDR_CHECK(".TypeFunctionName("ndr_pull", $l->{DATA_TYPE})."($ndr, $ndr_flags, $var_name));"); 867 868 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") { 869 873 $var_name = get_value_of($var_name); 870 874 my $signed = Parse::Pidl::Typelist::is_signed($l->{DATA_TYPE}); … … 944 948 if (($l->{TYPE} eq "POINTER") and ($l->{POINTER_TYPE} eq "ref")) { 945 949 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") { 952 955 $mem_flags = "LIBNDR_FLAG_REF_ALLOC"; 953 956 } … … 1010 1013 } elsif ($l->{TYPE} eq "ARRAY") { 1011 1014 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 } 1012 1029 1013 1030 my $nl = GetNextLevel($e, $l); … … 1043 1060 $self->indent; 1044 1061 1045 if ($l->{POINTER_TYPE} eq "relative" ) {1062 if ($l->{POINTER_TYPE} eq "relative" or $l->{POINTER_TYPE} eq "relative_short") { 1046 1063 $self->pidl("uint32_t _relative_save_offset;"); 1047 1064 $self->pidl("_relative_save_offset = $ndr->offset;"); … … 1058 1075 1059 1076 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("}"); 1061 1083 $self->pidl("$ndr->offset = _relative_save_offset;"); 1062 1084 } … … 1072 1094 if ($l->{IS_VARYING}) { 1073 1095 $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("}"); 1074 1110 } 1075 1111 … … 1116 1152 my $represent_name; 1117 1153 my $transmit_name; 1154 1155 return if ContainsPipe($e, $e->{LEVELS}[0]); 1118 1156 1119 1157 return unless $primitives or ($deferred and ContainsDeferred($e, $e->{LEVELS}[0])); … … 1162 1200 $self->pidl("}"); 1163 1201 } 1164 1202 1165 1203 return; 1166 1204 } elsif ($l->{POINTER_TYPE} eq "ref" and $l->{LEVEL} eq "EMBEDDED") { … … 1170 1208 ($l->{POINTER_TYPE} eq "full")) { 1171 1209 $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}));"); 1172 1212 } else { 1173 1213 die("Unhandled pointer type $l->{POINTER_TYPE}"); … … 1190 1230 1191 1231 #$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") { 1193 1233 $self->pidl("NDR_CHECK(ndr_pull_relative_ptr1($ndr, $var_name, _ptr_$e->{NAME}));"); 1194 1234 } … … 1455 1495 1456 1496 $self->pidl("ndr_print_struct($ndr, name, \"$name\");"); 1497 $self->pidl("if (r == NULL) { ndr_print_null($ndr); return; }"); 1457 1498 1458 1499 $self->start_flags($struct, $ndr); … … 1471 1512 my ($self,$e) = @_; 1472 1513 foreach my $l (@{$e->{LEVELS}}) { 1514 my $size = 32; 1473 1515 if ($l->{TYPE} eq "POINTER" and 1474 1516 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};"); 1476 1521 last; 1477 1522 } … … 1603 1648 $self->pidl("flags |= $flags;"); 1604 1649 } 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);"); 1606 1651 } 1607 1652 … … 1615 1660 { 1616 1661 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"; 1618 1663 } 1619 1664 … … 1638 1683 } 1639 1684 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);"); 1641 1686 } 1642 1687 … … 1647 1692 my $have_default = 0; 1648 1693 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);"); 1650 1695 1651 1696 if (defined($e->{SWITCH_TYPE})) { 1697 if (defined($e->{ALIGN})) { 1698 $self->pidl("NDR_CHECK(ndr_push_union_align($ndr, $e->{ALIGN}));"); 1699 } 1700 1652 1701 $self->pidl("NDR_CHECK(ndr_push_$e->{SWITCH_TYPE}($ndr, NDR_SCALARS, level));"); 1653 1702 } 1654 1703 1655 1704 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 } 1657 1711 } 1658 1712 … … 1694 1748 my $have_default = 0; 1695 1749 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);"); 1697 1751 if (defined($e->{PROPERTIES}{relative_base})) { 1698 1752 # retrieve the current offset as base for relative pointers … … 1753 1807 my $have_default = 0; 1754 1808 1755 $self->pidl(" int level;");1809 $self->pidl("uint32_t level;"); 1756 1810 foreach my $el (@{$e->{ELEMENTS}}) { 1757 1811 $self->DeclareArrayVariables($el); … … 1794 1848 my $have_default = 0; 1795 1849 1850 1796 1851 if (defined($switch_type)) { 1852 if (defined($e->{ALIGN})) { 1853 $self->pidl("NDR_CHECK(ndr_pull_union_align($ndr, $e->{ALIGN}));"); 1854 } 1855 1797 1856 $self->pidl("NDR_CHECK(ndr_pull_$switch_type($ndr, NDR_SCALARS, &_level));"); 1798 1857 $self->pidl("if (_level != level) {"); … … 1802 1861 1803 1862 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 } 1805 1869 } 1806 1870 … … 1880 1944 my $switch_type = $e->{SWITCH_TYPE}; 1881 1945 1882 $self->pidl(" int level;");1946 $self->pidl("uint32_t level;"); 1883 1947 if (defined($switch_type)) { 1884 1948 if (Parse::Pidl::Typelist::typeIs($switch_type, "ENUM")) { … … 1926 1990 { 1927 1991 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"; 1929 1993 } 1930 1994 … … 2004 2068 }; 2005 2069 2070 sub 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 2103 sub 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 2136 sub 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 2006 2163 ##################################################################### 2007 2164 # parse a function - print side … … 2024 2181 2025 2182 $self->pidl("ndr_print_struct($ndr, name, \"$fn->{NAME}\");"); 2183 $self->pidl("if (r == NULL) { ndr_print_null($ndr); return; }"); 2026 2184 $self->pidl("$ndr->depth++;"); 2027 2185 … … 2205 2363 next if (($e->{LEVELS}[1]->{TYPE} eq "DATA") and 2206 2364 ($e->{LEVELS}[1]->{DATA_TYPE} eq "string")); 2365 next if ($e->{LEVELS}[1]->{TYPE} eq "PIPE"); 2207 2366 next if (($e->{LEVELS}[1]->{TYPE} eq "ARRAY") 2208 2367 and $e->{LEVELS}[1]->{IS_ZERO_TERMINATED}); … … 2219 2378 } else { 2220 2379 $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;"); 2221 2386 } 2222 2387 } else { … … 2278 2443 } 2279 2444 2445 sub 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 2475 sub 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 2280 2503 sub FunctionCallEntry($$) 2281 2504 { 2282 2505 my ($self, $d) = @_; 2283 2506 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 2284 2533 $self->pidl("\t{"); 2285 2534 $self->pidl("\t\t\"$d->{NAME}\","); … … 2288 2537 $self->pidl("\t\t(ndr_pull_flags_fn_t) ndr_pull_$d->{NAME},"); 2289 2538 $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 },"); 2291 2541 $self->pidl("\t},"); 2292 2542 return 1; … … 2304 2554 return unless defined ($interface->{PROPERTIES}->{uuid}); 2305 2555 2556 foreach my $d (@{$interface->{INHERITED_FUNCTIONS}},@{$interface->{FUNCTIONS}}) { 2557 $self->FunctionCallPipes($d); 2558 } 2559 2306 2560 $self->pidl("static const struct ndr_interface_call $interface->{NAME}\_calls[] = {"); 2307 2561 … … 2309 2563 $count += $self->FunctionCallEntry($d); 2310 2564 } 2311 $self->pidl("\t{ NULL, 0, NULL, NULL, NULL , false}");2565 $self->pidl("\t{ NULL, 0, NULL, NULL, NULL }"); 2312 2566 $self->pidl("};"); 2313 2567 $self->pidl(""); … … 2557 2811 # Typedefs 2558 2812 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 2559 2827 next unless(typeHasBody($d)); 2560 2828 … … 2576 2844 ($needed->{"ndr_pull_$d->{NAME}"}) && $self->ParseFunctionPull($d); 2577 2845 ($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;2582 2846 } 2583 2847 … … 2702 2966 2703 2967 NeededType($t->{DATA}, $needed, $req) if ($t->{TYPE} eq "TYPEDEF"); 2968 NeededType($t->{DATA}, $needed, $req) if ($t->{TYPE} eq "PIPE"); 2704 2969 2705 2970 if ($t->{TYPE} eq "STRUCT" or $t->{TYPE} eq "UNION") { … … 2723 2988 NeededFunction($_, $needed) foreach (@{$interface->{FUNCTIONS}}); 2724 2989 foreach (reverse @{$interface->{TYPES}}) { 2990 2725 2991 if (has_property($_, "public")) { 2726 2992 $needed->{TypeFunctionName("ndr_pull", $_)} = $needed->{TypeFunctionName("ndr_push", $_)} = -
vendor/current/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm
r414 r740 82 82 83 83 pidl " 84 static NTSTATUS $name\__op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface )84 static NTSTATUS $name\__op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface, uint32_t if_version) 85 85 { 86 86 #ifdef DCESRV_INTERFACE_$uname\_BIND -
vendor/current/pidl/lib/Parse/Pidl/Samba4/Python.pm
r414 r740 13 13 use Parse::Pidl::Typelist qw(hasType resolveType getType mapTypeName expandAlias); 14 14 use Parse::Pidl::Util qw(has_property ParseExpr unmake_str); 15 use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred is_charset_array);15 use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred ContainsPipe is_charset_array); 16 16 use Parse::Pidl::CUtil qw(get_value_of get_pointer_to); 17 17 use Parse::Pidl::Samba4 qw(ArrayDynamicallyAllocated); … … 25 25 my $self = { res => "", res_hdr => "", tabs => "", constants => {}, 26 26 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 => []}; 29 30 bless($self, $class); 30 31 } … … 64 65 my ($name, $basename) = @_; 65 66 67 $basename =~ s/^.*\.([^.]+)$/\1/; 68 66 69 $name =~ s/^$basename\_//; 70 67 71 68 72 return $name; … … 77 81 s/\.idl$//; 78 82 $self->pidl_hdr("#include \"librpc/gen_ndr/$_\.h\"\n"); 79 $self->register_module_import( $_);83 $self->register_module_import("samba.dcerpc.$_"); 80 84 } 81 85 } … … 127 131 } else { 128 132 $self->pidl("ret = Py_None;"); 133 $self->pidl("Py_INCREF(ret);"); 129 134 } 130 135 … … 214 219 not ($nl->{TYPE} eq "ARRAY" and ($nl->{IS_FIXED} or is_charset_array($e, $nl))) and 215 220 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);"); 217 222 } 218 223 $self->ConvertObjectFromPython($env, $mem_ctx, $e, "value", $varname, "return -1;"); … … 254 259 $self->pidl("DATA_BLOB blob;"); 255 260 $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);"); 257 262 $self->pidl("if (err != NDR_ERR_SUCCESS) {"); 258 263 $self->indent; … … 276 281 $self->pidl("\treturn NULL;"); 277 282 $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);"); 296 284 $self->pidl("if (err != NDR_ERR_SUCCESS) {"); 297 285 $self->indent; … … 305 293 $self->pidl("}"); 306 294 $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 307 312 $py_methods = "py_$name\_methods"; 308 313 $self->pidl("static PyMethodDef $py_methods\[] = {"); 309 314 $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\" },"); 312 318 $self->pidl("{ NULL, NULL, 0, NULL }"); 313 319 $self->deindent; … … 324 330 $self->pidl("PyObject_HEAD_INIT(NULL) 0,"); 325 331 $self->pidl(".tp_name = \"$modulename.$prettyname\","); 326 $self->pidl(".tp_basicsize = sizeof(py_talloc_Object),");327 $self->pidl(".tp_dealloc = py_talloc_dealloc,");328 332 $self->pidl(".tp_getset = $getsetters,"); 329 $self->pidl(".tp_repr = py_talloc_default_repr,");330 333 if ($docstring) { 331 334 $self->pidl(".tp_doc = $docstring,"); … … 333 336 $self->pidl(".tp_methods = $py_methods,"); 334 337 $self->pidl(".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,"); 338 $self->pidl(".tp_basicsize = sizeof(py_talloc_Object),"); 335 339 $self->pidl(".tp_new = py_$name\_new,"); 336 340 $self->deindent; … … 338 342 339 343 $self->pidl(""); 344 345 my $talloc_typename = $self->import_type_variable("talloc", "Object"); 346 $self->register_module_prereadycode(["$name\_Type.tp_base = $talloc_typename;", ""]); 340 347 341 348 return "&$typeobject"; … … 389 396 $self->pidl("{"); 390 397 $self->indent; 391 $self->pidl("PyObject *result = Py_None;");398 $self->pidl("PyObject *result;"); 392 399 foreach my $e (@{$fn->{ELEMENTS}}) { 393 400 next unless (grep(/out/,@{$e->{DIRECTION}})); … … 408 415 $signature .= "("; 409 416 } elsif ($result_size == 0) { 417 $self->pidl("result = Py_None;"); 418 $self->pidl("Py_INCREF(result);"); 410 419 $signature .= "None"; 411 420 } … … 506 515 my $py_var = "py_".$metadata_args->{in}->{$e->{NAME}}; 507 516 $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)"; 509 518 if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") { 510 519 $self->pidl("r->in.$e->{NAME} = talloc_ptrtype(r, r->in.$e->{NAME});"); … … 531 540 my $docstring = $self->DocString($fn, $fn->{NAME}); 532 541 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"; 540 547 } 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\""; 549 549 } 550 550 … … 664 664 665 665 foreach my $d (@{$interface->{FUNCTIONS}}) { 666 next if not defined($d->{OPNUM});666 next if has_property($d, "noopnum"); 667 667 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; 668 678 669 679 my $prettyname = $d->{NAME}; … … 674 684 my ($infn, $outfn, $fndocstring) = $self->PythonFunction($d, $interface->{NAME}, $prettyname); 675 685 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}]); 677 687 } 678 688 … … 681 691 foreach my $d (@fns) { 682 692 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} },"); 684 694 } 685 695 $self->pidl("{ NULL }"); … … 712 722 } 713 723 714 $self->pidl("static PyTypeObject $interface->{NAME}_InterfaceType = {"); 724 my $if_typename = "$interface->{NAME}_InterfaceType"; 725 726 $self->pidl("static PyTypeObject $if_typename = {"); 715 727 $self->indent; 716 728 $self->pidl("PyObject_HEAD_INIT(NULL) 0,"); 717 729 $self->pidl(".tp_name = \"$basename.$interface->{NAME}\","); 718 730 $self->pidl(".tp_basicsize = sizeof(dcerpc_InterfaceObject),"); 719 $self->pidl(".tp_base = &dcerpc_InterfaceType,");720 731 $self->pidl(".tp_doc = $docstring,"); 721 732 $self->pidl(".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,"); … … 726 737 $self->pidl(""); 727 738 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;", ""]); 730 743 } 731 744 … … 744 757 my ($self, $name, $py_name) = @_; 745 758 746 $self->register_module_object($name, "(PyObject *) $py_name");759 $self->register_module_object($name, "(PyObject *)(void *)$py_name"); 747 760 748 761 $self->check_ready_type($py_name); … … 759 772 sub register_module_import($$) 760 773 { 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 785 sub 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"; 764 794 } 765 795 … … 769 799 # FIXME: Have a global lookup table for types that look different on the 770 800 # 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") { 772 802 $orig_ctype->{NAME} = "dom_sid"; 773 803 } … … 778 808 # If this is an external type, make sure we do the right imports. 779 809 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}); 785 811 } 786 812 return "&$ctype->{NAME}_Type"; … … 795 821 } 796 822 797 sub register_module_ readycode($$)823 sub register_module_prereadycode($$) 798 824 { 799 825 my ($self, $code) = @_; 800 826 801 push (@{$self->{readycode}}, @$code); 827 push (@{$self->{prereadycode}}, @$code); 828 } 829 830 sub register_module_postreadycode($$) 831 { 832 my ($self, $code) = @_; 833 834 push (@{$self->{postreadycode}}, @$code); 802 835 } 803 836 … … 815 848 $self->pidl("memset($dest, 0, sizeof(" . get_value_of($dest) . "));"); 816 849 } 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;"); 818 852 } else { 819 853 $self->pidl("$dest = $src;"); … … 834 868 } 835 869 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; 840 877 $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("}"); 841 886 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 } 842 912 } 843 913 … … 846 916 unless (defined ($ctype_name)) { 847 917 error($location, "Unable to determine origin of type `" . mapTypeName($ctype) . "'"); 848 $self->pidl("PyErr_SetString(PyExc_TypeError, \"Can not convert C Type " . mapTypeName($ctype) . " toPython\");");918 $self->pidl("PyErr_SetString(PyExc_TypeError, \"Can not convert C Type " . mapTypeName($ctype) . " from Python\");"); 849 919 return; 850 920 } 851 921 $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)"); 853 929 return; 854 930 } 855 931 856 932 if ($actual_ctype->{TYPE} eq "SCALAR" and $actual_ctype->{NAME} eq "DATA_BLOB") { 857 $self->pidl("$target = data_blob_talloc($mem_ctx, PyString_A sString($cvar), PyString_Size($cvar));");933 $self->pidl("$target = data_blob_talloc($mem_ctx, PyString_AS_STRING($cvar), PyString_GET_SIZE($cvar));"); 858 934 return; 859 935 } … … 861 937 if ($actual_ctype->{TYPE} eq "SCALAR" and 862 938 ($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_A sString($cvar));");939 $self->pidl("$target = talloc_strdup($mem_ctx, PyString_AS_STRING($cvar));"); 864 940 return; 865 941 } 866 942 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 867 948 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") { 868 954 $self->pidl("$target = PyString_AsString($cvar);"); 869 955 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 } 872 967 873 968 if ($actual_ctype->{TYPE} eq "SCALAR" and $actual_ctype->{NAME} eq "NTSTATUS") { … … 899 994 my ($self, $env, $mem_ctx, $py_var, $e, $l, $var_name, $fail) = @_; 900 995 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 } 901 1003 902 1004 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 }907 1005 if ($l->{POINTER_TYPE} ne "ref") { 908 1006 $self->pidl("if ($py_var == Py_None) {"); … … 913 1011 $self->indent; 914 1012 } 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); 917 1027 if ($l->{POINTER_TYPE} ne "ref") { 918 1028 $self->deindent; … … 920 1030 } 921 1031 } elsif ($l->{TYPE} eq "ARRAY") { 922 my $pl = GetPrevLevel($e, $l);923 1032 if ($pl && $pl->{TYPE} eq "POINTER") { 924 1033 $var_name = get_pointer_to($var_name); … … 926 1035 927 1036 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; 929 1039 # 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("}"); 931 1052 } else { 932 1053 my $counter = "$e->{NAME}_cntr_$l->{LEVEL_INDEX}"; … … 936 1057 $self->pidl("int $counter;"); 937 1058 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\");"); 939 1062 } 940 $self->pidl("for ($counter = 0; $counter < PyList_ Size($py_var); $counter++) {");941 $self->indent; 942 $self->ConvertObjectFromPythonLevel($env, $var_name, "PyList_G etItem($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); 943 1066 $self->deindent; 944 1067 $self->pidl("}"); … … 947 1070 } 948 1071 } elsif ($l->{TYPE} eq "DATA") { 949 950 1072 if (not Parse::Pidl::Typelist::is_scalar($l->{DATA_TYPE})) { 951 1073 $var_name = get_pointer_to($var_name); … … 955 1077 $var_name = get_pointer_to($var_name); 956 1078 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("}"); 958 1089 } 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); 960 1091 } else { 961 1092 fatal($e->{ORIGINAL}, "unknown level type $l->{TYPE}"); … … 978 1109 $ctypename = expandAlias($ctypename); 979 1110 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)$/) { 981 1116 return "PyInt_FromLong($cvar)"; 982 1117 } … … 995 1130 996 1131 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)"; 998 1137 } 999 1138 1000 1139 # Not yet supported 1001 1140 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)"; } 1003 1145 if ($ctypename eq "pointer") { 1004 1146 return "PyCObject_FromTallocPtr($cvar)"; … … 1055 1197 my ($self, $mem_ctx, $env, $e, $l, $var_name, $py_var, $fail) = @_; 1056 1198 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 } 1057 1206 1058 1207 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 }1063 1208 if ($l->{POINTER_TYPE} ne "ref") { 1064 1209 $self->pidl("if ($var_name == NULL) {"); 1065 1210 $self->indent; 1066 1211 $self->pidl("$py_var = Py_None;"); 1212 $self->pidl("Py_INCREF($py_var);"); 1067 1213 $self->deindent; 1068 1214 $self->pidl("} else {"); 1069 1215 $self->indent; 1070 1216 } 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); 1072 1222 if ($l->{POINTER_TYPE} ne "ref") { 1073 1223 $self->deindent; … … 1075 1225 } 1076 1226 } elsif ($l->{TYPE} eq "ARRAY") { 1077 my $pl = GetPrevLevel($e, $l);1078 1227 if ($pl && $pl->{TYPE} eq "POINTER") { 1079 1228 $var_name = get_pointer_to($var_name); … … 1082 1231 if (is_charset_array($e, $l)) { 1083 1232 # 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; 1084 1240 $self->pidl("$py_var = PyUnicode_Decode($var_name, strlen($var_name), \"utf-8\", \"ignore\");"); 1241 $self->deindent; 1242 $self->pidl("}"); 1085 1243 } else { 1086 1244 die("No SIZE_IS for array $var_name") unless (defined($l->{SIZE_IS})); … … 1101 1259 my $member_var = "py_$e->{NAME}_$l->{LEVEL_INDEX}"; 1102 1260 $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); 1104 1262 $self->pidl("PyList_SetItem($py_var, $counter, $member_var);"); 1105 1263 $self->deindent; … … 1111 1269 $var_name = get_pointer_to($var_name); 1112 1270 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);"); 1114 1272 $self->fail_on_null($py_var, $fail); 1115 1273 … … 1121 1279 $self->pidl("$py_var = $conv;"); 1122 1280 } 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); 1124 1282 } else { 1125 1283 fatal($e->{ORIGINAL}, "Unknown level type $l->{TYPE} $var_name"); … … 1142 1300 $self->pidl_hdr(" 1143 1301 /* Python wrapper functions auto-generated by pidl */ 1302 #include <Python.h> 1144 1303 #include \"includes.h\" 1145 #include <Python.h> 1146 #include \"librpc/rpc/dcerpc.h\" 1147 #include \"lib/talloc/pytalloc.h\" 1304 #include <pytalloc.h> 1148 1305 #include \"librpc/rpc/pyrpc.h\" 1306 #include \"librpc/rpc/pyrpc_util.h\" 1149 1307 #include \"$hdr\" 1150 1308 #include \"$ndr_hdr\" 1151 1152 #ifndef Py_RETURN_NONE1153 #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None1154 #endif1155 1309 1156 1310 "); … … 1174 1328 $self->pidl(""); 1175 1329 1330 $self->pidl_hdr("void init$basename(void);"); 1176 1331 $self->pidl("void init$basename(void)"); 1177 1332 $self->pidl("{"); 1178 1333 $self->indent; 1179 1334 $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)"); 1188 1345 $self->pidl("\treturn;"); 1189 1346 $self->pidl(""); … … 1191 1348 1192 1349 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)"); 1198 1358 $self->pidl("\treturn;"); 1199 1359 $self->pidl(""); 1200 1360 } 1361 1362 $self->pidl($_) foreach (@{$self->{prereadycode}}); 1201 1363 1202 1364 foreach (@{$self->{ready_types}}) { … … 1205 1367 } 1206 1368 1207 $self->pidl($_) foreach (@{$self->{ readycode}});1369 $self->pidl($_) foreach (@{$self->{postreadycode}}); 1208 1370 1209 1371 foreach (@{$self->{patch_type_calls}}) { -
vendor/current/pidl/lib/Parse/Pidl/Typelist.pm
r414 r740 9 9 @ISA = qw(Exporter); 10 10 @EXPORT_OK = qw(hasType getType resolveType mapTypeName scalar_is_reference expandAlias 11 12 bitmap_type_fn mapType typeHasBody11 mapScalarType addType typeIs is_signed is_scalar enum_type_fn 12 bitmap_type_fn mapType typeHasBody is_fixed_size_scalar 13 13 ); 14 14 use vars qw($VERSION); … … 21 21 22 22 my @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 28 my @non_fixed_size_scalars = ( 29 "string", "string_array", "nbt_string", "dns_string", 30 "wrepl_nbt_name", "dnsp_name", "dnsp_string" 25 31 ); 26 32 … … 37 43 "int32" => "int32_t", 38 44 "uint32" => "uint32_t", 45 "int3264" => "int32_t", 46 "uint3264" => "uint32_t", 39 47 "hyper" => "uint64_t", 40 48 "dlong" => "int64_t", … … 47 55 "string_array" => "const char **", 48 56 "time_t" => "time_t", 57 "uid_t" => "uid_t", 58 "gid_t" => "gid_t", 49 59 "NTTIME" => "NTTIME", 50 60 "NTTIME_1sec" => "NTTIME", … … 53 63 "NTSTATUS" => "NTSTATUS", 54 64 "COMRESULT" => "COMRESULT", 65 "dns_string" => "const char *", 55 66 "nbt_string" => "const char *", 56 67 "wrepl_nbt_name"=> "struct nbt_name *", 57 68 "ipv4address" => "const char *", 69 "ipv6address" => "const char *", 70 "dnsp_name" => "const char *", 71 "dnsp_string" => "const char *", 58 72 ); 59 73 … … 123 137 } 124 138 139 sub typeIs($$); 125 140 sub typeIs($$) 126 141 { 127 142 my ($t,$tt) = @_; 128 143 129 144 if (ref($t) eq "HASH") { 145 return 1 if ($t->{TYPE} eq "TYPEDEF" and $t->{DATA}->{TYPE} eq $tt); 130 146 return 1 if ($t->{TYPE} eq $tt); 131 147 return 0; 132 148 } 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 } 135 152 return 0; 136 153 } … … 178 195 179 196 return 0; 197 } 198 199 sub 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; 180 206 } 181 207 … … 266 292 return "union $n" if ($t->{TYPE} eq "UNION"); 267 293 return mapScalarType(bitmap_type_fn($t)) if ($t->{TYPE} eq "BITMAP"); 294 return "struct $n" if ($t->{TYPE} eq "PIPE"); 268 295 die("Unknown type $t->{TYPE}"); 269 296 } … … 304 331 305 332 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") { 311 339 $y->{BASEFILE} = $basename; 312 340 addType($y); -
vendor/current/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm
r414 r740 111 111 use Parse::Pidl qw(fatal warning error); 112 112 use Parse::Pidl::Util qw(has_property); 113 use Parse::Pidl::Typelist qw(addType); 113 114 114 115 sub handle_type($$$$$$$$$$) … … 150 151 ALIGNMENT => $alignment 151 152 }; 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 }); 152 164 } 153 165 -
vendor/current/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
r414 r740 1 1 ################################################## 2 # Samba4NDR parser generator for IDL structures2 # Wireshark NDR parser generator for IDL structures 3 3 # Copyright tridge@samba.org 2000-2003 4 4 # Copyright tpot@samba.org 2001,2005 … … 546 546 $self->pidl_code("proto_item *item = NULL;"); 547 547 $self->pidl_code("proto_tree *tree = NULL;"); 548 if ($e->{ALIGN} > 1) { 549 $self->pidl_code("dcerpc_info *di = pinfo->private_data;"); 550 } 548 551 $self->pidl_code("int old_offset;"); 549 552 $self->pidl_code(""); … … 566 569 567 570 $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(""); 568 580 $self->pidl_code("return offset;"); 569 581 $self->deindent; … … 635 647 $self->pidl_code("switch(level) {$res\t}"); 636 648 $self->pidl_code("proto_item_set_len(item, offset-old_offset);\n"); 649 $self->pidl_code(""); 650 637 651 $self->pidl_code("return offset;"); 638 652 $self->deindent; … … 873 887 $self->register_type("GUID", "offset = dissect_ndr_uuid_t(tvb, offset, pinfo, tree, drep, \@HF\@, NULL);","FT_GUID", "BASE_NONE", 0, "NULL", 4); 874 888 $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); 879 893 $self->register_type("SID", " 880 894 dcerpc_info *di = (dcerpc_info *)pinfo->private_data; … … 896 910 { 897 911 my($self,$ndr,$idl_file,$h_filename,$cnf_file) = @_; 898 912 899 913 $self->Initialize($cnf_file); 900 914
Note:
See TracChangeset
for help on using the changeset viewer.