@@ -1414,115 +1414,6 @@ mono_get_exception_class (void)
1414
1414
return mono_defaults .exception_class ;
1415
1415
}
1416
1416
1417
-
1418
- static char * get_attribute_value (const gchar * * attribute_names ,
1419
- const gchar * * attribute_values ,
1420
- const char * att_name )
1421
- {
1422
- int n ;
1423
- for (n = 0 ; attribute_names [n ] != NULL ; n ++ ) {
1424
- if (strcmp (attribute_names [n ], att_name ) == 0 )
1425
- return g_strdup (attribute_values [n ]);
1426
- }
1427
- return NULL ;
1428
- }
1429
-
1430
- static void start_element (GMarkupParseContext * context ,
1431
- const gchar * element_name ,
1432
- const gchar * * attribute_names ,
1433
- const gchar * * attribute_values ,
1434
- gpointer user_data ,
1435
- GError * * gerror )
1436
- {
1437
- AppConfigInfo * app_config = (AppConfigInfo * ) user_data ;
1438
-
1439
- if (strcmp (element_name , "configuration" ) == 0 ) {
1440
- app_config -> configuration_count ++ ;
1441
- return ;
1442
- }
1443
- if (strcmp (element_name , "startup" ) == 0 ) {
1444
- app_config -> startup_count ++ ;
1445
- return ;
1446
- }
1447
-
1448
- if (app_config -> configuration_count != 1 || app_config -> startup_count != 1 )
1449
- return ;
1450
-
1451
- if (strcmp (element_name , "requiredRuntime" ) == 0 ) {
1452
- app_config -> required_runtime = get_attribute_value (attribute_names , attribute_values , "version" );
1453
- } else if (strcmp (element_name , "supportedRuntime" ) == 0 ) {
1454
- char * version = get_attribute_value (attribute_names , attribute_values , "version" );
1455
- app_config -> supported_runtimes = g_slist_append (app_config -> supported_runtimes , version );
1456
- }
1457
- }
1458
-
1459
- static void end_element (GMarkupParseContext * context ,
1460
- const gchar * element_name ,
1461
- gpointer user_data ,
1462
- GError * * gerror )
1463
- {
1464
- AppConfigInfo * app_config = (AppConfigInfo * ) user_data ;
1465
-
1466
- if (strcmp (element_name , "configuration" ) == 0 ) {
1467
- app_config -> configuration_count -- ;
1468
- } else if (strcmp (element_name , "startup" ) == 0 ) {
1469
- app_config -> startup_count -- ;
1470
- }
1471
- }
1472
-
1473
- static const GMarkupParser
1474
- mono_parser = {
1475
- start_element ,
1476
- end_element ,
1477
- NULL ,
1478
- NULL ,
1479
- NULL
1480
- };
1481
-
1482
- static AppConfigInfo *
1483
- app_config_parse (const char * exe_filename )
1484
- {
1485
- AppConfigInfo * app_config ;
1486
- GMarkupParseContext * context ;
1487
- char * text ;
1488
- gsize len ;
1489
- char * config_filename ;
1490
-
1491
- config_filename = g_strconcat (exe_filename , ".config" , (const char * )NULL );
1492
-
1493
- if (!g_file_get_contents (config_filename , & text , & len , NULL )) {
1494
- g_free (config_filename );
1495
- return NULL ;
1496
- }
1497
- g_free (config_filename );
1498
-
1499
- app_config = g_new0 (AppConfigInfo , 1 );
1500
-
1501
- context = g_markup_parse_context_new (& mono_parser , (GMarkupParseFlags )0 , app_config , NULL );
1502
- if (g_markup_parse_context_parse (context , text , len , NULL )) {
1503
- g_markup_parse_context_end_parse (context , NULL );
1504
- }
1505
- g_markup_parse_context_free (context );
1506
- g_free (text );
1507
- return app_config ;
1508
- }
1509
-
1510
- static void
1511
- app_config_free (AppConfigInfo * app_config )
1512
- {
1513
- char * rt ;
1514
- GSList * list = app_config -> supported_runtimes ;
1515
- while (list != NULL ) {
1516
- rt = (char * )list -> data ;
1517
- g_free (rt );
1518
- list = g_slist_next (list );
1519
- }
1520
- g_slist_free (app_config -> supported_runtimes );
1521
- g_free (app_config -> required_runtime );
1522
- g_free (app_config );
1523
- }
1524
-
1525
-
1526
1417
static const MonoRuntimeInfo *
1527
1418
get_runtime_by_version (const char * version )
1528
1419
{
@@ -1552,43 +1443,10 @@ get_runtime_by_version (const char *version)
1552
1443
static GSList *
1553
1444
get_runtimes_from_exe (const char * file , MonoImage * * out_image )
1554
1445
{
1555
- AppConfigInfo * app_config ;
1556
- char * version ;
1557
1446
const MonoRuntimeInfo * runtime = NULL ;
1558
1447
MonoImage * image = NULL ;
1559
1448
GSList * runtimes = NULL ;
1560
1449
1561
- app_config = app_config_parse (file );
1562
-
1563
- if (app_config != NULL ) {
1564
- /* Check supportedRuntime elements, if none is supported, fail.
1565
- * If there are no such elements, look for a requiredRuntime element.
1566
- */
1567
- if (app_config -> supported_runtimes != NULL ) {
1568
- GSList * list = app_config -> supported_runtimes ;
1569
- while (list != NULL ) {
1570
- version = (char * ) list -> data ;
1571
- runtime = get_runtime_by_version (version );
1572
- if (runtime != NULL )
1573
- runtimes = g_slist_prepend (runtimes , (gpointer )runtime );
1574
- list = g_slist_next (list );
1575
- }
1576
- runtimes = g_slist_reverse (runtimes );
1577
- app_config_free (app_config );
1578
- return runtimes ;
1579
- }
1580
-
1581
- /* Check the requiredRuntime element. This is for 1.0 apps only. */
1582
- if (app_config -> required_runtime != NULL ) {
1583
- const MonoRuntimeInfo * runtime = get_runtime_by_version (app_config -> required_runtime );
1584
- if (runtime != NULL )
1585
- runtimes = g_slist_prepend (runtimes , (gpointer )runtime );
1586
- app_config_free (app_config );
1587
- return runtimes ;
1588
- }
1589
- app_config_free (app_config );
1590
- }
1591
-
1592
1450
/* Look for a runtime with the exact version */
1593
1451
image = mono_assembly_open_from_bundle (mono_domain_default_alc (mono_domain_get ()), file , NULL , NULL );
1594
1452
0 commit comments