1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[450] Import cleaned tools</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd>450</dd>
<dt>Author</dt> <dd>dmorgan</dd>
<dt>Date</dt> <dd>2011-02-07 00:23:30 +0100 (Mon, 07 Feb 2011)</dd>
</dl>
<h3>Log Message</h3>
<pre>Import cleaned tools</pre>
<h3>Added Paths</h3>
<ul>
<li>drakx/trunk/tools/</li>
<li><a href="#drakxtrunktoolsperl_checker">drakx/trunk/tools/.perl_checker</a></li>
<li><a href="#drakxtrunktoolsMakefile">drakx/trunk/tools/Makefile</a></li>
<li><a href="#drakxtrunktoolscheckusedmodules">drakx/trunk/tools/checkusedmodules</a></li>
<li><a href="#drakxtrunktoolsdrakxinchroot">drakx/trunk/tools/drakx-in-chroot</a></li>
<li><a href="#drakxtrunktoolsextractchangelog">drakx/trunk/tools/extractchangelog</a></li>
<li><a href="#drakxtrunktoolsgetneededdrakxmodules">drakx/trunk/tools/get-needed-drakx-modules</a></li>
<li><a href="#drakxtrunktoolshd_grubcgi">drakx/trunk/tools/hd_grub.cgi</a></li>
<li>drakx/trunk/tools/i386/</li>
<li>drakx/trunk/tools/ia64/</li>
<li><a href="#drakxtrunktoolsinstallxmlfilelist">drakx/trunk/tools/install-xml-file-list</a></li>
<li><a href="#drakxtrunktoolsmake_lang_png_transparentc">drakx/trunk/tools/make_lang_png_transparent.c</a></li>
<li><a href="#drakxtrunktoolsmdkinst_stage2_tool">drakx/trunk/tools/mdkinst_stage2_tool</a></li>
<li><a href="#drakxtrunktoolsntp_serverspl">drakx/trunk/tools/ntp_servers.pl</a></li>
<li>drakx/trunk/tools/ppc/</li>
<li><a href="#drakxtrunktoolsrpcinfoflushedc">drakx/trunk/tools/rpcinfo-flushed.c</a></li>
<li>drakx/trunk/tools/serial_probe/</li>
<li><a href="#drakxtrunktoolsserial_probeMakefile">drakx/trunk/tools/serial_probe/Makefile</a></li>
<li><a href="#drakxtrunktoolsserial_probedeviceh">drakx/trunk/tools/serial_probe/device.h</a></li>
<li><a href="#drakxtrunktoolsserial_probekudzuh">drakx/trunk/tools/serial_probe/kudzu.h</a></li>
<li><a href="#drakxtrunktoolsserial_probeserialc">drakx/trunk/tools/serial_probe/serial.c</a></li>
<li><a href="#drakxtrunktoolsserial_probeserialh">drakx/trunk/tools/serial_probe/serial.h</a></li>
<li><a href="#drakxtrunktoolsserial_probeserial_probec">drakx/trunk/tools/serial_probe/serial_probe.c</a></li>
<li><a href="#drakxtrunktoolsshift_allpl">drakx/trunk/tools/shift_all.pl</a></li>
<li><a href="#drakxtrunktoolsshift_imgc">drakx/trunk/tools/shift_img.c</a></li>
<li><a href="#drakxtrunktoolssimplifydrakxmodules">drakx/trunk/tools/simplify-drakx-modules</a></li>
<li><a href="#drakxtrunktoolsspecific_arch">drakx/trunk/tools/specific_arch</a></li>
<li>drakx/trunk/tools/x86_64/</li>
<li><a href="#drakxtrunktoolsxhostc">drakx/trunk/tools/xhost+.c</a></li>
</ul>
</div>
<div id="patch"><pre>
<a id="drakxtrunktoolsperl_checker">Added: drakx/trunk/tools/.perl_checker</a>
===================================================================
--- drakx/trunk/tools/.perl_checker (rev 0)
+++ drakx/trunk/tools/.perl_checker 2011-02-06 23:23:30 UTC (rev 450)
@@ -0,0 +1,10 @@
+AutoLoader
+Carp::Heavy
+constant
+Cwd
+Digest::base
+Encode
+File::Path
+Gtk2::Gdk::Keysyms
+IO::Handle
+Pod::Usage
\ No newline at end of file
<a id="drakxtrunktoolsMakefile">Added: drakx/trunk/tools/Makefile</a>
===================================================================
--- drakx/trunk/tools/Makefile (rev 0)
+++ drakx/trunk/tools/Makefile 2011-02-06 23:23:30 UTC (rev 450)
@@ -0,0 +1,27 @@
+DIRS = serial_probe
+CFLAGS = -Wall
+
+ARCH := $(shell arch | egrep "(x86_64|sparc64|s390x)")
+ifneq ("x$(ARCH)", "x")
+LIB_NAME = lib64
+else
+LIB_NAME = lib
+endif
+
+.PHONY: clean install $(DIRS)
+
+all: $(DIRS) xhost+ rpcinfo-flushed
+
+$(DIRS):
+ make -C $@
+
+install:
+ install -d $(ROOTDEST)/misc
+ install mdkinst_stage2_tool drakx-in-chroot $(ROOTDEST)/misc
+
+xhost+: %: %.c
+ $(CC) $(CFLAGS) $< -L/usr/X11R6/$(LIB_NAME) -lX11 -o $@
+
+clean:
+ for i in $(DIRS); do $(MAKE) -C $$i clean; done
+ rm -rf *~ xhost+ rpcinfo-flushed */*.o
Property changes on: drakx/trunk/tools/Makefile
___________________________________________________________________
<a id="svneolstyle">Added: svn:eol-style</a>
+ native
<a id="drakxtrunktoolscheckusedmodules">Added: drakx/trunk/tools/checkusedmodules</a>
===================================================================
--- drakx/trunk/tools/checkusedmodules (rev 0)
+++ drakx/trunk/tools/checkusedmodules 2011-02-06 23:23:30 UTC (rev 450)
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# This script compares the perl modules used by the .pm files in perl-install
+# against the ones listed in share/list, to detect potential missing modules
+# (and potential run-time problems during the stage 2)
+
+cd ../perl-install || exit 1;
+
+# list of used .pm files
+find . -name '*.pm' -not -name b_dump_strings.pm -not -path ./interactive/http.pm | \
+ xargs perl -lne '/^\s*(use|require)\s+([\w:]+)/ && print $2' | sort -u > /tmp/gi-used-pm
+
+# list of .pm files included in install
+perl -lne 'm{/(?:PERL_VERSION|ARCH-linux|vendor_perl/\*)/([\w/]+)\.pm$} and $_=$1, s,/,::,g, print' share/list > /tmp/gi-found-pm0
+find . -name blib -prune -o -name '*.pm' | perl -ne 's,^\./,,; s/\.pm$// or next; s,/,::,g; print' >> /tmp/gi-found-pm0
+
+# compute difference
+sort -u /tmp/gi-found-pm0 > /tmp/gi-found-pm
+diff -u /tmp/gi-{used,found}-pm | perl -lne 'BEGIN{print"Unpackaged modules:"} s/^-(?!-)/ / && print'
+
+# cleanup
+rm -f /tmp/gi-used-pm /tmp/gi-found-pm{,0}
Property changes on: drakx/trunk/tools/checkusedmodules
___________________________________________________________________
<a id="svnexecutable">Added: svn:executable</a>
+ *
<a id="drakxtrunktoolsdrakxinchroot">Added: drakx/trunk/tools/drakx-in-chroot</a>
===================================================================
--- drakx/trunk/tools/drakx-in-chroot (rev 0)
+++ drakx/trunk/tools/drakx-in-chroot 2011-02-06 23:23:30 UTC (rev 450)
@@ -0,0 +1,228 @@
+#!/usr/bin/perl
+
+use MDK::Common;
+
+my $SLASH_LOCATION = '/tmp/drakx-in-chroot';
+
+my $verbose = 0;
+my $prefix_ROOTED = '/mnt';
+my $IMAGE_LOCATION_ROOTED = '/tmp/image';
+my $MEDIA_LOCATION_ROOTED = '/tmp/media';
+my $STAGE2_LOCATION_ROOTED = '/tmp/stage2';
+my $LOOP_MOUNT_POINT = "$SLASH_LOCATION/tmp/loop";
+my $LIVE_LOCATION_REL = 'install/stage2/live/';
+my $COMPRESSED_LOCATION_REL = 'install/stage2/';
+my $COMPRESSED_FILE_REL = $COMPRESSED_LOCATION_REL . 'mdkinst.sqfs';
+my $AUTO_INSTALL_ROOTED = '/tmp/auto_inst.cfg.pl';
+my $DEFCFG_ROOTED = '/tmp/defcfg.pl';
+my $RPMSRATE_ROOTED = '/tmp/rpmsrate';
+my $resolution = '800x600';
+my ($disk_iso_repository, $repository_uri);
+
+@ARGV >= 2 or die "usage: drakx-in-chroot <root of distrib> <dir to install to> [options]\n
+\nOptions specific to drakx-in-chroot:
+ --flang XX use XX locale
+ --disk-iso path of a distro
+ --resolution=XXXxYYYY (eg: --resolution=1024x768)\n
+ --repository=<path> path of packages repository
+ --text text mode installer
+";
+
+(my $repository, my $dir, @ARGV) = @ARGV;
+foreach (@ARGV) {
+ if (/--resolution=(.*)/) {
+ $resolution = $1;
+ } elsif (/--disk-iso=(.*)/) {
+ $disk_iso_repository = $1;
+ } elsif (/--repository=(.*)/) {
+ $repository_uri = $1;
+ }
+}
+my ($repository_without_arch, $repository_arch) = basename($repository) eq arch() ? (dirname($repository), '/' . arch()) : ($repository, '');
+my $STAGE2_LOCATION = $SLASH_LOCATION . $STAGE2_LOCATION_ROOTED;
+
+my $sudo;
+if ($>) {
+ $sudo = "sudo";
+ $ENV{PATH} = "/sbin:/usr/sbin:$ENV{PATH}";
+}
+
+undef $ENV{TMPDIR}; # prevent packdrake faillure on creating temporary files
+
+if (-d $SLASH_LOCATION) {
+ umount_all() == 0 or exit(1);
+ sys("$sudo rm -rf $SLASH_LOCATION/var/lib/rpm $SLASH_LOCATION/dev/mapper");
+ rm_rf($SLASH_LOCATION);
+}
+
+mkdir_p("$SLASH_LOCATION$_") foreach '/dev', '/dev/usb', '/etc', '/var', '/proc', '/sys', $STAGE2_LOCATION_ROOTED, $MEDIA_LOCATION_ROOTED, $prefix_ROOTED;
+
+sys("$sudo rm -rf $dir") if $ENV{CLEAN};
+-e $dir or sys("$sudo mkdir -p $dir");
+
+copy_auto_install_files();
+
+my $remote_repository = $repository =~ m!^(ftp|http)://! && $1;
+if ($remote_repository) {
+ my $local_mdkinst = "$SLASH_LOCATION/tmp/mdkinst.sqfs";
+ sys("curl --silent -o $local_mdkinst $repository/$COMPRESSED_FILE_REL");
+ mount_mdkinst($local_mdkinst);
+} elsif (-d "$repository/$LIVE_LOCATION_REL") {
+ sys("$sudo mount -o bind $repository/$LIVE_LOCATION_REL $STAGE2_LOCATION");
+} elsif (-e "$repository/$COMPRESSED_FILE_REL") {
+ mount_mdkinst("$repository/$COMPRESSED_FILE_REL");
+}
+
+sys("$sudo mount -o bind $dir $SLASH_LOCATION$prefix_ROOTED");
+$repository_uri ||= $repository_without_arch if !$remote_repository;
+sys("$sudo mount -o bind $repository_uri $SLASH_LOCATION$MEDIA_LOCATION_ROOTED") if $repository_uri;
+
+sys("$sudo mount -t proc none $SLASH_LOCATION/proc");
+sys("$sudo mount -t sysfs none $SLASH_LOCATION/sys");
+
+if ($disk_iso_repository) {
+ my $repository_arch = $repository_arch || 'i586';
+ mkdir_p($LOOP_MOUNT_POINT);
+ sys("$sudo mount -o loop,ro $disk_iso_repository $LOOP_MOUNT_POINT");
+ symlinkf('loop/' . $repository_arch, "$SLASH_LOCATION$IMAGE_LOCATION_ROOTED"); # FIXME: arch()
+}
+
+symlinkf('media' . $repository_arch, "$SLASH_LOCATION$IMAGE_LOCATION_ROOTED");
+create_initial_symlinks();
+create_initial_devices();
+
+apply_stage2_updates();
+
+output("$SLASH_LOCATION/etc/hosts", "127.0.0.1 localhost\n") if ! -e "$SLASH_LOCATION/etc/hosts";
+
+#- in the chroot, we have no way to know which device corresponds to the "/" partition.
+#- so helping it by giving the device which provide major/minor information
+mkdir_p("$dir/dev");
+eval { cp_af($_, "$dir$_") } foreach qw(/dev/root);
+
+#- if the DISPLAY is remote, we may need to resolve the name:
+eval { cp_af($_, "$SLASH_LOCATION$_") } foreach qw(/etc/resolv.conf);
+
+{
+ chomp(my $kernel_version = `uname -r`);
+ my $dir = "/modules/$kernel_version";
+ mkdir_p("$SLASH_LOCATION$dir");
+ output_p("$SLASH_LOCATION$dir" . $_, "\n") foreach "/lib/$dir/modules.dep", "/lib/$dir/modules.alias";
+}
+
+my $Xnest_pid;
+my $Xnest_bin = find { whereis_binary($_) } 'Xephyr', 'Xnest';
+if (!-f ($SLASH_LOCATION . $AUTO_INSTALL_ROOTED) && $Xnest_bin && (join('', @ARGV) !~ /--text/)) {
+ my $DISPLAY = ':8';
+ $Xnest_pid = fork();
+ if (!$Xnest_pid) {
+ exec $Xnest_bin, $DISPLAY, '-ac', ($Xnest_bin eq 'Xephyr' ? '-screen' : '-geometry'), $resolution or die "Xnest failed\n";
+ }
+ $ENV{DISPLAY} = '127.0.0.1' . $DISPLAY;
+}
+
+if (my $pid = fork()) {
+ waitpid $pid, 0;
+ umount_all() == 0 or warn "umounting failed\n";
+ $Xnest_pid and kill 15, $Xnest_pid;
+} else {
+ $ENV{TERM} = 'linux'; # we only have terminfo for terminal "linux"
+ $ENV{HOME} = '/';
+ # to kept sync with gi/mdk-stage1/init.c::env:
+ $ENV{LD_LIBRARY_PATH}='/lib:/usr/lib:/mnt/lib:/mnt/usr/lib:/usr/X11R6/lib:/mnt/usr/X11R6/lib:/lib64:/usr/lib64:/usr/X11R6/lib64:/mnt/lib64:/mnt/usr/lib64:/mnt/usr/X11R6/lib64';
+ if ($remote_repository) {
+ $ENV{URLPREFIX} = $repository;
+ }
+ my $cmd = join(' ', "/usr/bin/runinstall2 --local_install",
+ if_($disk_iso_repository, "--method disk-iso"),
+ if_($remote_repository, "--method $remote_repository"),
+ @ARGV);
+ exec "$sudo chroot $SLASH_LOCATION $cmd" or die "exec $cmd in $SLASH_LOCATION failed\n";
+}
+
+sub system_verbose { warn join(' ', @_), "\n" if $verbose; system(@_) }
+sub sys { &system_verbose; $? and die qq(running "@_" failed: $?\n) }
+
+sub mount_mdkinst {
+ my ($mdkinst) = @_;
+ sys("$sudo mount -t squashfs -o loop,ro $mdkinst $STAGE2_LOCATION");
+}
+sub create_initial_symlinks() {
+ foreach (cat_or_die("$STAGE2_LOCATION/usr/share/symlinks")) {
+ my ($from, $to_) = split;
+ my $to = $SLASH_LOCATION . ($to_ || $from);
+ $from = "$STAGE2_LOCATION_ROOTED$from" if !$to_;
+ if (! -l $to) {
+ symlink $from, $to or die "symlinking $to failed\n";
+ }
+ }
+}
+
+sub create_initial_devices() {
+ sys("$sudo cp -a /dev/{mem,null,random,urandom} $SLASH_LOCATION/dev");
+}
+
+sub umount_all() {
+ my $err;
+ clean_stage2_updates();
+ my @procs = ('/proc/bus/usb', '/proc', '/sys');
+ foreach ((map { "$prefix_ROOTED$_" } @procs, ''), @procs, $STAGE2_LOCATION_ROOTED, $LOOP_MOUNT_POINT, $MEDIA_LOCATION_ROOTED, $IMAGE_LOCATION_ROOTED) {
+ my $dir = "$SLASH_LOCATION$_";
+ rmdir $dir;
+ if (-d $dir) {
+ if (m!/proc/bus/usb! || begins_with($_, $prefix_ROOTED)) {
+ system_verbose "$sudo umount $dir 2>/dev/null";
+ next;
+ }
+ system_verbose "$sudo umount $dir";
+ }
+ rmdir $dir;
+ if (-d $dir) {
+ warn "$dir is busy\n";
+ $err++;
+ }
+ }
+ if (my @remaining = cat_('/proc/mounts') =~ m!($SLASH_LOCATION/mnt/\S+)!g) {
+ warn "umount those mount points first: ", join(' ', @remaining), "\n";
+ $err++;
+ }
+ $err;
+}
+
+sub copy_auto_install_files() {
+ my ($opt);
+ each_index {
+ if ($opt eq 'auto_install' && -f $_) {
+ cp_f($_, $SLASH_LOCATION . $AUTO_INSTALL_ROOTED);
+ $_ = $AUTO_INSTALL_ROOTED;
+ } elsif ($opt eq 'defcfg' && -f $_) {
+ cp_f($_, $SLASH_LOCATION . $DEFCFG_ROOTED);
+ $_ = $DEFCFG_ROOTED;
+ } elsif ($opt eq 'rpmsrate' && -f $_) {
+ cp_f($_, $SLASH_LOCATION . $RPMSRATE_ROOTED);
+ }
+ undef $opt;
+ /^--?(.*)/ and $opt = $1;
+ } @ARGV;
+}
+
+my @stage2_updates;
+sub apply_stage2_updates() {
+ each_index {
+ if ($_ eq '--stage2-update') {
+ my $file = $ARGV[$::i+1];
+ my $dest = $ARGV[$::i+2];
+ if (-f $file && $dest) {
+ undef $_;
+ undef $ARGV[$::i+1];
+ undef $ARGV[$::i+2];
+ push @stage2_updates, $dest;
+ sys("$sudo mount --bind $file $STAGE2_LOCATION/$dest");
+ }
+ }
+ } @ARGV;
+}
+
+sub clean_stage2_updates() {
+ sys("$sudo umount $STAGE2_LOCATION/$_") foreach @stage2_updates;
+}
Property changes on: drakx/trunk/tools/drakx-in-chroot
___________________________________________________________________
Added: svn:executable
+ *
<a id="drakxtrunktoolsextractchangelog">Added: drakx/trunk/tools/extractchangelog</a>
===================================================================
--- drakx/trunk/tools/extractchangelog (rev 0)
+++ drakx/trunk/tools/extractchangelog 2011-02-06 23:23:30 UTC (rev 450)
@@ -0,0 +1,2 @@
+#!/usr/bin/perl
+
<a id="drakxtrunktoolsgetneededdrakxmodules">Added: drakx/trunk/tools/get-needed-drakx-modules</a>
===================================================================
--- drakx/trunk/tools/get-needed-drakx-modules (rev 0)
+++ drakx/trunk/tools/get-needed-drakx-modules 2011-02-06 23:23:30 UTC (rev 450)
@@ -0,0 +1,19 @@
+#!/usr/bin/perl
+
+use MDK::Common;
+
+my ($rel, $dest, $script) = @ARGV;
+
+$rel =~ s!/?$!!;
+
+foreach (`strace -efile perl -cw -I $rel $script 2>&1`) {
+ my ($f) = /^open\("(.*?)",.*\)\s*=\s*\d+$/ or next;
+ $f !~ m!/usr/lib/perl5/[^/]*/warnings.pm! or next;
+ if (begins_with($f, $rel)) {
+ print $f, "\t", $dest . substr($f, length($rel)), "\n";
+ } elsif (begins_with($f, '/dev/')) {
+ # skip
+ } elsif (begins_with($f, '/')) {
+ print "$f\n";
+ }
+}
Property changes on: drakx/trunk/tools/get-needed-drakx-modules
___________________________________________________________________
Added: svn:executable
+ *
<a id="drakxtrunktoolshd_grubcgi">Added: drakx/trunk/tools/hd_grub.cgi</a>
===================================================================
--- drakx/trunk/tools/hd_grub.cgi (rev 0)
+++ drakx/trunk/tools/hd_grub.cgi 2011-02-06 23:23:30 UTC (rev 450)
@@ -0,0 +1,102 @@
+#!/usr/bin/perl
+
+use CGI ':all';
+use CGI::Carp;
+
+my $default_append = "ramdisk_size=128000 root=/dev/ram3";
+my $default_acpi = "acpi=ht";
+my $default_vga = "vga=788";
+
+my $cgi_name = "/" . ($0 =~ m|([^/]+)$|)[0];
+
+print
+ header(),
+ start_html(-TITLE => 'hd_grub configuration');
+
+if (param()) {
+ print_menu_lst();
+} else {
+ print_form();
+}
+
+print end_html;
+
+
+sub menu_lst {
+ my ($hd, $hd_linux, $partition_number, $directory) = @_;
+
+ my $grub_partition_number = $partition_number - 1;
+
+ <<EOF;
+timeout 0
+default 0
+
+title Mageia Install
+
+root ($hd,$grub_partition_number)
+kernel $directory/isolinux/alt0/vmlinuz $default_append $default_acpi $default_vga automatic=method:disk,partition:$hd_linux$partition_number,directory:$directory
+initrd $directory/isolinux/alt0/all.rdz
+EOF
+
+}
+
+sub print_menu_lst {
+ my $directory = param('directory');
+ $directory =~ s!^/!!;
+ print
+ ol(li(qq(Select the text below and save it in a file "menu.lst")),
+ li(qq(Create a floppy from $directory/images/hd_grub.img (eg: <tt>dd if=hd_grub.img of=/dev/fd0</tt>))),
+ li(qq(Copy the file "menu.lst" to the floppy, overwriting the existing one)),
+ ),
+ p(),
+ start_form(-name => 'form', -action => $cgi_name, -method => 'get'),
+ textarea(-default => menu_lst(param('hd'), param('hd_linux'), param('partition_number'), "/$directory"),
+ -rows => 15, -columns => 120,
+ ),
+ end_form(),
+}
+
+sub print_form {
+ print
+ p(),
+ start_form(-name => 'form', -action => $cgi_name, -method => 'get'),
+ ul("Please choose the partition where %s is copied.",
+ li(popup_menu(-name => "hd", -default => 'hd0',
+ -values => [ 'hd0' .. 'hd3' ],
+ -labels => { hd0 => '1st BIOS hard drive (usually hda or sda)',
+ hd1 => '2nd BIOS hard drive',
+ hd2 => '3rd BIOS hard drive',
+ hd3 => '4th BIOS hard drive',
+ })),
+ li(popup_menu(-name => "hd_linux", -default => 'hda',
+ -values => [ 'hda' .. 'hdd', 'sda' .. 'sdc', 'hde' .. 'hdh' ],
+ -labels => {
+ hda => '1st IDE hard drive (hda)',
+ hdb => '2nd IDE hard drive (hdb)',
+ hdc => '3rd IDE hard drive (hdc)',
+ hdd => '4th IDE hard drive (hdd)',
+ hde => '5th IDE hard drive (hde)',
+ hdf => '6th IDE hard drive (hdf)',
+ hdg => '7th IDE hard drive (hdg)',
+ hdh => '8th IDE hard drive (hdh)',
+ sda => '1st SCSI hard drive (sda)',
+ sdb => '2nd SCSI hard drive (sdb)',
+ sdc => '3rd SCSI hard drive (sdc)',
+ })),
+ li(popup_menu(-name => "partition_number", -default => '0',
+ -values => [ 1 .. 15 ],
+ -labels => { 1 => '1st primary partition (hda1, sda1 or ...)',
+ 2 => '2nd primary partition',
+ 3 => '3rd primary partition',
+ 4 => '4th primary partition',
+ 5 => '5th partition (hda5, sda5 or ...) (first logical partition)',
+ map { $_ => $_ . 'th partition' } 6 .. 15
+ })),
+ ),
+ p(),
+ ul("Please enter the directory containing the %s Distribution (relative to the partition chosen above)",
+ li(textfield(-name => 'directory', -default => '/cooker/i586', size => 40)),
+ ),
+ p(submit(-name => 'Go')),
+ end_form();
+}
Property changes on: drakx/trunk/tools/hd_grub.cgi
___________________________________________________________________
Added: svn:executable
+ *
<a id="drakxtrunktoolsinstallxmlfilelist">Added: drakx/trunk/tools/install-xml-file-list</a>
===================================================================
--- drakx/trunk/tools/install-xml-file-list (rev 0)
+++ drakx/trunk/tools/install-xml-file-list 2011-02-06 23:23:30 UTC (rev 450)
@@ -0,0 +1,383 @@
+#!/usr/bin/perl
+
+use FileHandle;
+use MDK::Common;
+use XML::Parser;
+use Data::Dumper;
+use File::Glob;
+use Config;
+use Cwd 'cwd';
+
+my $want_sudo = $ARGV[0] eq '--sudo' && shift @ARGV;
+
+@ARGV == 2 or die "usage: install-xml-file-list [--sudo] <xml file> <destination>\n";
+my ($xml_file_list, $DEST) = @ARGV;
+
+my $sudo = '';
+if ($>) {
+ $sudo = "sudo" if $want_sudo;
+ $ENV{PATH} = "/sbin:/usr/sbin:$ENV{PATH}";
+}
+
+#$verbose = 1;
+
+my $initial_dir = cwd();
+my $ARCH = arch() =~ /i.86/ ? 'i386' : arch();
+my $LIB = arch() =~ /x86_64/ ? "lib64" : "lib";
+
+my $base_cpio_options = '-pumd --quiet';
+
+my $problem;
+my $tree = XML::Parser->new(Style => 'Tree')->parsefile($xml_file_list);
+
+my $main_node = decompose($tree);
+
+$main_node->{tag} eq 'list' or die "bad file $xml_file_list (main tag should be <list>)\n";
+
+handle_nodes({}, $main_node);
+
+$problem and exit 1;
+
+install_needed_libraries();
+
+final_cleanup();
+
+sub error {
+ my ($err) = @_;
+ warn "FATAL: $err\n";
+ $problem = 1;
+}
+
+sub final_cleanup() {
+ #- cpio creates directory 700, that's not nice
+ system("find $DEST -type d -print0 | xargs -0 $sudo chmod 755");
+}
+
+sub handle_nodes {
+ my ($env, $e) = @_;
+ handle_node($env, decompose($_)) foreach @{$e->{l}};
+}
+sub handle_node {
+ my ($env, $node) = @_;
+
+ if (!$node->{tag} && $node->{text} !~ /\S/) {
+ } elsif (!$node->{tag}) {
+ install($env, $node->{text});
+ } elsif ($node->{tag} eq 'if') {
+ my $cond = valid_cond($node->{attr});
+ handle_nodes($env, $node) if $cond;
+ } elsif ($node->{tag} eq 'if-not') {
+ my $cond = valid_cond($node->{attr});
+ handle_nodes($env, $node) if !$cond;
+ } elsif (member($node->{tag}, 'from', 'to', 'mode', 'filter')) {
+ handle_nodes(add_to_env($env, $node->{tag} => $node->{attr}), $node);
+ } else {
+ warn "expecting tag <from>, not <$node->{tag}>\n";
+ }
+}
+
+sub valid_cond {
+ my ($attr) = @_;
+ every {
+ if ($_ eq 'ARCH') {
+ $ARCH =~ /$attr->{$_}/;
+ } elsif ($_ eq 'set') {
+ $ENV{$attr->{$_}};
+ } else {
+ die "<if>: unknown condition $_\n";
+ }
+ } keys %$attr;
+}
+
+sub add_to_env {
+ my ($env, $tag, $attr) = @_;
+ my %env = map_each { $::a => +{%$::b} } %$env;
+ foreach (keys %$attr) {
+ !$env{$tag}{$_} or die qq(overriding attribute <$tag $_="$env{$tag}{$_}"> with $_="$attr->{$_}"\n);
+ $env{$tag}{$_} = $attr->{$_};
+ }
+ \%env;
+}
+
+sub group_by_n {
+ my ($n, $l) = @_;
+ my (@r, $subl);
+ my $i = 0;
+ foreach (@$l) {
+ if ($i % $n == 0) {
+ push @r, $subl = [];
+ }
+ push @$subl, $_;
+ $i++;
+ }
+ @r;
+}
+
+sub identify_file {
+ my ($dev, $ino) = @_;
+ "$dev:$ino";
+}
+
+sub all_files_rec_ {
+ my ($d) = @_;
+
+ $d, -d $d && ! -l $d ? map { all_files_rec_("$d/$_") } all($d) : ();
+}
+
+sub expand_macros {
+ my ($f) = @_;
+ $f =~ s!\bLIB\b!$LIB!g;
+ $f =~ s!\bARCH\b!$ARCH!ge;
+ $f =~ s!\$\((\w+)\)!$ENV{$1} || die "$1 undefined\n"!ge;
+ $f;
+}
+
+my %needed_libraries;
+sub collect_needed_libraries {
+ my (@to_check) = @_;
+ while (@to_check) {
+ my $to_check = join(' ', @to_check);
+ my @l = `ldd $to_check 2>/dev/null` =~ m! => (/\S+)!g;
+ foreach (@l) {
+ if ($main_node->{attr}{'no-arch-libraries'}) {
+ #- replace /lib/tls or /lib/i686 with /lib
+ s!^(/lib(64)?/).*?/!$1! if arch() !~ /x86_64/;
+ }
+ }
+ @to_check = grep { !$needed_libraries{$_}++ } @l;
+ @to_check = ();
+ }
+}
+sub install_needed_libraries {
+ copy_files('', $DEST, [ keys %needed_libraries ], '', '--dereference');
+}
+
+sub collect_needed_perl_files {
+ my ($local_rep, $dest, @scripts) = @_;
+
+ my (%local, %global);
+ foreach my $script (@scripts) {
+ foreach (`strace -efile perl -cw -I$local_rep $script 2>&1`) {
+ my ($f) = /^open\("(.*?)",.*\)\s*=\s*\d+$/ or next;
+ if ($f =~ m!^\Q$local_rep\E/(.*)!) {
+ $local{$1} = 1;
+ } elsif (begins_with($f, '/dev/')) {
+ # skip
+ } elsif (begins_with($f, '/')) {
+ if ($main_node->{attr}{'no-arch-libraries'}) {
+ #- replace /lib/tls or /lib/i686 with /lib
+ $f =~ s!^(/lib(64)?/).*?/!$1! if arch() !~ /x86_64/;
+ }
+ $global{$f} = 1;
+ }
+ }
+ }
+ [ keys %local ], [ keys %global ];
+}
+
+sub copy_files {
+ my ($working_dir, $to_dir, $files, $b_flatten, @options) = @_;
+
+ if ($b_flatten) {
+ mkdir_p($to_dir);
+ my $options = join(' ', '-r', @options);
+ foreach (group_by_n(20, $files)) {
+ warn "cp $options to_dir $to_dir from $working_dir: @$_\n" if $verbose;
+ system("cd $working_dir ; $sudo cp $options @$_ $to_dir");
+ }
+ } else {
+ my $options = join(' ', $base_cpio_options, @options);
+ warn "cpio $options to_dir=$to_dir from=$working_dir: @$files\n" if $verbose;
+ open(my $F, "| cd $working_dir ; $sudo cpio $options $to_dir");
+ print $F "$_\n" foreach @$files;
+ close($F) or die "cpio $to_dir failed\n";
+ }
+}
+
+sub install {
+ my ($env, $text) = @_;
+
+ my $from_dir = expand_macros($env->{from}{dir});
+ my $to_dir = $DEST . expand_macros($env->{to}{dir} || $env->{to}{flatten} && $from_dir || '');
+ my $copy_mode = $env->{mode}{copy} || '';
+ my $working_dir = '.';
+
+ my $expand = $env->{from}{expand} || '';
+
+ my $disallow_from_dir = sub {
+ !$from_dir or die "from dir not allowed with $expand binary\n";
+ };
+
+ my $from_file = sub {
+ my ($rel, $b_full_glob, $b_recursive_dirs) = @_;
+ my $f = expand_macros($from_dir ? "$from_dir/$rel" : $rel);
+ my @l = $f;
+ chdir $working_dir;
+ if ($f =~ /\*/ || $b_full_glob) {
+ @l = File::Glob::bsd_glob($f); #- using bsd_glob because CORE::glob() splits on whitespace and we don't want this
+ if (@l == 0) {
+ error("no match for $f");
+ } elsif (@l == 1 || $b_full_glob) {
+ } else {
+ error("multiple match for $f");
+ @l = ();
+ }
+ } elsif (! -e $f) {
+ error("missing file $f ($rel) in $working_dir");
+ @l = ();
+ }
+ if (@l == 1 && -d $l[0] && $b_recursive_dirs) {
+ @l = all_files_rec_($l[0]);
+ }
+ @l = grep { !m!/(\.svn|CVS)($|/)! } @l;
+ if (my $re = $env->{from}{matching}) {
+ @l = grep { eval $re } @l;
+ }
+
+ collect_needed_libraries(grep { -f $_ && -x $_ } @l);
+
+ chdir $initial_dir;
+ @l;
+ };
+
+ my @text_l = $env->{from}{spaces_in_filename} ? $text =~ /^\s*(.*?)\s*$/ : split(' ', $text);
+ my @files;
+ if ($expand eq 'tar') {
+ foreach (@text_l) {
+ my ($tarball) = $from_file->($_) or next;
+ system('tar', 'xfj', $tarball, '-C', $to_dir);
+ }
+ # not filling @files, things are already done
+
+ } elsif ($expand eq 'command') {
+ @files = chomp_(`$text`);
+
+ } elsif ($expand eq 'glob') {
+ #- glob done in $from_file
+ @files = @text_l;
+
+ } elsif ($expand eq 'binary') {
+ $disallow_from_dir->();
+ my @PATH = qw(/sbin /bin /usr/bin /usr/sbin /usr/X11R6/bin);
+ foreach my $name (map { expand_macros($_) } @text_l) {
+ my @l = grep { -x $_ } map { "$_/$name" } @PATH;
+ @l or error("can't find binary $name"), next;
+ if (@l > 1) {
+ my @m = grep { ! -l $_ } @l;
+ if (@m == 1) {
+ my $id = identify_file($m[0]);
+ push @files, grep { -l $_ && identify_file($_) eq $id } @l;
+ }
+ @l = @m if @m;
+ }
+ if (@l > 1) {
+ warn "many matches for binary $name: " . join(' ', @l) . ", choosing $l[0]\n";
+ }
+ my $f = $l[0];
+ while (1) {
+ push @files, $f;
+ $copy_mode ne 'dereference' or last;
+ my $l = readlink($f) or last;
+ if ($l =~ m!/! && $l !~ m!^\.\..*/s?bin/[^/]+$!) {
+ warn "keeping symlink $f -> $l as is\n";
+ last;
+ }
+ $f = dirname($f) . '/' . $l;
+ }
+ }
+ $copy_mode ||= 'keep-links';
+ $env->{filter}{command} ||= 'strip';
+
+ } elsif ($expand eq 'rpm') {
+ $disallow_from_dir->();
+ foreach my $rpm (@text_l) {
+ my @l = chomp_(`rpm -ql $rpm`) or error("rpm $rpm must be installed");
+ push @files, @l;
+ }
+
+ } elsif ($expand eq 'perl') {
+ $disallow_from_dir->();
+ $from_dir = '/usr/lib/perl5/vendor_perl/*';
+ @files = @text_l;
+ } elsif ($expand eq 'main-perl') {
+ $disallow_from_dir->();
+ $from_dir = $Config{privlib};
+ @files = @text_l;
+ } elsif ($expand =~ /collect-perl-files/) {
+ my (undef, $local, $to) = split(' ', $expand);
+
+ @files = @text_l;
+ warn "collect-perl-files $local $to @files ($env->{filter}{command})\n";
+ my ($local_perl_files, $global_perl_files) = collect_needed_perl_files($local, $to, @files);
+ warn "collect-perl-files gave: ", join(' ', @$local_perl_files), "\n";
+# warn " and: ", join(' ', @$global_perl_files), "\n";
+ copy_and_filter($local =~ m!/! ? $local : "$working_dir/$local", "$DEST$to", $local_perl_files, $env->{filter}, '', '--dereference');
+ copy_and_filter('', $DEST, $global_perl_files, $env->{filter}, '', '--dereference');
+
+ } elsif ($expand) {
+ die "unknown expand method $expand\n";
+ } else {
+ @files = @text_l;
+
+ $env->{filter}{command} ||= 'strip' if $to_dir =~ m!/bin$!;
+ }
+
+ if ($env->{to}{dir} && $from_dir) {
+ $working_dir = $from_dir;
+ undef $from_dir;
+ }
+
+ my @all_files = map { $from_file->($_, $expand eq 'glob', $expand ne 'rpm') } @files;
+
+ my @options = (
+ if_($copy_mode ne 'keep-links', '--dereference'),
+ );
+ if (@all_files) {
+ copy_and_filter($working_dir, $to_dir, \@all_files, $env->{filter}, $env->{to}{flatten}, @options);
+ }
+}
+
+sub copy_and_filter {
+ my ($working_dir, $to_dir, $all_files, $filter, $flatten, @copy_options) = @_;
+
+ copy_files($working_dir, $to_dir, $all_files, $flatten, @copy_options);
+ apply_filter($to_dir, $filter, $all_files, $flatten);
+}
+
+sub apply_filter {
+ my ($to_dir, $filter, $all_files, $b_flatten) = @_;
+
+ chdir $to_dir;
+ foreach (group_by_n(20, $all_files)) {
+ my @l = $b_flatten ? (map { basename($_) } @$_) : (map { "./$_" } @$_);
+ @l = grep { ! -d $_ } @l or next;
+
+ if (my $subst = $filter->{subst}) {
+ system('perl', '-pi', '-e', $subst, @l);
+ }
+ if (my $command = $filter->{command}) {
+ $command = $initial_dir . "/$command" if $command =~ m!^..?/!;
+ if ($command =~ /simplify-drakx-modules/) {
+ @l = grep { !/\.so($|\.)/ } @l or next;
+ }
+ my @options = (
+ if_($command eq 'gzip', '-9f'),
+ if_($command eq 'strip', '2>/dev/null'),
+ );
+ warn "running $command @options @l\n" if $verbose;
+ system(join(' ', $command, @options, @l));
+ }
+ }
+ chdir $initial_dir;
+}
+
+sub decompose {
+ my ($tree) = @_;
+ my ($tag, $val) = @$tree;
+ if ($tag eq '0') {
+ { text => $val };
+ } else {
+ my ($attr, @l) = @$val;
+ { tag => $tag, attr => $attr, l => [ group_by2(@l) ] };
+ }
+}
Property changes on: drakx/trunk/tools/install-xml-file-list
___________________________________________________________________
Added: svn:executable
+ *
<a id="drakxtrunktoolsmake_lang_png_transparentc">Added: drakx/trunk/tools/make_lang_png_transparent.c</a>
===================================================================
--- drakx/trunk/tools/make_lang_png_transparent.c (rev 0)
+++ drakx/trunk/tools/make_lang_png_transparent.c 2011-02-06 23:23:30 UTC (rev 450)
@@ -0,0 +1,167 @@
+/*
+ * Guillaume Cottenceau (gc at mandriva.com)
+ *
+ * Copyright 2002-2005 Mandriva
+ *
+ * This software may be freely redistributed under the terms of the GNU
+ * public license.
+ *
+ */
+
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+
+#define PNG_DEBUG 3
+#include <png.h>
+
+void abort_(const char * s, ...)
+{
+ va_list args;
+ va_start(args, s);
+ vfprintf(stderr, s, args);
+ fprintf(stderr, "\n");
+ va_end(args);
+ abort();
+}
+
+int x, y;
+
+int width, height;
+png_byte color_type;
+png_byte bit_depth;
+
+png_structp png_ptr;
+png_infop info_ptr;
+int number_of_passes;
+png_bytep * row_pointers;
+
+void read_png_file(char* file_name)
+{
+ char header[8]; // 8 is the maximum size that can be checked
+
+ /* open file and test for it being a png */
+ FILE *fp = fopen(file_name, "rb");
+ if (!fp)
+ abort_("[read_png_file] File %s could not be opened for reading", file_name);
+ fread(header, 1, 8, fp);
+ if (png_sig_cmp(header, 0, 8))
+ abort_("[read_png_file] File %s is not recognized as a PNG file", file_name);
+
+
+ /* initialize stuff */
+ png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+
+ if (!png_ptr)
+ abort_("[read_png_file] png_create_read_struct failed");
+
+ info_ptr = png_create_info_struct(png_ptr);
+ if (!info_ptr)
+ abort_("[read_png_file] png_create_info_struct failed");
+
+ if (setjmp(png_jmpbuf(png_ptr)))
+ abort_("[read_png_file] Error during init_io");
+
+ png_init_io(png_ptr, fp);
+ png_set_sig_bytes(png_ptr, 8);
+
+ png_read_info(png_ptr, info_ptr);
+
+ width = info_ptr->width;
+ height = info_ptr->height;
+ color_type = info_ptr->color_type;
+ bit_depth = info_ptr->bit_depth;
+
+ number_of_passes = png_set_interlace_handling(png_ptr);
+ png_read_update_info(png_ptr, info_ptr);
+
+
+ /* read file */
+ if (setjmp(png_jmpbuf(png_ptr)))
+ abort_("[read_png_file] Error during read_image");
+
+ row_pointers = (png_bytep*) malloc(sizeof(png_bytep) * height);
+ for (y=0; y<height; y++)
+ row_pointers[y] = (png_byte*) malloc(info_ptr->rowbytes);
+
+ png_read_image(png_ptr, row_pointers);
+}
+
+
+void write_png_file(char* file_name)
+{
+ /* create file */
+ FILE *fp = fopen(file_name, "wb");
+ if (!fp)
+ abort_("[write_png_file] File %s could not be opened for writing", file_name);
+
+
+ /* initialize stuff */
+ png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+
+ if (!png_ptr)
+ abort_("[write_png_file] png_create_write_struct failed");
+
+ info_ptr = png_create_info_struct(png_ptr);
+ if (!info_ptr)
+ abort_("[write_png_file] png_create_info_struct failed");
+
+ if (setjmp(png_jmpbuf(png_ptr)))
+ abort_("[write_png_file] Error during init_io");
+
+ png_init_io(png_ptr, fp);
+
+
+ /* write header */
+ if (setjmp(png_jmpbuf(png_ptr)))
+ abort_("[write_png_file] Error during writing header");
+
+ png_set_IHDR(png_ptr, info_ptr, width, height,
+ bit_depth, color_type, PNG_INTERLACE_NONE,
+ PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
+
+ png_write_info(png_ptr, info_ptr);
+
+
+ /* write bytes */
+ if (setjmp(png_jmpbuf(png_ptr)))
+ abort_("[write_png_file] Error during writing bytes");
+
+ png_write_image(png_ptr, row_pointers);
+
+
+ /* end write */
+ if (setjmp(png_jmpbuf(png_ptr)))
+ abort_("[write_png_file] Error during end of write");
+
+ png_write_end(png_ptr, NULL);
+
+}
+
+void process_file(void)
+{
+ if (info_ptr->color_type != PNG_COLOR_TYPE_RGBA)
+ abort_("[process_file] color_type of input file must be PNG_COLOR_TYPE_RGBA (is %d)", info_ptr->color_type);
+
+ for (y=0; y<height; y++) {
+ png_byte* row = row_pointers[y];
+ for (x=0; x<width; x++) {
+ png_byte* ptr = &(row[x*4]);
+ ptr[3] = 255-ptr[0];
+ ptr[0] = ptr[1] = ptr[2] = 0;
+ }
+ }
+
+}
+
+
+int main(int argc, char **argv)
+{
+ if (argc != 3)
+ abort_("Usage: program_name <file_in> <file_out>");
+
+ read_png_file(argv[1]);
+ process_file();
+ write_png_file(argv[2]);
+}
Property changes on: drakx/trunk/tools/make_lang_png_transparent.c
___________________________________________________________________
Added: svn:eol-style
+ native
<a id="drakxtrunktoolsmdkinst_stage2_tool">Added: drakx/trunk/tools/mdkinst_stage2_tool</a>
===================================================================
--- drakx/trunk/tools/mdkinst_stage2_tool (rev 0)
+++ drakx/trunk/tools/mdkinst_stage2_tool 2011-02-06 23:23:30 UTC (rev 450)
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+error() {
+ cat <<EOF;
+usage: mdkinst_stage2_tool [--clean] [--compress | --uncompress] <stage2 dir> [<compressed file>]
+EOF
+ exit 1
+}
+
+if [ "$1" = "--clean" ]; then
+ CLEAN=1
+ shift
+fi
+
+[ $# = 2 -o $# = 3 ] || error
+
+if [ "$1" = "--compress" -o "$1" == "--uncompress" ]; then
+ ACTION=$1
+ shift
+ STAGE2_DIR="$1"
+ shift
+ LIVE_DIR="$STAGE2_DIR/live"
+ if [ -n "$1" ]; then
+ COMPRESSED_IMAGE=$1
+ shift
+ else
+ COMPRESSED_IMAGE="$STAGE2_DIR/mdkinst.sqfs"
+ fi
+else
+ error
+fi
+
+if [ $ACTION = "--compress" ]; then
+ which mksquashfs >/dev/null 2>/dev/null || { echo "missing command mksquashfs (from squashfs-tools)"; exit 1; }
+
+ [ -d "$LIVE_DIR" ] || error
+ echo "Creating $COMPRESSED_IMAGE from $LIVE_DIR"
+ rm -f $STAGE2_DIR/.room
+ mksquashfs $LIVE_DIR $COMPRESSED_IMAGE -all-root -noappend >/dev/null || { echo "mksquashfs failed"; exit 1; }
+ chmod 755 $COMPRESSED_IMAGE
+ echo foo > $STAGE2_DIR/.room
+ if [ -s $STAGE2_DIR/.room ]; then
+ rm -f $STAGE2_DIR/.room
+ [ -n "$CLEAN" ] && rm -rf $LIVE_DIR
+ else
+ echo "not enough space"
+ rm -f $COMPRESSED_IMAGE
+ exit 1
+ fi
+else
+ which unsquashfs >/dev/null 2>/dev/null || { echo "missing command unsquashfs (from squashfs-tools)"; exit 1; }
+
+ [ -f "$COMPRESSED_IMAGE" ] || error
+ echo "Creating $LIVE_DIR from $COMPRESSED_IMAGE"
+
+ if [ $EUID != "0" ]; then
+ SUDO="sudo"
+ PATH="/sbin:/usr/sbin:$PATH"
+ fi
+
+ unsquashfs -dest $LIVE_DIR $COMPRESSED_IMAGE || { rm -rf $LIVE_DIR; exit 1; }
+
+ [ -n "$CLEAN" ] && rm -f $COMPRESSED_IMAGE
+fi
+
+exit 0
Property changes on: drakx/trunk/tools/mdkinst_stage2_tool
___________________________________________________________________
Added: svn:executable
+ *
<a id="drakxtrunktoolsntp_serverspl">Added: drakx/trunk/tools/ntp_servers.pl</a>
===================================================================
--- drakx/trunk/tools/ntp_servers.pl (rev 0)
+++ drakx/trunk/tools/ntp_servers.pl 2011-02-06 23:23:30 UTC (rev 450)
@@ -0,0 +1,303 @@
+#!/usr/bin/perl
+
+#open F, "/usr/bin/lynx -dump http://www.eecis.udel.edu/~mills/ntp/clock1a.html|";
+open(my $G, "/usr/bin/lynx -dump http://www.eecis.udel.edu/~mills/ntp/clock2a.html|");
+
+# Chris Kloiber <ckloiber@redhat.com> writes:
+# > It's not considered polite to use the Stratum 1 servers for purposes that
+# > are not absolutely critical. I would use Stratum 2 servers and live with
+# > the few nanoseconds difference.
+#parse() while <F>;
+
+parse($_) while <$G>;
+
+my @all;
+my ($l, $nb);
+sub parse {
+ local ($_) = @_;
+ /Active Servers/ .. /Discontinued Service/ or return;
+ if (/^\s+\d+\. ([A-Z ]*[A-Z]);?\s+([.\w-]+)/) {
+ push @all, $l = { name => $2, indic => $1 };
+ $nb = 0;
+ } else {
+ s/^\s*//;
+ s/\s*$//;
+ my ($field, $val) = /^(.*):\s*(.*)/;
+ if ($field =~ /policy/i) {
+ $field = "policy";
+ $val = lc join(' ', split(' ', $val));
+ $val =~ s/glad to receive a note//;
+ $val =~ s/(but )?please send (a )?message to notify//;
+ $val =~ s/an email note is appreciated//;
+ $val =~ s/please send a message with the//;
+ $val =~ s/no need to notify//;
+ $val =~ s/[(), .;]*$//;
+ $val = "open access" if $val eq "public";
+ warn "$val ($all[-1]{name})\n" if $val ne 'open access';
+ } elsif ($field =~ /^Contact|Synchroni[sz]ation|Location|Geographic\s+Coordinates|Service\s+Area|Note$/i) {
+ } else {
+# warn "bad line ($field) $_\n";
+ return;
+ }
+ $l->{$field} .= ($l->{$field} && ' ') . $val;
+ }
+ $nb++;
+}
+
+
+use Data::Dumper;
+#warn Dumper(\@all);
+
+foreach (grep { $_->{policy} eq 'open access' } @all) {
+ my ($country, $state) = split ' ', $_->{indic};
+ $country = ucfirst(lc $country_codes{$country});
+ $country .= " $state" if $state;
+ printf "\t'%s' => '%s',\n", lc($_->{name}), $country;
+}
+
+BEGIN {
+%country_codes = ( # from ftp://ftp.ripe.net/iso3166-countrycodes
+"AF", "AFGHANISTAN",
+"AL", "ALBANIA",
+"DZ", "ALGERIA",
+"AS", "AMERICAN SAMOA",
+"AD", "ANDORRA",
+"AO", "ANGOLA",
+"AI", "ANGUILLA",
+"AQ", "ANTARCTICA",
+"AG", "ANTIGUA AND BARBUDA",
+"AR", "ARGENTINA",
+"AM", "ARMENIA",
+"AW", "ARUBA",
+"AU", "AUSTRALIA",
+"AT", "AUSTRIA",
+"AZ", "AZERBAIJAN",
+"BS", "BAHAMAS",
+"BH", "BAHRAIN",
+"BD", "BANGLADESH",
+"BB", "BARBADOS",
+"BY", "BELARUS",
+"BE", "BELGIUM",
+"BZ", "BELIZE",
+"BJ", "BENIN",
+"BM", "BERMUDA",
+"BT", "BHUTAN",
+"BO", "BOLIVIA",
+"BA", "BOSNIA AND HERZEGOWINA",
+"BW", "BOTSWANA",
+"BV", "BOUVET ISLAND",
+"BR", "BRAZIL",
+"IO", "BRITISH INDIAN OCEAN TERRITORY",
+"BN", "BRUNEI DARUSSALAM",
+"BG", "BULGARIA",
+"BF", "BURKINA FASO",
+"BI", "BURUNDI",
+"KH", "CAMBODIA",
+"CM", "CAMEROON",
+"CA", "CANADA",
+"CV", "CAPE VERDE",
+"KY", "CAYMAN ISLANDS",
+"CF", "CENTRAL AFRICAN REPUBLIC",
+"TD", "CHAD",
+"CL", "CHILE",
+"CN", "CHINA",
+"CX", "CHRISTMAS ISLAND",
+"CC", "COCOS (KEELING) ISLANDS",
+"CO", "COLOMBIA",
+"KM", "COMOROS",
+"CG", "CONGO",
+"CD", "CONGO, THE DEMOCRATIC REPUBLIC OF THE",
+"CK", "COOK ISLANDS",
+"CR", "COSTA RICA",
+"CI", "COTE D'IVOIRE",
+"HR", "CROATIA",
+"CU", "CUBA",
+"CY", "CYPRUS",
+"CZ", "CZECH REPUBLIC",
+"DK", "DENMARK",
+"DJ", "DJIBOUTI",
+"DM", "DOMINICA",
+"DO", "DOMINICAN REPUBLIC",
+"TP", "EAST TIMOR",
+"EC", "ECUADOR",
+"EG", "EGYPT",
+"SV", "EL SALVADOR",
+"GQ", "EQUATORIAL GUINEA",
+"ER", "ERITREA",
+"EE", "ESTONIA",
+"ET", "ETHIOPIA",
+"FK", "FALKLAND ISLANDS (MALVINAS)",
+"FO", "FAROE ISLANDS",
+"FJ", "FIJI",
+"FI", "FINLAND",
+"FR", "FRANCE",
+"FX", "FRANCE, METROPOLITAN",
+"GF", "FRENCH GUIANA",
+"PF", "FRENCH POLYNESIA",
+"TF", "FRENCH SOUTHERN TERRITORIES",
+"GA", "GABON",
+"GM", "GAMBIA",
+"GE", "GEORGIA",
+"DE", "GERMANY",
+"GH", "GHANA",
+"GI", "GIBRALTAR",
+"GR", "GREECE",
+"GL", "GREENLAND",
+"GD", "GRENADA",
+"GP", "GUADELOUPE",
+"GU", "GUAM",
+"GT", "GUATEMALA",
+"GN", "GUINEA",
+"GW", "GUINEA-BISSAU",
+"GY", "GUYANA",
+"HT", "HAITI",
+"HM", "HEARD AND MC DONALD ISLANDS",
+"VA", "HOLY SEE (VATICAN CITY STATE)",
+"HN", "HONDURAS",
+"HK", "HONG KONG",
+"HU", "HUNGARY",
+"IS", "ICELAND",
+"IN", "INDIA",
+"ID", "INDONESIA",
+"IR", "IRAN (ISLAMIC REPUBLIC OF)",
+"IQ", "IRAQ",
+"IE", "IRELAND",
+"IL", "ISRAEL",
+"IT", "ITALY",
+"JM", "JAMAICA",
+"JP", "JAPAN",
+"JO", "JORDAN",
+"KZ", "KAZAKHSTAN",
+"KE", "KENYA",
+"KI", "KIRIBATI",
+"KP", "KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF",
+"KR", "KOREA, REPUBLIC OF",
+"KW", "KUWAIT",
+"KG", "KYRGYZSTAN",
+"LA", "LAO PEOPLE'S DEMOCRATIC REPUBLIC",
+"LV", "LATVIA",
+"LB", "LEBANON",
+"LS", "LESOTHO",
+"LR", "LIBERIA",
+"LY", "LIBYAN ARAB JAMAHIRIYA",
+"LI", "LIECHTENSTEIN",
+"LT", "LITHUANIA",
+"LU", "LUXEMBOURG",
+"MO", "MACAU",
+"MK", "MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF",
+"MG", "MADAGASCAR",
+"MW", "MALAWI",
+"MY", "MALAYSIA",
+"MV", "MALDIVES",
+"ML", "MALI",
+"MT", "MALTA",
+"MH", "MARSHALL ISLANDS",
+"MQ", "MARTINIQUE",
+"MR", "MAURITANIA",
+"MU", "MAURITIUS",
+"YT", "MAYOTTE",
+"MX", "MEXICO",
+"FM", "MICRONESIA, FEDERATED STATES OF",
+"MD", "MOLDOVA, REPUBLIC OF",
+"MC", "MONACO",
+"MN", "MONGOLIA",
+"MS", "MONTSERRAT",
+"MA", "MOROCCO",
+"MZ", "MOZAMBIQUE",
+"MM", "MYANMAR",
+"NA", "NAMIBIA",
+"NR", "NAURU",
+"NP", "NEPAL",
+"NL", "NETHERLANDS",
+"AN", "NETHERLANDS ANTILLES",
+"NC", "NEW CALEDONIA",
+"NZ", "NEW ZEALAND",
+"NI", "NICARAGUA",
+"NE", "NIGER",
+"NG", "NIGERIA",
+"NU", "NIUE",
+"NF", "NORFOLK ISLAND",
+"MP", "NORTHERN MARIANA ISLANDS",
+"NO", "NORWAY",
+"OM", "OMAN",
+"PK", "PAKISTAN",
+"PW", "PALAU",
+"PA", "PANAMA",
+"PG", "PAPUA NEW GUINEA",
+"PY", "PARAGUAY",
+"PE", "PERU",
+"PH", "PHILIPPINES",
+"PN", "PITCAIRN",
+"PL", "POLAND",
+"PT", "PORTUGAL",
+"PR", "PUERTO RICO",
+"QA", "QATAR",
+"RE", "REUNION",
+"RO", "ROMANIA",
+"RU", "RUSSIA",
+"RW", "RWANDA",
+"KN", "SAINT KITTS AND NEVIS",
+"LC", "SAINT LUCIA",
+"VC", "SAINT VINCENT AND THE GRENADINES",
+"WS", "SAMOA",
+"SM", "SAN MARINO",
+"ST", "SAO TOME AND PRINCIPE",
+"SA", "SAUDI ARABIA",
+"SN", "SENEGAL",
+"SC", "SEYCHELLES",
+"SL", "SIERRA LEONE",
+"SG", "SINGAPORE",
+"SK", "SLOVAKIA (Slovak Republic)",
+"SI", "SLOVENIA",
+"SB", "SOLOMON ISLANDS",
+"SO", "SOMALIA",
+"ZA", "SOUTH AFRICA",
+"GS", "SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS",
+"ES", "SPAIN",
+"LK", "SRI LANKA",
+"SH", "ST. HELENA",
+"PM", "ST. PIERRE AND MIQUELON",
+"SD", "SUDAN",
+"SR", "SURINAME",
+"SJ", "SVALBARD AND JAN MAYEN ISLANDS",
+"SZ", "SWAZILAND",
+"SE", "SWEDEN",
+"CH", "SWITZERLAND",
+"SY", "SYRIAN ARAB REPUBLIC",
+"TW", "TAIWAN, PROVINCE OF CHINA",
+"TJ", "TAJIKISTAN",
+"TZ", "TANZANIA, UNITED REPUBLIC OF",
+"TH", "THAILAND",
+"TG", "TOGO",
+"TK", "TOKELAU",
+"TO", "TONGA",
+"TT", "TRINIDAD AND TOBAGO",
+"TN", "TUNISIA",
+"TR", "TURKEY",
+"TM", "TURKMENISTAN",
+"TC", "TURKS AND CAICOS ISLANDS",
+"TV", "TUVALU",
+"UG", "UGANDA",
+"UA", "UKRAINE",
+"AE", "UNITED ARAB EMIRATES",
+"GB", "UNITED KINGDOM",
+"US", "UNITED STATES",
+"UM", "UNITED STATES MINOR OUTLYING ISLANDS",
+"UY", "URUGUAY",
+"UZ", "UZBEKISTAN",
+"VU", "VANUATU",
+"VE", "VENEZUELA",
+"VN", "VIET NAM",
+"VG", "VIRGIN ISLANDS (BRITISH)",
+"VI", "VIRGIN ISLANDS (U.S.)",
+"WF", "WALLIS AND FUTUNA ISLANDS",
+"EH", "WESTERN SAHARA",
+"YE", "YEMEN",
+"YU", "YUGOSLAVIA",
+"ZM", "ZAMBIA",
+"ZW", "ZIMBABWE",
+
+#added
+"UK", "UNITED KINGDOM",
+);
+}
<a id="drakxtrunktoolsrpcinfoflushedc">Added: drakx/trunk/tools/rpcinfo-flushed.c</a>
===================================================================
--- drakx/trunk/tools/rpcinfo-flushed.c (rev 0)
+++ drakx/trunk/tools/rpcinfo-flushed.c 2011-02-06 23:23:30 UTC (rev 450)
@@ -0,0 +1,740 @@
+#define _(x) x
+
+/* @(#)rpcinfo.c 2.2 88/08/11 4.0 RPCSRC */
+#if !defined(lint) && defined (SCCSID)
+static char sccsid[] = "@(#)rpcinfo.c 1.22 87/08/12 SMI";
+#endif
+
+/*
+ * Copyright (C) 1986, Sun Microsystems, Inc.
+ */
+
+/*
+ * rpcinfo: ping a particular rpc program
+ * or dump the portmapper
+ */
+
+/*
+ * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
+ * unrestricted use provided that this legend is included on all tape
+ * media and as a part of the software program in whole or part. Users
+ * may copy or modify Sun RPC without charge, but are not authorized
+ * to license or distribute it to anyone else except as part of a product or
+ * program developed by the user.
+ *
+ * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
+ * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
+ *
+ * Sun RPC is provided with no support and without any obligation on the
+ * part of Sun Microsystems, Inc. to assist in its use, correction,
+ * modification or enhancement.
+ *
+ * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
+ * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
+ * OR ANY PART THEREOF.
+ *
+ * In no event will Sun Microsystems, Inc. be liable for any lost revenue
+ * or profits or other special, indirect and consequential damages, even if
+ * Sun has been advised of the possibility of such damages.
+ *
+ * Sun Microsystems, Inc.
+ * 2550 Garcia Avenue
+ * Mountain View, California 94043
+ */
+
+#include <getopt.h>
+#include <string.h>
+#include <unistd.h>
+#include <rpc/rpc.h>
+#include <stdio.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <rpc/pmap_prot.h>
+#include <rpc/pmap_clnt.h>
+#include <signal.h>
+#include <ctype.h>
+#include <locale.h>
+#include <libintl.h>
+
+#define MAXHOSTLEN 256
+
+#define MIN_VERS ((u_long) 0)
+#define MAX_VERS ((u_long) 4294967295UL)
+
+static void udpping (u_short portflag, int argc, char **argv);
+static void tcpping (u_short portflag, int argc, char **argv);
+static int pstatus (CLIENT *client, u_long prognum, u_long vers);
+static void pmapdump (int argc, char **argv);
+static bool_t reply_proc (void *res, struct sockaddr_in *who);
+static void brdcst (int argc, char **argv) __attribute__ ((noreturn));
+static void deletereg (int argc, char **argv);
+static void usage (void);
+static u_long getprognum (char *arg);
+static u_long getvers (char *arg);
+static void get_inet_address (struct sockaddr_in *addr, char *host);
+
+/*
+ * Functions to be performed.
+ */
+#define NONE 0 /* no function */
+#define PMAPDUMP 1 /* dump portmapper registrations */
+#define TCPPING 2 /* ping TCP service */
+#define UDPPING 3 /* ping UDP service */
+#define BRDCST 4 /* ping broadcast UDP service */
+#define DELETES 5 /* delete registration for the service */
+
+int
+main (int argc, char **argv)
+{
+ register int c;
+ int errflg;
+ int function;
+ u_short portnum;
+
+ setlocale (LC_ALL, "");
+
+ function = NONE;
+ portnum = 0;
+ errflg = 0;
+ while ((c = getopt (argc, argv, "ptubdn:")) != -1)
+ {
+ switch (c)
+ {
+
+ case 'p':
+ if (function != NONE)
+ errflg = 1;
+ else
+ function = PMAPDUMP;
+ break;
+
+ case 't':
+ if (function != NONE)
+ errflg = 1;
+ else
+ function = TCPPING;
+ break;
+
+ case 'u':
+ if (function != NONE)
+ errflg = 1;
+ else
+ function = UDPPING;
+ break;
+
+ case 'b':
+ if (function != NONE)
+ errflg = 1;
+ else
+ function = BRDCST;
+ break;
+
+ case 'n':
+ portnum = (u_short) atoi (optarg); /* hope we don't get bogus # */
+ break;
+
+ case 'd':
+ if (function != NONE)
+ errflg = 1;
+ else
+ function = DELETES;
+ break;
+
+ case '?':
+ errflg = 1;
+ }
+ }
+
+ if (errflg || function == NONE)
+ {
+ usage ();
+ return 1;
+ }
+
+ switch (function)
+ {
+
+ case PMAPDUMP:
+ if (portnum != 0)
+ {
+ usage ();
+ return 1;
+ }
+ pmapdump (argc - optind, argv + optind);
+ break;
+
+ case UDPPING:
+ udpping (portnum, argc - optind, argv + optind);
+ break;
+
+ case TCPPING:
+ tcpping (portnum, argc - optind, argv + optind);
+ break;
+
+ case BRDCST:
+ if (portnum != 0)
+ {
+ usage ();
+ return 1;
+ }
+ brdcst (argc - optind, argv + optind);
+ break;
+
+ case DELETES:
+ deletereg (argc - optind, argv + optind);
+ break;
+ }
+
+ return 0;
+}
+
+static void
+udpping (portnum, argc, argv)
+ u_short portnum;
+ int argc;
+ char **argv;
+{
+ struct timeval to;
+ struct sockaddr_in addr;
+ enum clnt_stat rpc_stat;
+ CLIENT *client;
+ u_long prognum, vers, minvers, maxvers;
+ int sock = RPC_ANYSOCK;
+ struct rpc_err rpcerr;
+ int failure;
+
+ if (argc < 2 || argc > 3)
+ {
+ usage ();
+ exit (1);
+ }
+ prognum = getprognum (argv[1]);
+ get_inet_address (&addr, argv[0]);
+ /* Open the socket here so it will survive calls to clnt_destroy */
+ sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ if (sock < 0)
+ {
+ perror ("rpcinfo: socket");
+ exit (1);
+ }
+ failure = 0;
+ if (argc == 2)
+ {
+ /*
+ * A call to version 0 should fail with a program/version
+ * mismatch, and give us the range of versions supported.
+ */
+ addr.sin_port = htons (portnum);
+ to.tv_sec = 5;
+ to.tv_usec = 0;
+ if ((client = clntudp_create (&addr, prognum, (u_long) 0,
+ to, &sock)) == NULL)
+ {
+ clnt_pcreateerror ("rpcinfo");
+ printf (_("program %lu is not available\n"), prognum);
+ exit (1);
+ }
+ to.tv_sec = 10;
+ to.tv_usec = 0;
+ rpc_stat = clnt_call (client, NULLPROC, (xdrproc_t) xdr_void,
+ (char *) NULL, (xdrproc_t) xdr_void,
+ (char *) NULL, to);
+ if (rpc_stat == RPC_PROGVERSMISMATCH)
+ {
+ clnt_geterr (client, &rpcerr);
+ minvers = rpcerr.re_vers.low;
+ maxvers = rpcerr.re_vers.high;
+ }
+ else if (rpc_stat == RPC_SUCCESS)
+ {
+ /*
+ * Oh dear, it DOES support version 0.
+ * Let's try version MAX_VERS.
+ */
+ addr.sin_port = htons (portnum);
+ to.tv_sec = 5;
+ to.tv_usec = 0;
+ if ((client = clntudp_create (&addr, prognum, MAX_VERS,
+ to, &sock)) == NULL)
+ {
+ clnt_pcreateerror ("rpcinfo");
+ printf (_("program %lu version %lu is not available\n"),
+ prognum, MAX_VERS);
+ exit (1);
+ }
+ to.tv_sec = 10;
+ to.tv_usec = 0;
+ rpc_stat = clnt_call (client, NULLPROC, (xdrproc_t) xdr_void,
+ NULL, (xdrproc_t) xdr_void, NULL, to);
+ if (rpc_stat == RPC_PROGVERSMISMATCH)
+ {
+ clnt_geterr (client, &rpcerr);
+ minvers = rpcerr.re_vers.low;
+ maxvers = rpcerr.re_vers.high;
+ }
+ else if (rpc_stat == RPC_SUCCESS)
+ {
+ /*
+ * It also supports version MAX_VERS.
+ * Looks like we have a wise guy.
+ * OK, we give them information on all
+ * 4 billion versions they support...
+ */
+ minvers = 0;
+ maxvers = MAX_VERS;
+ }
+ else
+ {
+ (void) pstatus (client, prognum, MAX_VERS);
+ exit (1);
+ }
+ }
+ else
+ {
+ (void) pstatus (client, prognum, (u_long) 0);
+ exit (1);
+ }
+ clnt_destroy (client);
+ for (vers = minvers; vers <= maxvers; vers++)
+ {
+ addr.sin_port = htons (portnum);
+ to.tv_sec = 5;
+ to.tv_usec = 0;
+ if ((client = clntudp_create (&addr, prognum, vers,
+ to, &sock)) == NULL)
+ {
+ clnt_pcreateerror ("rpcinfo");
+ printf (_("program %lu version %lu is not available\n"),
+ prognum, vers);
+ exit (1);
+ }
+ to.tv_sec = 10;
+ to.tv_usec = 0;
+ rpc_stat = clnt_call (client, NULLPROC, (xdrproc_t) xdr_void,
+ NULL, (xdrproc_t) xdr_void, NULL, to);
+ if (pstatus (client, prognum, vers) < 0)
+ failure = 1;
+ clnt_destroy (client);
+ }
+ }
+ else
+ {
+ vers = getvers (argv[2]);
+ addr.sin_port = htons (portnum);
+ to.tv_sec = 5;
+ to.tv_usec = 0;
+ if ((client = clntudp_create (&addr, prognum, vers,
+ to, &sock)) == NULL)
+ {
+ clnt_pcreateerror ("rpcinfo");
+ printf (_("program %lu version %lu is not available\n"),
+ prognum, vers);
+ exit (1);
+ }
+ to.tv_sec = 10;
+ to.tv_usec = 0;
+ rpc_stat = clnt_call (client, 0, (xdrproc_t) xdr_void, NULL,
+ (xdrproc_t) xdr_void, NULL, to);
+ if (pstatus (client, prognum, vers) < 0)
+ failure = 1;
+ }
+ (void) close (sock); /* Close it up again */
+ if (failure)
+ exit (1);
+}
+
+static void
+tcpping (portnum, argc, argv)
+ u_short portnum;
+ int argc;
+ char **argv;
+{
+ struct timeval to;
+ struct sockaddr_in addr;
+ enum clnt_stat rpc_stat;
+ CLIENT *client;
+ u_long prognum, vers, minvers, maxvers;
+ int sock = RPC_ANYSOCK;
+ struct rpc_err rpcerr;
+ int failure;
+
+ if (argc < 2 || argc > 3)
+ {
+ usage ();
+ exit (1);
+ }
+ prognum = getprognum (argv[1]);
+ get_inet_address (&addr, argv[0]);
+ failure = 0;
+ if (argc == 2)
+ {
+ /*
+ * A call to version 0 should fail with a program/version
+ * mismatch, and give us the range of versions supported.
+ */
+ addr.sin_port = htons (portnum);
+ if ((client = clnttcp_create (&addr, prognum, MIN_VERS,
+ &sock, 0, 0)) == NULL)
+ {
+ clnt_pcreateerror ("rpcinfo");
+ printf (_("program %lu is not available\n"), prognum);
+ exit (1);
+ }
+ to.tv_sec = 10;
+ to.tv_usec = 0;
+ rpc_stat = clnt_call (client, NULLPROC, (xdrproc_t) xdr_void, NULL,
+ (xdrproc_t) xdr_void, NULL, to);
+ if (rpc_stat == RPC_PROGVERSMISMATCH)
+ {
+ clnt_geterr (client, &rpcerr);
+ minvers = rpcerr.re_vers.low;
+ maxvers = rpcerr.re_vers.high;
+ }
+ else if (rpc_stat == RPC_SUCCESS)
+ {
+ /*
+ * Oh dear, it DOES support version 0.
+ * Let's try version MAX_VERS.
+ */
+ addr.sin_port = htons (portnum);
+ if ((client = clnttcp_create (&addr, prognum, MAX_VERS,
+ &sock, 0, 0)) == NULL)
+ {
+ clnt_pcreateerror ("rpcinfo");
+ printf (_("program %lu version %lu is not available\n"),
+ prognum, MAX_VERS);
+ exit (1);
+ }
+ to.tv_sec = 10;
+ to.tv_usec = 0;
+ rpc_stat = clnt_call (client, NULLPROC, (xdrproc_t) xdr_void,
+ NULL, (xdrproc_t) xdr_void, NULL, to);
+ if (rpc_stat == RPC_PROGVERSMISMATCH)
+ {
+ clnt_geterr (client, &rpcerr);
+ minvers = rpcerr.re_vers.low;
+ maxvers = rpcerr.re_vers.high;
+ }
+ else if (rpc_stat == RPC_SUCCESS)
+ {
+ /*
+ * It also supports version MAX_VERS.
+ * Looks like we have a wise guy.
+ * OK, we give them information on all
+ * 4 billion versions they support...
+ */
+ minvers = 0;
+ maxvers = MAX_VERS;
+ }
+ else
+ {
+ (void) pstatus (client, prognum, MAX_VERS);
+ exit (1);
+ }
+ }
+ else
+ {
+ (void) pstatus (client, prognum, MIN_VERS);
+ exit (1);
+ }
+ clnt_destroy (client);
+ (void) close (sock);
+ sock = RPC_ANYSOCK; /* Re-initialize it for later */
+ for (vers = minvers; vers <= maxvers; vers++)
+ {
+ addr.sin_port = htons (portnum);
+ if ((client = clnttcp_create (&addr, prognum, vers,
+ &sock, 0, 0)) == NULL)
+ {
+ clnt_pcreateerror ("rpcinfo");
+ printf (_("program %lu version %lu is not available\n"),
+ prognum, vers);
+ exit (1);
+ }
+ to.tv_usec = 0;
+ to.tv_sec = 10;
+ rpc_stat = clnt_call (client, 0, (xdrproc_t) xdr_void, NULL,
+ (xdrproc_t) xdr_void, NULL, to);
+ if (pstatus (client, prognum, vers) < 0)
+ failure = 1;
+ clnt_destroy (client);
+ (void) close (sock);
+ sock = RPC_ANYSOCK;
+ }
+ }
+ else
+ {
+ vers = getvers (argv[2]);
+ addr.sin_port = htons (portnum);
+ if ((client = clnttcp_create (&addr, prognum, vers, &sock,
+ 0, 0)) == NULL)
+ {
+ clnt_pcreateerror ("rpcinfo");
+ printf (_("program %lu version %lu is not available\n"),
+ prognum, vers);
+ exit (1);
+ }
+ to.tv_usec = 0;
+ to.tv_sec = 10;
+ rpc_stat = clnt_call (client, 0, (xdrproc_t) xdr_void, NULL,
+ (xdrproc_t) xdr_void, NULL, to);
+ if (pstatus (client, prognum, vers) < 0)
+ failure = 1;
+ }
+ if (failure)
+ exit (1);
+}
+
+/*
+ * This routine should take a pointer to an "rpc_err" structure, rather than
+ * a pointer to a CLIENT structure, but "clnt_perror" takes a pointer to
+ * a CLIENT structure rather than a pointer to an "rpc_err" structure.
+ * As such, we have to keep the CLIENT structure around in order to print
+ * a good error message.
+ */
+static int
+pstatus (client, prognum, vers)
+ register CLIENT *client;
+ u_long prognum;
+ u_long vers;
+{
+ struct rpc_err rpcerr;
+
+ clnt_geterr (client, &rpcerr);
+ if (rpcerr.re_status != RPC_SUCCESS)
+ {
+ clnt_perror (client, "rpcinfo");
+ printf (_("program %lu version %lu is not available\n"), prognum, vers);
+ return -1;
+ }
+ else
+ {
+ printf (_("program %lu version %lu ready and waiting\n"), prognum, vers);
+ return 0;
+ }
+}
+
+static void
+pmapdump (argc, argv)
+ int argc;
+ char **argv;
+{
+ struct sockaddr_in server_addr;
+ register struct hostent *hp;
+ struct pmaplist *head = NULL;
+ int socket = RPC_ANYSOCK;
+ struct timeval minutetimeout;
+ register CLIENT *client;
+ struct rpcent *rpc;
+
+ if (argc > 1)
+ {
+ usage ();
+ exit (1);
+ }
+ if (argc == 1)
+ get_inet_address (&server_addr, argv[0]);
+ else
+ {
+ bzero ((char *) &server_addr, sizeof server_addr);
+ server_addr.sin_family = AF_INET;
+ if ((hp = gethostbyname ("localhost")) != NULL)
+ bcopy (hp->h_addr, (caddr_t) & server_addr.sin_addr,
+ hp->h_length);
+ else
+ server_addr.sin_addr.s_addr = inet_addr ("0.0.0.0");
+ }
+ minutetimeout.tv_sec = 60;
+ minutetimeout.tv_usec = 0;
+ server_addr.sin_port = htons (PMAPPORT);
+ if ((client = clnttcp_create (&server_addr, PMAPPROG,
+ PMAPVERS, &socket, 50, 500)) == NULL)
+ {
+ clnt_pcreateerror (_("rpcinfo: can't contact portmapper"));
+ exit (1);
+ }
+ if (clnt_call (client, PMAPPROC_DUMP, (xdrproc_t) xdr_void, NULL,
+ (xdrproc_t) xdr_pmaplist, (caddr_t) &head,
+ minutetimeout) != RPC_SUCCESS)
+ {
+ fputs (_("rpcinfo: can't contact portmapper"), stderr);
+ fputs (": ", stderr);
+ clnt_perror (client, "rpcinfo");
+ exit (1);
+ }
+ if (head == NULL)
+ {
+ fputs (_("No remote programs registered.\n"), stdout);
+ }
+ else
+ {
+ fputs (_(" program vers proto port\n"), stdout);
+ for (; head != NULL; head = head->pml_next)
+ {
+ printf ("%10ld%5ld",
+ head->pml_map.pm_prog,
+ head->pml_map.pm_vers);
+ if (head->pml_map.pm_prot == IPPROTO_UDP)
+ printf ("%6s", "udp");
+ else if (head->pml_map.pm_prot == IPPROTO_TCP)
+ printf ("%6s", "tcp");
+ else
+ printf ("%6ld", head->pml_map.pm_prot);
+ printf ("%7ld", head->pml_map.pm_port);
+ rpc = getrpcbynumber (head->pml_map.pm_prog);
+ if (rpc)
+ printf (" %s\n", rpc->r_name);
+ else
+ printf ("\n");
+ }
+ }
+}
+
+/*
+ * reply_proc collects replies from the broadcast.
+ * to get a unique list of responses the output of rpcinfo should
+ * be piped through sort(1) and then uniq(1).
+ */
+
+/*ARGSUSED */
+static bool_t
+reply_proc (res, who)
+ void *res; /* Nothing comes back */
+ struct sockaddr_in *who; /* Who sent us the reply */
+{
+ register struct hostent *hp;
+
+ hp = gethostbyaddr ((char *) &who->sin_addr, sizeof who->sin_addr,
+ AF_INET);
+ printf ("%s %s\n", inet_ntoa (who->sin_addr),
+ (hp == NULL) ? _("(unknown)") : hp->h_name);
+ fflush(stdout);
+ return FALSE;
+}
+
+static void
+brdcst (argc, argv)
+ int argc;
+ char **argv;
+{
+ enum clnt_stat rpc_stat;
+ u_long prognum, vers;
+
+ if (argc != 2)
+ {
+ usage ();
+ exit (1);
+ }
+ prognum = getprognum (argv[0]);
+ vers = getvers (argv[1]);
+ rpc_stat = clnt_broadcast (prognum, vers, NULLPROC, (xdrproc_t) xdr_void,
+ NULL, (xdrproc_t) xdr_void, NULL,
+ (resultproc_t) reply_proc);
+ if ((rpc_stat != RPC_SUCCESS) && (rpc_stat != RPC_TIMEDOUT))
+ {
+ fprintf (stderr, _("rpcinfo: broadcast failed: %s\n"),
+ clnt_sperrno (rpc_stat));
+ exit (1);
+ }
+ exit (0);
+}
+
+static void
+deletereg (argc, argv)
+ int argc;
+ char **argv;
+{
+ u_long prog_num, version_num;
+
+ if (argc != 2)
+ {
+ usage ();
+ exit (1);
+ }
+ if (getuid ())
+ { /* This command allowed only to root */
+ fputs (_("Sorry. You are not root\n"), stderr);
+ exit (1);
+ }
+ prog_num = getprognum (argv[0]);
+ version_num = getvers (argv[1]);
+ if ((pmap_unset (prog_num, version_num)) == 0)
+ {
+ fprintf (stderr, _("rpcinfo: Could not delete registration for prog %s version %s\n"),
+ argv[0], argv[1]);
+ exit (1);
+ }
+}
+
+static void
+usage ()
+{
+ fputs (_("Usage: rpcinfo [ -n portnum ] -u host prognum [ versnum ]\n"),
+ stderr);
+ fputs (_(" rpcinfo [ -n portnum ] -t host prognum [ versnum ]\n"),
+ stderr);
+ fputs (_(" rpcinfo -p [ host ]\n"), stderr);
+ fputs (_(" rpcinfo -b prognum versnum\n"), stderr);
+ fputs (_(" rpcinfo -d prognum versnum\n"), stderr);
+}
+
+static u_long
+getprognum (arg)
+ char *arg;
+{
+ register struct rpcent *rpc;
+ register u_long prognum;
+
+ if (isalpha (*arg))
+ {
+ rpc = getrpcbyname (arg);
+ if (rpc == NULL)
+ {
+ fprintf (stderr, _("rpcinfo: %s is unknown service\n"), arg);
+ exit (1);
+ }
+ prognum = rpc->r_number;
+ }
+ else
+ {
+ prognum = (u_long) atoi (arg);
+ }
+
+ return prognum;
+}
+
+static u_long
+getvers (arg)
+ char *arg;
+{
+ register u_long vers;
+
+ vers = (int) atoi (arg);
+ return vers;
+}
+
+static void
+get_inet_address (addr, host)
+ struct sockaddr_in *addr;
+ char *host;
+{
+ register struct hostent *hp;
+
+ bzero ((char *) addr, sizeof *addr);
+ addr->sin_addr.s_addr = (u_long) inet_addr (host);
+ if (addr->sin_addr.s_addr == INADDR_NONE
+ || addr->sin_addr.s_addr == INADDR_ANY)
+ {
+ if ((hp = gethostbyname (host)) == NULL)
+ {
+ fprintf (stderr, _("rpcinfo: %s is unknown host\n"),
+ host);
+ exit (1);
+ }
+ bcopy (hp->h_addr, (char *) &addr->sin_addr, hp->h_length);
+ }
+ addr->sin_family = AF_INET;
+}
Property changes on: drakx/trunk/tools/rpcinfo-flushed.c
___________________________________________________________________
Added: svn:eol-style
+ native
<a id="drakxtrunktoolsserial_probeMakefile">Added: drakx/trunk/tools/serial_probe/Makefile</a>
===================================================================
--- drakx/trunk/tools/serial_probe/Makefile (rev 0)
+++ drakx/trunk/tools/serial_probe/Makefile 2011-02-06 23:23:30 UTC (rev 450)
@@ -0,0 +1,13 @@
+CFLAGS = -Wall -Os
+CFILES = $(wildcard *.c)
+OFILES = $(CFILES:%.c=%.o)
+GOAL = serial_probe
+
+$(GOAL): $(OFILES)
+
+serial.o: serial.c serial.h device.h kudzu.h
+serial_probe.o: serial_probe.c serial.h device.h
+serial_probe: serial_probe.o
+
+clean:
+ rm -f $(GOAL) $(OFILES) *~
Property changes on: drakx/trunk/tools/serial_probe/Makefile
___________________________________________________________________
Added: svn:eol-style
+ native
<a id="drakxtrunktoolsserial_probedeviceh">Added: drakx/trunk/tools/serial_probe/device.h</a>
===================================================================
--- drakx/trunk/tools/serial_probe/device.h (rev 0)
+++ drakx/trunk/tools/serial_probe/device.h 2011-02-06 23:23:30 UTC (rev 450)
@@ -0,0 +1,104 @@
+/* Copyright 1999-2003 Red Hat, Inc.
+ *
+ * This software may be freely redistributed under the terms of the GNU
+ * public license.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+
+#ifndef _KUDZU_DEVICES_H_
+#define _KUDZU_DEVICES_H_
+
+#include <stdio.h>
+
+enum deviceClass {
+ /* device classes... this is somewhat ad-hoc */
+ CLASS_UNSPEC = ~0,
+ CLASS_OTHER = (1 << 0),
+ CLASS_NETWORK = (1 << 1),
+ CLASS_SCSI = (1 << 2),
+ CLASS_MOUSE = (1 << 3),
+ CLASS_AUDIO = (1 << 4),
+ CLASS_CDROM = (1 << 5),
+ CLASS_MODEM = (1 << 6),
+ CLASS_VIDEO = (1 << 7),
+ CLASS_TAPE = (1 << 8),
+ CLASS_FLOPPY = (1 << 9),
+ CLASS_SCANNER = (1 << 10),
+ CLASS_HD = (1 << 11),
+ CLASS_RAID = (1 << 12),
+ CLASS_PRINTER = (1 << 13),
+ CLASS_CAPTURE = (1 << 14),
+ CLASS_KEYBOARD = (1 << 15),
+ CLASS_MONITOR = (1 << 16),
+ CLASS_USB = (1 << 17),
+ CLASS_SOCKET = (1 << 18),
+ CLASS_FIREWIRE = (1 << 19),
+ CLASS_IDE = (1 << 20)
+};
+
+/* Update this if needed */
+#define CLASS_LAST CLASS_IDE
+
+enum deviceBus {
+ /* 'bus' that a device is attached to... this is also ad-hoc */
+ /* BUS_SBUS is sort of a misnomer - it's more or less Sun */
+ /* OpenPROM probing of all various associated non-PCI buses */
+ BUS_UNSPEC = ~0,
+ BUS_OTHER = (1 << 0),
+ BUS_PCI = (1 << 1),
+ BUS_SBUS = (1 << 2),
+ BUS_SERIAL = (1 << 3),
+ BUS_PSAUX = (1 << 4),
+ BUS_PARALLEL = (1 << 5),
+ BUS_SCSI = (1 << 6),
+ BUS_IDE = (1 << 7),
+ /* Again, misnomer */
+ BUS_KEYBOARD = (1 << 8),
+ BUS_DDC = (1 << 9),
+ BUS_USB = (1 << 10),
+ BUS_ISAPNP = (1 << 11),
+ BUS_MISC = (1 << 12),
+ BUS_FIREWIRE = (1 << 13),
+ BUS_PCMCIA = (1 << 14),
+ BUS_ADB = (1 << 15),
+ BUS_MACIO = (1 << 16)
+};
+
+struct device {
+ /* This pointer is used to make lists by the library. */
+ /* Do not expect it to remain constant (or useful) across library calls. */
+ struct device *next;
+ /* Used for ordering, and for aliasing (modem0, modem1, etc.) */
+ int index;
+ enum deviceClass type; /* type */
+ enum deviceBus bus; /* bus it's attached to */
+ char * device; /* device file associated with it */
+ char * driver; /* driver to load, if any */
+ char * desc; /* a description */
+ int detached; /* should we care if it disappears? */
+ struct device *(*newDevice) (struct device *old, struct device *new);
+ void (*freeDevice) (struct device *dev);
+ void (*writeDevice) (FILE *file, struct device *dev);
+ int (*compareDevice) (struct device *dev1, struct device *dev2);
+};
+
+struct device *newDevice(struct device *old, struct device *new);
+void freeDevice(struct device *dev);
+void writeDevice(FILE *file, struct device *dev);
+int compareDevice(struct device *dev1, struct device *dev2);
+struct device *readDevice(FILE *file);
+
+/* Most of these aren't implemented yet...... */
+/* Return everything found, even non-useful stuff */
+#define PROBE_ALL 1
+/* Don't do 'dangerous' probes that could do weird things (isapnp, serial) */
+#define PROBE_SAFE (1<<1)
+/* Stop at first device found */
+#define PROBE_ONE (1<<2)
+
+#endif
Property changes on: drakx/trunk/tools/serial_probe/device.h
___________________________________________________________________
Added: svn:eol-style
+ native
<a id="drakxtrunktoolsserial_probekudzuh">Added: drakx/trunk/tools/serial_probe/kudzu.h</a>
===================================================================
--- drakx/trunk/tools/serial_probe/kudzu.h (rev 0)
+++ drakx/trunk/tools/serial_probe/kudzu.h 2011-02-06 23:23:30 UTC (rev 450)
@@ -0,0 +1,26 @@
+/* Copyright 1999-2003 Red Hat, Inc.
+ *
+ * This software may be freely redistributed under the terms of the GNU
+ * public license.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _KUDZU_H_
+#define _KUDZU_H_
+
+/* kudzu: it grows on you */
+
+/* level of debugging output */
+#undef DEBUG_LEVEL
+
+#ifdef DEBUG_LEVEL
+#define DEBUG(s...) fprintf(stderr,s)
+#else
+#define DEBUG(s...) ;
+#endif
+
+#endif
Property changes on: drakx/trunk/tools/serial_probe/kudzu.h
___________________________________________________________________
Added: svn:eol-style
+ native
<a id="drakxtrunktoolsserial_probeserialc">Added: drakx/trunk/tools/serial_probe/serial.c</a>
===================================================================
--- drakx/trunk/tools/serial_probe/serial.c (rev 0)
+++ drakx/trunk/tools/serial_probe/serial.c 2011-02-06 23:23:30 UTC (rev 450)
@@ -0,0 +1,1136 @@
+/* Copyright 1999-2003 Red Hat, Inc.
+ *
+ * This software may be freely redistributed under the terms of the GNU
+ * public license.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * probe serial port for PnP/Legacy devices
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <termios.h>
+#include <errno.h>
+#include <string.h>
+#include <signal.h>
+#include <time.h>
+#include <libgen.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <sys/sysmacros.h>
+
+#include <asm/types.h>
+#include <linux/serial.h>
+
+#include "serial.h"
+#include "kudzu.h"
+
+/* character strings ARE null-terminated in the following structure */
+/* these elements are marked with a (string) in the comment */
+/* If PnP device sent 6 bit data stream, we've xlated by a 0x20 offset */
+/* When computing checksum, must remove this offset */
+struct pnp_com_id {
+ unsigned char xlate_6bit; /* does this contain xlated data */
+ unsigned char other_id[17]; /* backward compatibility with pre-PNP */
+ unsigned char other_len; /* length of the other_id */
+ unsigned char pnp_rev[2]; /* PnP revision bytes */
+ unsigned char pnp_rev_str[8]; /* PnP revision (string version) */
+ unsigned char eisa_id[4]; /* EISA Mfr identifier (string) */
+ unsigned char product_id[5]; /* Mfr determined product ID (string) */
+ unsigned char serial_number[9];/* Optional dev serial number (string) */
+ unsigned char class_name[33]; /* Optional PnP Class name (string) */
+ unsigned char driver_id[42]; /* Optional compat device IDs (string) */
+ unsigned char user_name[42]; /* Optional verbose product descr (string)*/
+ unsigned char checksum[2]; /* Optional checksum */
+};
+
+/* there are two possible bytes to signify the start of a PnP ID string */
+#define BeginPnP1 0x28
+#define BeginPnP2 0x08
+
+/* Likewise, two possible stop bytes */
+#define EndPnP1 0x29
+#define EndPnP2 0x09
+
+/* these chars indicate extensions to the base dev id exist */
+#define ExtendPnP1 0x5c
+#define ExtendPnP2 0x3c
+
+#define PNP_COM_MAXLEN 256
+
+/* results from initiating hardware probe of a hardware device */
+#define PNP_COM_FATAL 1 /* system error, check errno */
+#define PNP_COM_FAIL 2 /* probe ok, but found nothing */
+#define PNP_COM_OK 3 /* probe ok, we found it */
+
+/* types of devices we might find */
+/* if PNP_COM_PNPDEV is NOT set, its a legacy device */
+#define PNP_COM_MOUSE 1 /* its a mouse */
+#define PNP_COM_MODEM 2 /* its a modem */
+#define PNP_COM_OTHER 4 /* device is there, cant tell what kind */
+#define PNP_COM_NOEXIST 8 /* no device seen */
+#define PNP_COM_PNPDEV 512 /* its a PNP device */
+
+static void serialFreeDevice(struct serialDevice *dev) {
+ if (dev->pnpmfr) free(dev->pnpmfr);
+ if (dev->pnpmodel) free(dev->pnpmodel);
+ if (dev->pnpcompat) free(dev->pnpcompat);
+ if (dev->pnpdesc) free(dev->pnpdesc);
+ freeDevice((struct device *)dev);
+}
+
+static void serialWriteDevice(FILE *file, struct serialDevice *dev)
+{
+ writeDevice(file, (struct device *) dev);
+ if (dev->pnpmfr)
+ fprintf(file,"pnpmfr: %s\n",dev->pnpmfr);
+ if (dev->pnpmodel)
+ fprintf(file,"pnpmodel: %s\n",dev->pnpmodel);
+ if (dev->pnpcompat)
+ fprintf(file,"pnpcompat: %s\n",dev->pnpcompat);
+ if (dev->pnpdesc)
+ fprintf(file,"pnpdesc: %s\n",dev->pnpdesc);
+}
+
+static int serialCompareDevice( struct serialDevice *dev1, struct serialDevice *dev2)
+{
+ int x;
+
+ x = compareDevice((struct device *)dev1, (struct device *)dev2);
+ if (x && x!=2) return x;
+ if (dev1->pnpmfr && dev2->pnpmfr && strcmp(dev1->pnpmfr,dev2->pnpmfr))
+ return 1;
+ if ((!dev1->pnpmfr || !dev2->pnpmfr) && (dev1->pnpmfr != dev2->pnpmfr))
+ return 1;
+ if (dev1->pnpmodel && dev2->pnpmodel && strcmp(dev1->pnpmodel,dev2->pnpmodel))
+ return 1;
+ if ((!dev1->pnpmodel || !dev2->pnpmodel) && (dev1->pnpmodel != dev2->pnpmodel))
+ return 1;
+ if (dev1->pnpcompat && dev2->pnpcompat && strcmp(dev1->pnpcompat,dev2->pnpcompat))
+ return 1;
+ if ((!dev1->pnpcompat || !dev2->pnpcompat) && (dev1->pnpcompat != dev2->pnpcompat))
+ return 1;
+ if (dev1->pnpdesc && dev2->pnpdesc && strcmp(dev1->pnpdesc,dev2->pnpdesc))
+ return 1;
+ if ((!dev1->pnpdesc || !dev2->pnpdesc) && (dev1->pnpdesc != dev2->pnpdesc))
+ return 1;
+ return x;
+}
+
+
+struct serialDevice * serialNewDevice(struct serialDevice *dev) {
+ struct serialDevice *ret;
+
+ ret = malloc(sizeof(struct serialDevice));
+ memset(ret,'\0',sizeof(struct serialDevice));
+ ret=(struct serialDevice *)newDevice((struct device *)dev,(struct device *)ret);
+ ret->bus = BUS_SERIAL;
+ ret->newDevice = serialNewDevice;
+ ret->freeDevice = serialFreeDevice;
+ ret->writeDevice = serialWriteDevice;
+ ret->compareDevice = serialCompareDevice;
+ if (dev && dev->bus == BUS_SERIAL) {
+ if (dev->pnpmfr)
+ ret->pnpmfr=strdup(dev->pnpmfr);
+ if (dev->pnpmodel)
+ ret->pnpmodel=strdup(dev->pnpmodel);
+ if (dev->pnpcompat)
+ ret->pnpcompat=strdup(dev->pnpcompat);
+ if (dev->pnpdesc)
+ ret->pnpdesc=strdup(dev->pnpdesc);
+ }
+ return ret;
+}
+
+/*
+ * wait_input - wait until there is data available on fd,
+ * for the length of time specified by *timo (indefinite
+ * if timo is NULL).
+ */
+
+static int wait_for_input (int fd, struct timeval *timo) {
+ fd_set ready;
+ int n;
+
+ FD_ZERO(&ready);
+ FD_SET(fd, &ready);
+
+ n = select(fd+1, &ready, NULL, &ready, timo);
+ return n;
+}
+
+static int open_serial_port( char *port ) {
+ int fd;
+
+ DEBUG("opening serial port %s...", port);
+
+ fd = open( port, O_RDWR | O_NONBLOCK);
+ if (fd < 0) {
+ DEBUG("failed.\n");
+ return -1;
+ } else {
+ DEBUG("successful.\n");
+ }
+
+ /* reset file so it is no longer in non-blocking mode */
+ if (fcntl(fd, F_SETFL, 0) < 0) {
+ close(fd);
+ DEBUG("Failed to set port to non-blocking mode\n");
+ return -1;
+ }
+
+ return fd;
+}
+
+/* <0 means ioctl error occurred */
+static int get_serial_lines( int fd ) {
+ int modem_lines;
+
+ ioctl(fd, TIOCMGET, &modem_lines);
+ return modem_lines;
+}
+
+/* <0 means ioctl error occurred */
+static int set_serial_lines( int fd, int modem_lines ) {
+ return ioctl(fd, TIOCMSET, &modem_lines);
+}
+
+/* set serial port to 1200 baud, 'nbits' bits, 1 stop, no parity */
+static int setup_serial_port( int fd, int nbits, struct termios *attr ) {
+
+ DEBUG("setting up serial port\n");
+
+ attr->c_iflag = IGNBRK | IGNPAR;
+ attr->c_cflag = 0;
+ attr->c_cflag &= ~(CSIZE | CSTOPB | PARENB | PARODD | PARENB);
+ attr->c_cflag |= CREAD | CLOCAL; /*| CRTSCTS ; */
+ if (nbits == 7)
+ attr->c_cflag |= CS7 | CSTOPB;
+ else
+ attr->c_cflag |= CS8;
+ attr->c_oflag = 0;
+ attr->c_lflag = 0;
+
+ attr->c_cc[VMIN] = 1;
+ attr->c_cc[VTIME] = 5;
+
+ if (cfsetospeed( attr, B1200))
+ return -1;
+ if (cfsetispeed( attr, B1200))
+ return -1;
+ return tcsetattr(fd, TCSANOW, attr);
+}
+
+/* Initialize the serial port to a known state *before* probing. This is
+ * apparently required for some Logitech mice, who will stubbornly refuse
+ * to respond to PnP probes after they've been opened by gpm or XFree.
+ */
+
+static int init_port(int fd) {
+ struct termios attr;
+
+ if (tcgetattr(fd,&attr))
+ return 1;
+
+ cfsetospeed(&attr, B2400);
+ cfsetispeed(&attr, B2400);
+ attr.c_iflag = IXON | ICRNL;
+ attr.c_cflag = CLOCAL | HUPCL | CREAD | B9600 | CS8;
+ attr.c_oflag = 0;
+ attr.c_lflag = 0;
+ return tcsetattr(fd, TCSANOW, &attr);
+}
+
+
+/* Request for PnP info from serial device */
+/* See page 6 of the pnpcom doc from Microsoft */
+/* Return code tells us what happened */
+/* */
+/* PNP_COM_FATAL - error, errno has reason */
+/* PNP_COM_OK - probe initiated successfully */
+static int init_pnp_com_seq1( int fd ) {
+ int modem_lines;
+ int temp;
+ int dsr_status;
+ int rc = PNP_COM_OK;
+ struct termios portattr;
+
+ DEBUG("initializing 1st PNP sequence\n");
+ if (init_port(fd))
+ return PNP_COM_FATAL;
+
+ modem_lines = get_serial_lines(fd);
+
+ /* COM port initialization, check for device enumerate */
+
+ /* turn on DTR, turn off RTS */
+ modem_lines |= TIOCM_DTR;
+ modem_lines &= ~TIOCM_RTS;
+ set_serial_lines(fd, modem_lines);
+
+ /* wait 200ms for DSR=1 */
+ usleep(200000);
+
+ dsr_status = get_serial_lines(fd) & TIOCM_DSR;
+ /* see if we got DSR coming up */
+
+ if (!dsr_status) {
+ DEBUG("Device did not set DSR\n");
+ }
+
+ /* COM port Setup, 1st phase */
+ temp = tcgetattr(fd, &portattr);
+ if (temp < 0)
+ return PNP_COM_FATAL;
+
+ /* now we set port to be 1200 baud, 7 bits, no parity, 1 stop bit */
+ temp = setup_serial_port( fd, 7, &portattr );
+ if (temp < 0)
+ return PNP_COM_FATAL;
+
+ /* we drop DTR and RTS */
+ modem_lines &= ~( TIOCM_RTS | TIOCM_DTR);
+ set_serial_lines(fd, modem_lines);
+ usleep(200000);
+
+ /* bring DTR back up */
+ modem_lines |= TIOCM_DTR;
+ set_serial_lines(fd, modem_lines);
+ usleep(200000);
+
+ /* Wait for response, 1st phase */
+ modem_lines |= TIOCM_RTS;
+ set_serial_lines(fd, modem_lines);
+ /* usleep(200000); => AQ: not valid as we should look to receive data during this time!! */
+
+ return rc;
+}
+
+
+/* Request for PnP info from serial device */
+/* See page 6 of the pnpcom doc from Microsoft */
+/* Always returns PNP_COM_OK */
+static int init_pnp_com_seq2( int fd ) {
+ int modem_lines;
+ int rc = PNP_COM_OK;
+
+ DEBUG("initializing 2nd PNP sequence\n");
+
+ modem_lines = get_serial_lines(fd);
+
+ /* COM port setup, 2nd phase */
+ /* turn off DTR and RTS */
+ modem_lines &= ~(TIOCM_DTR | TIOCM_RTS);
+ set_serial_lines(fd, modem_lines);
+ usleep(200000);
+
+ /* wait for response, 2nd phase */
+ /* turn on DTR and RTS */
+ modem_lines |= (TIOCM_DTR | TIOCM_RTS);
+ set_serial_lines(fd, modem_lines);
+ /* usleep(200000); => AQ: not valid as we should look to receive data during this time!! */
+
+ return rc;
+}
+
+
+/* Request for PnP info from serial modem device */
+/* Uses ATI9 code, may not do anything but return 'ERROR' */
+/* Return code tells us what happened */
+/* */
+/* PNP_COM_FATAL - error, errno has reason */
+/* PNP_COM_OK - probe initiated successfully */
+/* PNP_COM_FAIL - DSR never came on - try alterntives */
+/* means (ATI9?) to get PnP string */
+static int init_pnp_com_ati9( int fd ) {
+ int modem_lines;
+ int temp;
+ int done;
+ int respindex;
+ int starttime;
+ unsigned char resp[100], buf[2];
+ struct timeval timo;
+ struct termios portattr;
+
+ DEBUG("Querying ATI9 info from modem\n");
+ modem_lines = get_serial_lines(fd);
+
+ /* turn off RTS */
+ modem_lines &= ~TIOCM_RTS;
+ set_serial_lines(fd, modem_lines);
+
+ /* wait 200ms for DSR=1 */
+ usleep(200000);
+
+ /* now we set port to be 1200 baud, 8 bits, no parity, 1 stop bit */
+ temp = tcgetattr(fd, &portattr);
+ if (temp < 0) {
+ modem_lines |= TIOCM_DTR | TIOCM_RTS;
+ set_serial_lines(fd, modem_lines);
+ return PNP_COM_FATAL;
+ }
+
+ /* goto 1200 baud, 8 bits */
+ temp = setup_serial_port( fd, 8, &portattr );
+ if (temp < 0) {
+ modem_lines |= TIOCM_DTR | TIOCM_RTS;
+ set_serial_lines(fd, modem_lines);
+ return PNP_COM_FATAL;
+ }
+
+ /* turn on DTR and RTS */
+ modem_lines = get_serial_lines(fd);
+ modem_lines |= TIOCM_RTS | TIOCM_DTR;
+ set_serial_lines(fd, modem_lines);
+ usleep(200000);
+
+ /* send the 'AT' command */
+ DEBUG("Sending ATI9 command to modem\n");
+
+ write(fd, "ATI9\r", 5);
+
+ /* start reading - read the AT command back */
+ done = 0;
+ respindex= 0;
+ starttime=time(NULL);
+ memset(resp, 0, sizeof(resp));
+ while (!done) {
+ timo.tv_sec=0;
+ timo.tv_usec=250000;
+ if (wait_for_input(fd, &timo) > 0) {
+ temp = read( fd, buf, 1 );
+ if (temp < 0) {
+ if (errno != EAGAIN)
+ return PNP_COM_FATAL;
+ } else {
+ resp[respindex++] = buf[0];
+ resp[respindex] = 0;
+ }
+ } else
+ done = 1;
+
+ /* shouldnt run more than 5 seconds */
+ if (time(NULL)-starttime > 5 )
+ done = 1;
+
+ if (respindex > 6)
+ done = 1;
+
+ if (strstr(resp, "ATI9\r"))
+ done = 1;
+
+ DEBUG("ATI9 probe ->%d \"%s\"\n",respindex, resp);
+ }
+
+ /* see if we saw the 'OK' response */
+ if (strstr(resp, "("))
+ return PNP_COM_OK;
+ else
+ return PNP_COM_FAIL;
+
+ return PNP_COM_OK;
+}
+
+/* See if this is a legacy mouse device */
+/* Only called if the PnP probe above failed */
+/* We turn off the mouse via RS232 lines, then turn it on */
+/* If it spits out an 'M' character (at 1200 baud, 7N1) */
+/* it could be a mouse. */
+/* */
+/* Return code tells us what happened */
+/* */
+/* PNP_COM_FATAL - error, errno has reason */
+/* PNP_COM_OK - probe saw 'M' */
+/* PNP_COM_FAIL - Never saw the 'M' response */
+
+static int find_legacy_mouse( int fd ) {
+ int modem_lines;
+ int temp;
+ int done;
+ int starttime;
+ unsigned char resp[2];
+ struct timeval timo;
+ struct termios portattr;
+
+ DEBUG("looking for a legacy mouse\n");
+
+ /* now we set port to be 1200 baud, 7 bits, no parity, 1 stop bit */
+ temp = tcgetattr(fd, &portattr);
+ if (temp < 0)
+ return PNP_COM_FATAL;
+
+ /* goto 1200 baud, etc etc*/
+ temp = setup_serial_port( fd, 7, &portattr );
+ if (temp < 0)
+ return PNP_COM_FATAL;
+
+ /* we drop DTR and RTS */
+ modem_lines = get_serial_lines(fd);
+ modem_lines &= ~( TIOCM_RTS | TIOCM_DTR);
+ set_serial_lines(fd, modem_lines);
+ usleep(200000);
+
+ /* bring them DTR back up */
+ modem_lines |= TIOCM_DTR | TIOCM_RTS;
+ set_serial_lines(fd, modem_lines);
+
+ /* start reading - after first character we quit */
+ done = 0;
+ starttime=time(NULL);
+ while (!done) {
+ timo.tv_sec=0;
+ timo.tv_usec=250000;
+ if (wait_for_input(fd, &timo) > 0) {
+ temp = read( fd, resp, 1 );
+ if (temp < 0) {
+ if (errno != EAGAIN)
+ return PNP_COM_FATAL;
+ } else {
+ done = 1;
+ }
+ } else
+ done = 1;
+
+
+ /* shouldnt run more than 2 seconds */
+ if (time(NULL)-starttime > 2 )
+ done = 1;
+ }
+ if (*resp == 'M') {
+ DEBUG("Found legacy mouse\n");
+ return PNP_COM_OK;
+ } else
+ return PNP_COM_FAIL;
+}
+
+/* See if this is a legacy modem device */
+/* Only called if the PnP probe above failed */
+/* We send a '!AT' and see if we get an 'OK' back */
+/* */
+/* Return code tells us what happened */
+/* */
+/* PNP_COM_FATAL - error, errno has reason */
+/* PNP_COM_OK - probe saw 'OK' */
+/* PNP_COM_FAIL - Never saw the 'OK' response */
+static int find_legacy_modem( int fd ) {
+ int modem_lines;
+ int temp;
+ int done;
+ int respindex;
+ int starttime;
+ unsigned char resp[10], buf[2];
+ struct timeval timo;
+ struct termios portattr;
+
+ DEBUG("looking for a legacy modem\n");
+
+ /* now we set port to be 1200 baud, 8 bits, no parity, 1 stop bit */
+ temp = tcgetattr(fd, &portattr);
+ if (temp < 0)
+ return PNP_COM_FATAL;
+
+ /* goto 1200 baud, 8 bits */
+ temp = setup_serial_port( fd, 8, &portattr );
+ if (temp < 0)
+ return PNP_COM_FATAL;
+
+ /* turn on DTR and RTS */
+ modem_lines = get_serial_lines(fd);
+ modem_lines |= TIOCM_RTS | TIOCM_DTR;
+ set_serial_lines(fd, modem_lines);
+ usleep(200000);
+
+ /* send the 'AT' command */
+ DEBUG("Sending AT command to modem\n");
+
+ write(fd, "AT\r", 3);
+
+ /* start reading - we'll get AT command back first, then modem response */
+ done = 0;
+ respindex= 0;
+ starttime=time(NULL);
+ memset(resp, 0, sizeof(resp));
+ while (!done) {
+ timo.tv_sec=0;
+ timo.tv_usec=250000;
+ if (wait_for_input(fd, &timo) > 0) {
+ temp = read( fd, buf, 1 );
+ if (temp < 0) {
+ if (errno != EAGAIN)
+ return PNP_COM_FATAL;
+ } else {
+ resp[respindex++] = buf[0];
+ }
+ } else
+ done = 1;
+
+ /* shouldnt run more than 5 seconds */
+ if (time(NULL)-starttime > 5 )
+ done = 1;
+
+ if (respindex > 9)
+ done = 1;
+ }
+
+ /* see if we saw the 'OK' response */
+ if (strstr(resp, "OK"))
+ return PNP_COM_OK;
+ else
+ return PNP_COM_FAIL;
+}
+
+/* retrieve the PnP ID string */
+/* timeout after 3 seconds */
+/* should probably set a 200 msec timeout per char, as spec says */
+/* if no char received, we're done */
+static int read_pnp_string( int fd, unsigned char *pnp_string, int *pnp_len, int pnp_stringbuf_size ) {
+ int pnp_index;
+ int temp, done, counter;
+ int seen_start;
+ time_t starttime;
+ struct timeval timo;
+ unsigned char buf[80];
+ unsigned char end_char;
+
+ DEBUG("Attempting to read PNP ID string\n");
+
+ /* see if we have any input waiting */
+ pnp_index = 0;
+ seen_start = 0;
+ done = 0;
+ end_char = 0;
+ starttime=time(NULL);
+ while (!done) {
+ timo.tv_sec=0;
+ timo.tv_usec=250000;
+ if (wait_for_input(fd, &timo) > 0) {
+ temp = read( fd, buf, 1 );
+ if (temp < 0) {
+ if (errno != EAGAIN)
+ return PNP_COM_FAIL;
+ } else {
+ for (counter=0; counter < temp; counter++) {
+ pnp_string[pnp_index++] = buf[counter];
+ if (seen_start) {
+ if (buf[counter] == end_char) {
+ done=1;
+ break;
+ }
+ } else {
+ if (buf[counter] == BeginPnP1) {
+ seen_start = 1;
+ end_char = EndPnP1;
+ } else if (buf[counter] == BeginPnP2) {
+ seen_start = 1;
+ end_char = EndPnP2;
+ }
+ }
+ }
+ }
+ } else
+ done = 1;
+
+ /* shouldnt run more than 3 seconds */
+ if (time(NULL)-starttime > 3 )
+ done = 1;
+
+ if (pnp_index >= pnp_stringbuf_size)
+ done = 1;
+ }
+ pnp_string[pnp_index] = 0;
+ *pnp_len=pnp_index;
+ if(*pnp_len > 0)
+ return PNP_COM_OK;
+ else /* allows to call seq2 to be conformant */
+ return PNP_COM_FAIL;
+}
+
+/* parse the PnP ID string into components */
+static int parse_pnp_string( unsigned char *pnp_id_string, int pnp_len,
+ struct pnp_com_id *pnp_id ) {
+ unsigned char *p1, *p2;
+ unsigned char *start;
+ unsigned char *end;
+ unsigned char *curpos;
+ unsigned char *endfield;
+ unsigned char *temppos;
+ unsigned char *pnp_string;
+ unsigned char end_char;
+
+ int no_more_extensions=0;
+ int stage;
+ int len;
+ unsigned short int checksum;
+ char hex_checksum[5];
+
+ char extension_delims[] = {EndPnP1, EndPnP2, ExtendPnP1, ExtendPnP2, 0};
+ char end_delims[] = {EndPnP1, EndPnP2, 0};
+ unsigned char* p1end = NULL;
+ unsigned char* p2end = NULL;
+
+ /* clear out pnp_id */
+ memset(pnp_id, 0, sizeof(*pnp_id));
+
+ /* copy pnp_string to temp space */
+ pnp_string = alloca(pnp_len+1);
+ memcpy(pnp_string, pnp_id_string, pnp_len+1);
+
+ /* first find the start of the PnP part of string */
+ p1 = memchr( pnp_string, BeginPnP1, pnp_len );
+ p2 = memchr( pnp_string, BeginPnP2, pnp_len );
+
+
+ if (p1) {
+ int p_len = pnp_len - (p1 - pnp_string);
+ p1end = memchr(p1, EndPnP1, p_len);
+ }
+ if (p2) {
+ int p_len = pnp_len - (p2 - pnp_string);
+ p2end = memchr(p2, EndPnP2, p_len);
+ }
+
+ /* use the one which points nearest to start of the string */
+ /* and is actually defined */
+ if ( p1 && p1end && p2 && p2end ) {
+ start = (p1 < p2) ? p1 : p2;
+ } else if ( p1 && p1end )
+ start = p1;
+ else if ( p2 && p2end )
+ start = p2;
+ else
+ start = NULL;
+
+ /* if no start then we're done */
+ if (!start)
+ return -1;
+
+ /* the length of the initial part cannot be more than 17 bytes */
+ if ((start - pnp_string) > 17)
+ return -1;
+
+ /* setup end character we are looking for based on the start character */
+ if (start == p2) {
+ pnp_id->xlate_6bit = 1;
+ end_char = EndPnP2;
+ /* we need to xlate data in PnP fields */
+ /* remember to skip the revision fields (bytes 1 and 2 after start) */
+ temppos=start;
+ while (1) {
+ if (*temppos == EndPnP2) {
+ *temppos += 0x20;
+ break;
+ } else if (temppos != start+1 && temppos != start+2 )
+ *temppos += 0x20;
+
+ temppos++;
+ }
+ } else {
+ pnp_id->xlate_6bit = 0;
+ end_char = EndPnP1;
+ }
+
+ /* move everything before the start of the PnP block */
+ memcpy(pnp_id->other_id, pnp_string, start-pnp_string);
+ pnp_id->other_len = start - pnp_string;
+
+ /* now we get the PnP fields - all were zero'd out above */
+ curpos = start+1;
+ memcpy(pnp_id->pnp_rev,curpos,2); curpos += 2;
+ memcpy(pnp_id->eisa_id,curpos,3); curpos += 3;
+ memcpy(pnp_id->product_id,curpos,4); curpos += 4;
+ /* now we see if have extension fields */
+ no_more_extensions = 0;
+ stage = 0;
+ while (!no_more_extensions) {
+ if (*curpos == ExtendPnP1 || *curpos == ExtendPnP2) {
+ curpos++;
+ endfield = strpbrk(curpos, extension_delims);
+ if (!endfield)
+ return -1;
+ /* if we reached the end of all PnP data, back off */
+ /* cause there is a checksum at the end of extension data */
+ if (*endfield == EndPnP1 || *endfield == EndPnP2)
+ endfield -= 2;
+ } else
+ break;
+
+ len = endfield - curpos;
+ switch (stage) {
+ case 0:
+ if (len != 8 && len != 0 )
+ return -1;
+
+ memcpy(pnp_id->serial_number,curpos,len);
+ curpos += len;
+ break;
+
+ case 1:
+ if (len > 33)
+ return -1;
+ memcpy(pnp_id->class_name, curpos, len);
+ curpos = endfield;
+ break;
+
+ case 2:
+ if (len > 41)
+ return -1;
+ memcpy(pnp_id->driver_id, curpos, len);
+ curpos = endfield;
+ break;
+
+ case 3:
+ if (len > 41)
+ return -1;
+ memcpy(pnp_id->user_name, curpos, len);
+ curpos = endfield;
+ break;
+ }
+ stage++;
+ }
+
+ /* now find the end of all PnP data */
+ end = strpbrk(curpos, end_delims);
+ if (!end)
+ return -1;
+
+ /* if we had any extensions, we expect an checksum */
+ if (stage != 0) {
+ /* copy checksum into struct */
+ memcpy(pnp_id->checksum, curpos, 2);
+
+ /* compute the checksum as the sum of all PnP bytes, excluding */
+ /* the two byte checksum. */
+ checksum = 0;
+ for (temppos=start; temppos <= end; temppos++) {
+ /* skip checksum in calculation */
+ if (temppos == (end-2) || temppos == (end-1))
+ continue;
+ /* dont xlate the revision at start */
+ if (temppos != (start+1) && temppos != (start+2))
+ checksum += *temppos - ((pnp_id->xlate_6bit) ? 0x20 : 0);
+ else
+ checksum += *temppos;
+ }
+ sprintf(hex_checksum, "%.2X", checksum & 0xff);
+ if (strncmp(hex_checksum, pnp_id->checksum, 2))
+ return -1;
+ }
+
+ /* checksum was ok, so we're done */
+ return 0;
+}
+
+static int attempt_pnp_retrieve(int fd, char *pnp_string, int *pnp_strlen, int pnp_stringbuf_size) {
+ int pnp_probe_status;
+ struct pnp_com_id pnp_id;
+ int tried_at_prodding=0, give_up=0;
+
+ DEBUG("Attempting PNP information retrieval\n");
+
+ while (!give_up) {
+ pnp_probe_status = init_pnp_com_seq1(fd);
+ if (pnp_probe_status == PNP_COM_FATAL)
+ return PNP_COM_FATAL;
+ pnp_probe_status = read_pnp_string(fd, pnp_string, pnp_strlen,
+ pnp_stringbuf_size);
+ if (pnp_probe_status == PNP_COM_FAIL) {
+ init_pnp_com_seq2(fd); /* always succeeds */
+
+ pnp_probe_status = read_pnp_string(fd, pnp_string, pnp_strlen,
+ pnp_stringbuf_size);
+ }
+
+ if (*pnp_strlen == 1 && pnp_string[0] == 'M') /* legacy mouse */
+ return PNP_COM_OK;
+ /* see if we got anything useful, if not try AT command */
+ /* to prod device into correct serial params */
+ if (parse_pnp_string( pnp_string, *pnp_strlen, &pnp_id )<0) {
+ DEBUG("That failed.\n");
+ if (!tried_at_prodding) {
+ DEBUG("Prod modem with AT command.\n");
+ write(fd, "AT\r", 3);
+ tried_at_prodding=1;
+ } else
+ give_up = 1;
+ } else
+ return PNP_COM_OK;
+ }
+
+ /* normal PNP detection has failed. */
+ /* try sending a ATI9 code to the modem to see if we get PnP id back */
+ init_pnp_com_ati9(fd);
+ read_pnp_string(fd, pnp_string, pnp_strlen, pnp_stringbuf_size );
+ if (parse_pnp_string( pnp_string, *pnp_strlen, &pnp_id )<0) {
+ *pnp_strlen = 0;
+ pnp_string[0] = 0;
+ return PNP_COM_FAIL;
+ } else
+ return PNP_COM_OK;
+}
+
+struct device *serialProbe(enum deviceClass probeClass, int probeFlags,
+ struct device *devlist) {
+ int fd;
+ int temp;
+ int pnp_strlen;
+ int devicetype=-1;
+ unsigned char pnp_string[100];
+ char port[20];
+ struct termios origattr;
+ struct pnp_com_id pnp_id;
+ struct serialDevice *serdev;
+ struct stat sb;
+ int maj, twelve=12;
+ int console=-1;
+ int stdin_line=-1;
+ struct serial_struct si;
+
+ DEBUG("Probing for serial ports\n");
+
+ if (probeFlags & PROBE_SAFE) return devlist;
+
+ /* Are we on a serial console? */
+ fstat(0,&sb);
+ maj = major(sb.st_rdev);
+ if (maj != 4 && (maj < 136 || maj > 143)) {
+ if (ioctl (0, TIOCLINUX, &twelve) < 0) {
+ if (ioctl (0, TIOCGSERIAL, &si) >= 0) {
+ if (si.line > 0) {
+ stdin_line = 1 << si.line;
+ } else {
+ stdin_line = 0;
+ }
+ } else stdin_line = 0;
+ }
+ }
+
+ fd=open("/dev/console",O_RDWR);
+ if (fd != -1) {
+ fstat(fd,&sb);
+ maj = major(sb.st_rdev);
+ if (maj != 4 && (maj < 136 || maj > 143)) {
+ if (ioctl (fd, TIOCLINUX, &twelve) < 0) {
+ #ifdef __powerpc__
+ // we could have gotten an error for another reason - like EINVAL
+ // skipping ttyS0 on PPC - which is where most modems reside
+ if (errno == ENOTTY) {
+ #endif
+ if (ioctl (fd, TIOCGSERIAL, &si) >= 0) {
+ if (si.line > 0) {
+ console = 1 << si.line;
+ } else {
+ console = 0;
+ #ifdef __powerpc__
+ }
+ #endif
+ }
+ } else console = 0;
+ }
+ }
+ close(fd);
+ }
+
+
+ if (
+ (probeClass & CLASS_UNSPEC) ||
+ (probeClass & CLASS_OTHER) ||
+ (probeClass & CLASS_MOUSE) ||
+ (probeClass & CLASS_MODEM) ||
+ (probeClass & CLASS_PRINTER)
+ ) {
+ int x;
+
+ for (x=0; x<=3 ; x++) {
+ struct stat sbuf;
+ char lockfile[32];
+ if (x==console || x==stdin_line) continue;
+ snprintf(port,20,"/dev/ttyS%d",x);
+
+ /* Make sure it's not in use */
+ snprintf(lockfile,32,"/var/lock/LCK..ttyS%d",x);
+ if (!stat(lockfile,&sbuf)) {
+ DEBUG("Port %s in use, skipping probe.\n",
+ port);
+ continue;
+ }
+ memset(lockfile,'\0',32);
+ if (readlink("/dev/modem",lockfile,32)>0) {
+ if (!strcmp(basename(port),basename(lockfile))) {
+ snprintf(lockfile,32,"/var/lock/LCK..modem");
+ if (!stat(lockfile,&sbuf)) {
+ DEBUG("Port %s in use, skipping probe.\n",
+ port);
+ continue;
+ }
+ }
+ }
+
+ if ((fd=open_serial_port(port)) < 0) {
+ continue;
+ }
+ /* save the current state of the port */
+ temp = tcgetattr(fd, &origattr);
+ if (temp < 0) {
+ DEBUG("unable to retrieve port attributes...no port present?\n");
+ close(fd);
+ continue;
+ }
+
+
+ /* try twiddling RS232 control lines and see if it talks to us */
+ devicetype=-1;
+ pnp_strlen = 0;
+ if (attempt_pnp_retrieve( fd, pnp_string, &pnp_strlen,
+ sizeof(pnp_string) - 1 ) == PNP_COM_FATAL)
+ goto endprobe;
+
+ /* see if we found any PnP signature */
+ if (pnp_strlen != 0 && (pnp_strlen != 1 || pnp_string[0] != 'M')) {
+
+ /* fill in the PnP com structure */
+ if (parse_pnp_string( pnp_string, pnp_strlen, &pnp_id )<0) {
+ DEBUG("Got PNP data back, but failed to parse. Aborting\n");
+ goto endprobe;
+ } else {
+ char *foo;
+ int len;
+
+ DEBUG("PNP data parsed.\n");
+ serdev = serialNewDevice(NULL);
+
+ if (pnp_id.user_name[0]) {
+ serdev->pnpdesc = strdup(pnp_id.user_name);
+ len = strlen(pnp_id.eisa_id) +
+ strlen(pnp_id.product_id) +
+ strlen(pnp_id.user_name) + 3;
+ foo = malloc(len);
+ snprintf(foo,len,"%s|%s %s",pnp_id.eisa_id,
+ pnp_id.product_id,pnp_id.user_name);
+ } else {
+ len = strlen(pnp_id.eisa_id) +
+ strlen(pnp_id.product_id) + 3;
+ foo = malloc(len);
+ snprintf(foo,len,"%s|%s",pnp_id.eisa_id,
+ pnp_id.product_id);
+ }
+ if (serdev->desc) free(serdev->desc);
+ serdev->desc=strdup(foo);
+ serdev->device=strdup(port+5);
+ if (serdev->driver) free(serdev->driver);
+ serdev->driver=strdup("ignore");
+ serdev->pnpmfr = strdup(pnp_id.eisa_id);
+ serdev->pnpmodel = strdup(pnp_id.product_id);
+
+ free(foo);
+ foo=pnp_id.product_id;
+ if (pnp_id.driver_id) {
+ if (strstr(pnp_id.driver_id,"PNP"))
+ foo = strstr(pnp_id.driver_id,"PNP")+3;
+ serdev->pnpcompat = strdup(pnp_id.driver_id);
+ }
+
+ if (*pnp_id.other_id == 'M' ||
+ !strncmp(pnp_id.class_name, "MOUSE", 5) ||
+ !strncmp(foo, "0F", 2)) {
+ serdev->type = CLASS_MOUSE;
+ if (!strncmp(serdev->desc, "|", 1)) {
+ free(serdev->desc);
+ serdev->desc=strdup("Generic Serial Mouse");
+ }
+ if (serdev->driver) free(serdev->driver);
+ serdev->driver = strdup("generic");
+ }
+ else if (!strncmp(pnp_id.class_name, "MODEM", 5) ||
+ !strncmp(foo, "C", 1))
+ serdev->type = CLASS_MODEM;
+ else if (!strncmp(pnp_id.class_name, "PRINTER", 7))
+ serdev->type = CLASS_PRINTER;
+ else
+ serdev->type = CLASS_OTHER;
+ if (serdev->type & probeClass) {
+ if (devlist)
+ serdev->next = devlist;
+ devlist = (struct device *)serdev;
+ if (probeFlags & PROBE_ONE) {
+ tcsetattr(fd, TCSANOW, &origattr);
+ tcflush(fd, TCIOFLUSH);
+ close(fd);
+ return devlist;
+ }
+ } else {
+ serdev->freeDevice(serdev);
+ }
+ goto endprobe;
+ }
+ } else {
+ DEBUG("No PNP data received.\n");
+ /* try to find a legacy device */
+
+ temp = find_legacy_mouse(fd);
+ if (temp == PNP_COM_FATAL) {
+ goto endprobe;
+ } else if (temp == PNP_COM_OK) {
+ if (probeClass & CLASS_MOUSE) {
+ serdev=serialNewDevice(NULL);
+ serdev->type = CLASS_MOUSE;
+ serdev->device = strdup(port+5);
+ serdev->driver= strdup("generic");
+ serdev->desc = strdup("Generic Serial Mouse");
+ if (devlist)
+ serdev->next = devlist;
+ devlist = (struct device *)serdev;
+ if (probeFlags & PROBE_ONE) {
+ tcsetattr(fd, TCSANOW, &origattr);
+ tcflush(fd, TCIOFLUSH);
+ close(fd);
+ return devlist;
+ }
+ }
+ goto endprobe;
+ } else {
+ DEBUG("Didn't see a legacy mouse.\n");
+
+ temp = find_legacy_modem(fd);
+ if (temp == PNP_COM_FATAL) {
+ goto endprobe;
+ } else if (temp == PNP_COM_OK) {
+ DEBUG("Legacy modem signature seen.\n");
+ if (probeClass & CLASS_MODEM) {
+ serdev=serialNewDevice(NULL);
+ serdev->type = CLASS_MODEM;
+ serdev->device = strdup(port+5);
+ serdev->driver= strdup("ignore");
+ serdev->desc = strdup("Generic Serial Modem");
+ if (devlist)
+ serdev->next = devlist;
+ devlist = (struct device *)serdev;
+ if (probeFlags & PROBE_ONE) {
+ tcsetattr(fd, TCSANOW, &origattr);
+ tcflush(fd, TCIOFLUSH);
+ close(fd);
+ return devlist;
+ }
+ }
+ goto endprobe;
+ } else {
+ DEBUG("Didnt see a legacy modem, game over.\n");
+ }
+ }
+ }
+ endprobe:
+ DEBUG("Restoring original port attributes\n");
+ tcsetattr(fd, TCSANOW, &origattr);
+ tcflush(fd, TCIOFLUSH);
+ close(fd);
+ }
+ }
+ return devlist;
+}
Property changes on: drakx/trunk/tools/serial_probe/serial.c
___________________________________________________________________
Added: svn:eol-style
+ native
<a id="drakxtrunktoolsserial_probeserialh">Added: drakx/trunk/tools/serial_probe/serial.h</a>
===================================================================
--- drakx/trunk/tools/serial_probe/serial.h (rev 0)
+++ drakx/trunk/tools/serial_probe/serial.h 2011-02-06 23:23:30 UTC (rev 450)
@@ -0,0 +1,43 @@
+/* Copyright 1999-2003 Red Hat, Inc.
+ *
+ * This software may be freely redistributed under the terms of the GNU
+ * public license.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _KUDZU_SERIAL_H_
+#define _KUDZU_SERIAL_H_
+
+#include "device.h"
+
+struct serialDevice {
+ /* common fields */
+ struct device *next; /* next device in list */
+ int index;
+ enum deviceClass type; /* type */
+ enum deviceBus bus; /* bus it's attached to */
+ char * device; /* device file associated with it */
+ char * driver; /* driver to load, if any */
+ char * desc; /* a description */
+ int detached;
+ /* serial-specific fields */
+ struct serialDevice *(*newDevice) (struct serialDevice *dev);
+ void (*freeDevice) (struct serialDevice *dev);
+ void (*writeDevice) (FILE *file, struct serialDevice *dev);
+ int (*compareDevice) (struct serialDevice *dev1, struct serialDevice *dev2);
+ char * pnpmfr;
+ char * pnpmodel;
+ char * pnpcompat;
+ char * pnpdesc;
+
+};
+
+struct serialDevice *serialNewDevice(struct serialDevice *dev);
+struct device *serialProbe(enum deviceClass probeClass, int probeFlags,
+ struct device *devlist);
+
+#endif
Property changes on: drakx/trunk/tools/serial_probe/serial.h
___________________________________________________________________
Added: svn:eol-style
+ native
<a id="drakxtrunktoolsserial_probeserial_probec">Added: drakx/trunk/tools/serial_probe/serial_probe.c</a>
===================================================================
--- drakx/trunk/tools/serial_probe/serial_probe.c (rev 0)
+++ drakx/trunk/tools/serial_probe/serial_probe.c 2011-02-06 23:23:30 UTC (rev 450)
@@ -0,0 +1,114 @@
+/* Copyright 1999 Mandrakesoft <fpons@mandrakesoft.com>
+ *
+ * The following file used by this one are copyrighted by RedHat and
+ * are taken from kudzu :
+ * device.h
+ * serial.h
+ * serial.c
+ * This file is taken from kudzu.c copyrighted by RedHat, 1999.
+ *
+ * This software may be freely redistributed under the terms of the GNU
+ * public license.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "serial.h"
+#include "device.h"
+
+typedef struct device *(newFunc)(struct device *);
+typedef int (initFunc)();
+typedef struct device *(probeFunc)(enum deviceClass, int, struct device *);
+
+char *classStrings[] = {
+ "UNSPEC", "OTHER", "NETWORK", "SCSI", "VIDEO", "AUDIO",
+ "MOUSE", "MODEM", "CDROM", "TAPE", "FLOPPY", "SCANNER",
+ "HD", "RAID", "PRINTER", "CAPTURE", "KEYBOARD", NULL
+};
+
+struct device *newDevice(struct device *old, struct device *new) {
+ if (!old) {
+ if (!new) {
+ new = malloc(sizeof(struct device));
+ memset(new,'\0',sizeof(struct device));
+ }
+ new->type = CLASS_UNSPEC;
+ } else {
+ new->type = old->type;
+ if (old->device) new->device = strdup(old->device);
+ if (old->driver) new->driver = strdup(old->driver);
+ if (old->desc) new->desc = strdup(old->desc);
+ }
+ new->newDevice = newDevice;
+ new->freeDevice = freeDevice;
+ new->compareDevice = compareDevice;
+ return new;
+}
+
+void freeDevice(struct device *dev) {
+ if (!dev) {
+ printf("freeDevice(null)\n");
+ abort(); /* return; */
+ }
+ if (dev->device) free (dev->device);
+ if (dev->driver) free (dev->driver);
+ if (dev->desc) free (dev->desc);
+ free (dev);
+}
+
+void writeDevice(FILE *file, struct device *dev) {}
+int compareDevice(struct device *dev1, struct device *dev2) { return 0; }
+
+int main () {
+ struct device* devices = NULL;
+ struct serialDevice* serialDevice = NULL;
+
+ devices = serialProbe(CLASS_UNSPEC, 0, devices);
+ while (devices) {
+ serialDevice = (struct serialDevice*)devices;
+
+ printf("CLASS=");
+ if (serialDevice->type == CLASS_UNSPEC) puts("UNSPEC"); else
+ if (serialDevice->type == CLASS_OTHER) puts("OTHER"); else
+ if (serialDevice->type == CLASS_NETWORK) puts("NETWORK"); else
+ if (serialDevice->type == CLASS_SCSI) puts("SCSI"); else
+ if (serialDevice->type == CLASS_MOUSE) puts("MOUSE"); else
+ if (serialDevice->type == CLASS_AUDIO) puts("AUDIO"); else
+ if (serialDevice->type == CLASS_CDROM) puts("CDROM"); else
+ if (serialDevice->type == CLASS_MODEM) puts("MODEM"); else
+ if (serialDevice->type == CLASS_VIDEO) puts("VIDEO"); else
+ if (serialDevice->type == CLASS_TAPE) puts("TAPE"); else
+ if (serialDevice->type == CLASS_FLOPPY) puts("FLOPPY"); else
+ if (serialDevice->type == CLASS_SCANNER) puts("SCANNER"); else
+ if (serialDevice->type == CLASS_HD) puts("HD"); else
+ if (serialDevice->type == CLASS_RAID) puts("RAID"); else
+ if (serialDevice->type == CLASS_PRINTER) puts("PRINTER"); else
+ if (serialDevice->type == CLASS_CAPTURE) puts("CAPTURE"); else
+ if (serialDevice->type == CLASS_KEYBOARD) puts("KEYBOARD"); else
+ if (serialDevice->type == CLASS_MONITOR) puts("MONITOR"); else
+ if (serialDevice->type == CLASS_USB) puts("USB"); else
+ if (serialDevice->type == CLASS_SOCKET) puts("SOCKET"); else
+ if (serialDevice->type == CLASS_FIREWIRE) puts("FIREWIRE"); else
+ if (serialDevice->type == CLASS_IDE) puts("IDE");
+ printf("BUS=SERIAL\n");
+ printf("DEVICE=/dev/%s\n", serialDevice->device);
+ printf("DRIVER=%s\n", serialDevice->driver);
+ if (!serialDevice->pnpdesc) printf("DESCRIPTION=%s\n", serialDevice->desc);
+ if (serialDevice->pnpmfr) printf("MANUFACTURER=%s\n", serialDevice->pnpmfr);
+ if (serialDevice->pnpmodel) printf("MODEL=%s\n", serialDevice->pnpmodel);
+ if (serialDevice->pnpcompat) printf("COMPAT=%s\n", serialDevice->pnpcompat);
+ if (serialDevice->pnpdesc) printf("DESCRIPTION=%s\n", serialDevice->pnpdesc);
+ printf("\n");
+
+ devices=devices->next;
+ }
+
+ return 0;
+}
Property changes on: drakx/trunk/tools/serial_probe/serial_probe.c
___________________________________________________________________
Added: svn:eol-style
+ native
<a id="drakxtrunktoolsshift_allpl">Added: drakx/trunk/tools/shift_all.pl</a>
===================================================================
--- drakx/trunk/tools/shift_all.pl (rev 0)
+++ drakx/trunk/tools/shift_all.pl 2011-02-06 23:23:30 UTC (rev 450)
@@ -0,0 +1,113 @@
+use MDK::Common;
+
+my %shifts = (
+'af' => 1,
+'am' => 1,
+'ar' => 0,
+'az' => 1,
+'be' => 2,
+'bg' => 2,
+'bn' => 1,
+'br' => 2,
+'bs' => 2,
+'ca' => 2,
+'cs' => 2,
+'cy' => 2,
+'da' => 2,
+'de' => 2,
+'el' => 2,
+'en_GB' => 2,
+'en_US' => 2,
+'eo' => 2,
+'es' => 2,
+'et' => 2,
+'eu' => 2,
+'fa' => 0,
+'fi' => 1,
+'fo' => 2,
+'fr' => 2,
+'ga' => 2,
+'gd' => 2,
+'gl' => 2,
+'gv' => 2,
+'he' => 0,
+'hi' => 1,
+'hr' => 2,
+'hu' => 2,
+'hy' => 1,
+'ia' => 2,
+'id' => 1,
+'is' => 1,
+'it' => 1,
+'iu' => 1,
+'ja' => 3,
+'ka' => 1,
+'kn' => 1,
+'ko' => 1,
+'kw' => 0,
+'lo' => 0,
+'lt' => 0,
+'lv' => 0,
+'mi' => 0,
+'mk' => 0,
+'mn' => 0,
+'mr' => 0,
+'ms' => 0,
+'mt' => 0,
+'nb' => 0,
+'nl' => 0,
+'nn' => 0,
+'no' => 0,
+'oc' => 0,
+'pl' => 0,
+'pt_BR' => 0,
+'pt' => 0,
+'ro' => 0,
+'ru' => 0,
+'sk' => 0,
+'sl' => 0,
+'sp' => 0,
+'sq' => 0,
+'sr' => 0,
+'sv' => 0,
+'ta' => 1,
+'te' => 1,
+'tg' => 0,
+'th' => 0,
+'tr' => 0,
+'tt' => 1,
+'uk' => 0,
+'ur' => 1,
+'uz' => 0,
+'vi' => 0,
+'wa' => 0,
+'yi' => 0,
+'zh_CN' => 0,
+'zh_TW' => 0,
+);
+
+foreach (glob("lang*.png")) {
+ /lang-(.*)\.png/;
+ exists $shifts{$1} or die "doesn't exist for $_";
+ $shifts{$1} or next;
+ print "./a.out $_ l.png $shifts{$1}\n";
+ system("./a.out $_ l.png $shifts{$1}");
+ renamef('l.png', $_);
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<a id="drakxtrunktoolsshift_imgc">Added: drakx/trunk/tools/shift_img.c</a>
===================================================================
--- drakx/trunk/tools/shift_img.c (rev 0)
+++ drakx/trunk/tools/shift_img.c 2011-02-06 23:23:30 UTC (rev 450)
@@ -0,0 +1,165 @@
+/*
+ * Guillaume Cottenceau (gc at mandriva.com)
+ *
+ * Copyright 2002-2005 Mandriva
+ *
+ * This software may be freely redistributed under the terms of the GNU
+ * public license.
+ *
+ */
+
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+
+#define PNG_DEBUG 3
+#include <png.h>
+
+void abort_(const char * s, ...)
+{
+ va_list args;
+ va_start(args, s);
+ vfprintf(stderr, s, args);
+ fprintf(stderr, "\n");
+ va_end(args);
+ abort();
+}
+
+int x, y;
+
+int width, height;
+png_byte color_type;
+png_byte bit_depth;
+
+png_structp png_ptr;
+png_infop info_ptr;
+int number_of_passes;
+png_bytep * row_pointers;
+
+void read_png_file(char* file_name)
+{
+ char header[8]; // 8 is the maximum size that can be checked
+
+ /* open file and test for it being a png */
+ FILE *fp = fopen(file_name, "rb");
+ if (!fp)
+ abort_("[read_png_file] File %s could not be opened for reading", file_name);
+ fread(header, 1, 8, fp);
+ if (png_sig_cmp(header, 0, 8))
+ abort_("[read_png_file] File %s is not recognized as a PNG file", file_name);
+
+
+ /* initialize stuff */
+ png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+
+ if (!png_ptr)
+ abort_("[read_png_file] png_create_read_struct failed");
+
+ info_ptr = png_create_info_struct(png_ptr);
+ if (!info_ptr)
+ abort_("[read_png_file] png_create_info_struct failed");
+
+ if (setjmp(png_jmpbuf(png_ptr)))
+ abort_("[read_png_file] Error during init_io");
+
+ png_init_io(png_ptr, fp);
+ png_set_sig_bytes(png_ptr, 8);
+
+ png_read_info(png_ptr, info_ptr);
+
+ width = info_ptr->width;
+ height = info_ptr->height;
+ color_type = info_ptr->color_type;
+ bit_depth = info_ptr->bit_depth;
+
+ number_of_passes = png_set_interlace_handling(png_ptr);
+ png_read_update_info(png_ptr, info_ptr);
+
+
+ /* read file */
+ if (setjmp(png_jmpbuf(png_ptr)))
+ abort_("[read_png_file] Error during read_image");
+
+ row_pointers = (png_bytep*) malloc(sizeof(png_bytep) * height);
+ for (y=0; y<height; y++)
+ row_pointers[y] = (png_byte*) malloc(info_ptr->rowbytes);
+
+ png_read_image(png_ptr, row_pointers);
+}
+
+
+void write_png_file(char* file_name)
+{
+ /* create file */
+ FILE *fp = fopen(file_name, "wb");
+ if (!fp)
+ abort_("[write_png_file] File %s could not be opened for writing", file_name);
+
+
+ /* initialize stuff */
+ png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+
+ if (!png_ptr)
+ abort_("[write_png_file] png_create_write_struct failed");
+
+ info_ptr = png_create_info_struct(png_ptr);
+ if (!info_ptr)
+ abort_("[write_png_file] png_create_info_struct failed");
+
+ if (setjmp(png_jmpbuf(png_ptr)))
+ abort_("[write_png_file] Error during init_io");
+
+ png_init_io(png_ptr, fp);
+
+
+ /* write header */
+ if (setjmp(png_jmpbuf(png_ptr)))
+ abort_("[write_png_file] Error during writing header");
+
+ png_set_IHDR(png_ptr, info_ptr, width, height,
+ bit_depth, color_type, PNG_INTERLACE_NONE,
+ PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
+
+ png_write_info(png_ptr, info_ptr);
+
+
+ /* write bytes */
+ if (setjmp(png_jmpbuf(png_ptr)))
+ abort_("[write_png_file] Error during writing bytes");
+
+ png_write_image(png_ptr, row_pointers);
+
+
+ /* end write */
+ if (setjmp(png_jmpbuf(png_ptr)))
+ abort_("[write_png_file] Error during end of write");
+
+ png_write_end(png_ptr, NULL);
+
+}
+
+void process_file(char* shift)
+{
+ int shift_ = atoi(shift);
+
+ if (info_ptr->color_type != PNG_COLOR_TYPE_RGBA)
+ abort_("[process_file] color_type of input file must be PNG_COLOR_TYPE_RGBA (is %d)", info_ptr->color_type);
+
+ width -= shift_;
+ for (y=0; y<height; y++) {
+ row_pointers[y] += 4 * shift_;
+ }
+
+}
+
+
+int main(int argc, char **argv)
+{
+ if (argc != 4)
+ abort_("Usage: program_name <file_in> <file_out> <shift>");
+
+ read_png_file(argv[1]);
+ process_file(argv[3]);
+ write_png_file(argv[2]);
+}
Property changes on: drakx/trunk/tools/shift_img.c
___________________________________________________________________
Added: svn:eol-style
+ native
<a id="drakxtrunktoolssimplifydrakxmodules">Added: drakx/trunk/tools/simplify-drakx-modules</a>
===================================================================
--- drakx/trunk/tools/simplify-drakx-modules (rev 0)
+++ drakx/trunk/tools/simplify-drakx-modules 2011-02-06 23:23:30 UTC (rev 450)
@@ -0,0 +1,5 @@
+#!/usr/bin/perl -pi
+
+s/^\s*use\s+(diagnostics|strict|vars|warnings).*//g;
+
+/^__END__/ and $_ = '', close ARGV;
Property changes on: drakx/trunk/tools/simplify-drakx-modules
___________________________________________________________________
Added: svn:executable
+ *
<a id="drakxtrunktoolsspecific_arch">Added: drakx/trunk/tools/specific_arch</a>
===================================================================
--- drakx/trunk/tools/specific_arch (rev 0)
+++ drakx/trunk/tools/specific_arch 2011-02-06 23:23:30 UTC (rev 450)
@@ -0,0 +1,9 @@
+#!/usr/bin/perl
+
+use MDK::Common;
+
+print join(' ', map {
+ my $arch = arch();
+ $arch = $compat_arch{$arch} while $arch && !-e "$_.$arch";
+ -e "$_.$arch" ? "$_.$arch" : ();
+ } @ARGV), "\n";
Property changes on: drakx/trunk/tools/specific_arch
___________________________________________________________________
Added: svn:executable
+ *
<a id="drakxtrunktoolsxhostc">Added: drakx/trunk/tools/xhost+.c</a>
===================================================================
--- drakx/trunk/tools/xhost+.c (rev 0)
+++ drakx/trunk/tools/xhost+.c 2011-02-06 23:23:30 UTC (rev 450)
@@ -0,0 +1,11 @@
+#include <stdlib.h>
+#include <X11/Xlib.h>
+
+
+int main(int argc, char **argv) {
+ Display *d = XOpenDisplay(getenv("DISPLAY") ? getenv("DISPLAY") : ":0");
+ if (d == NULL) exit(1);
+ XDisableAccessControl(d);
+ XCloseDisplay(d);
+ exit(0);
+}
Property changes on: drakx/trunk/tools/xhost+.c
___________________________________________________________________
Added: svn:eol-style
+ native
</pre></div>
</body>
</html>
|