summaryrefslogtreecommitdiffstats
path: root/private/nw/convert/nwconv/servlist.c
blob: 97a272746f2d475aadd4a16cefc2bd5f60a8c9b6 (plain) (blame)
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
/*
  +-------------------------------------------------------------------------+
  |               Server Linked List Manipulation Routines                  |
  +-------------------------------------------------------------------------+
  |                     (c) Copyright 1993-1994                             |
  |                          Microsoft Corp.                                |
  |                        All rights reserved                              |
  |                                                                         |
  | Program               : [ServList.c]                                    |
  | Programmer            : Arthur Hanson                                   |
  | Original Program Date : [Feb 15, 1994]                                  |
  | Last Update           : [Jun 16, 1994]                                  |
  |                                                                         |
  | Version:  1.00                                                          |
  |                                                                         |
  | Description:                                                            |
  |   Bunch of similar utility functions for adding to, deleting from,      |
  |   saving and restoring data lists.                                      |
  |                                                                         |
  |                                                                         |
  | History:                                                                |
  |   arth  Jun 16, 1994    1.00    Original Version.                       |
  |                                                                         |
  +-------------------------------------------------------------------------+
*/

#include "globals.h"
#include "convapi.h"
#include "columnlb.h"
#include "ntnetapi.h"
#include "nwnetapi.h"
#include "userdlg.h"
#include "filedlg.h"

// define from SBrowse.c -> for SourceShareListFixup
BOOL MapShare(SHARE_BUFFER *Share, DEST_SERVER_BUFFER *DServ);

static ULONG NumDServs = 0;
static ULONG NumSServs = 0;
static ULONG NumDomains = 0;

// Note:  Most of these routines are a bunch of doubly-linked list functions
//        as such it should be possible to condense them to use some common
//        functions for add/delete/insert.  However virtual-shares will have
//        to be different as the Virtual BOOL has to be the first field.


/*+-------------------------------------------------------------------------+
  |                    Routines for Directory/File Trees                    |
  +-------------------------------------------------------------------------+*/

/*+-------------------------------------------------------------------------+
  | TreeSave()
  |
  +-------------------------------------------------------------------------+*/
void _TreeSaveR(HANDLE hFile, DIR_BUFFER *Dir) {
   DIR_BUFFER *DList;
   ULONG Size;
   ULONG i;
   DWORD wrote;

   if (Dir == NULL)
      return;

   // First save out the file list for this node
   if (Dir->FileList) {
      WriteFile(hFile, &Dir->FileList->Count, sizeof(Dir->FileList->Count), &wrote, NULL);
      Size = sizeof(FILE_LIST) + (Dir->FileList->Count * sizeof(FILE_BUFFER));
      WriteFile(hFile, Dir->FileList, Size, &wrote, NULL);
   }

   if (Dir->DirList) {
      DList = Dir->DirList->DirBuffer;

      // first write out this dirlist then recurse down tree.
      WriteFile(hFile, &Dir->DirList->Count, sizeof(Dir->DirList->Count), &wrote, NULL);
      Size = sizeof(DIR_LIST) + (Dir->DirList->Count * sizeof(DIR_BUFFER));
      WriteFile(hFile, Dir->DirList, Size, &wrote, NULL);

      for (i = 0; i < Dir->DirList->Count; i++)
         _TreeSaveR(hFile, &DList[i]);

   }

} // _TreeSaveR


void TreeSave(HANDLE hFile, DIR_BUFFER *Dir) {
   DWORD wrote;

   if (Dir == NULL)
      return;

   // Make sure we save the minimum amount
   TreePrune(Dir);

   // write out the actual dir
   WriteFile(hFile, Dir, sizeof(DIR_BUFFER), &wrote, NULL);

   // now save it's child info recursively
   _TreeSaveR(hFile, Dir);

} // TreeSave


/*+-------------------------------------------------------------------------+
  | TreeLoad()
  |
  +-------------------------------------------------------------------------+*/
void _TreeLoadR(HANDLE hFile, DIR_BUFFER *Dir) {
   DIR_LIST *DList;
   DIR_BUFFER *DBuff;
   FILE_LIST *FList;
   FILE_BUFFER *FBuff;
   ULONG Size;
   ULONG i;
   DWORD wrote;
   ULONG Count;

   if (Dir == NULL)
      return;

   // First save out the file list for this node
   if (Dir->FileList) {
      ReadFile(hFile, &Count, sizeof(Count), &wrote, NULL);
      Size = sizeof(FILE_LIST) + (sizeof(FILE_BUFFER) * Count);
      FList = AllocMemory(Size);
      ReadFile(hFile, FList, Size, &wrote, NULL);

      // Read it in, now fixup the internal pointers.
      FList->parent = Dir;

      FBuff = FList->FileBuffer;
      for (i = 0; i < FList->Count; i++)
         FBuff[i].parent = FList;

      Dir->FileList = FList;
   }

   if (Dir->DirList) {
      ReadFile(hFile, &Count, sizeof(Count), &wrote, NULL);
      Size = sizeof(DIR_LIST) + (sizeof(DIR_BUFFER) * Count);
      DList = AllocMemory(Size);
      ReadFile(hFile, DList, Size, &wrote, NULL);

      // Read it in, now fixup the internal pointers.
      DList->parent = Dir;

      DBuff = DList->DirBuffer;
      for (i = 0; i < DList->Count; i++)
         DBuff[i].parent = DList;

      Dir->DirList = DList;

      // Now recurse into children and fix them up
      for (i = 0; i < DList->Count; i++)
         _TreeLoadR(hFile, &DBuff[i]);

   }

} // _TreeLoadR


void TreeLoad(HANDLE hFile, DIR_BUFFER **pDir) {
   DIR_BUFFER *Dir;
   DWORD wrote;

   if (pDir == NULL)
      return;

   // Allocate space for the new root
   Dir = AllocMemory(sizeof(DIR_BUFFER));
   if (Dir == NULL)
      return;

   memset(Dir, 0, sizeof(DIR_BUFFER));

   // set passed in var to new memory and read in values from file
   *pDir = Dir;
   ReadFile(hFile, Dir, sizeof(DIR_BUFFER), &wrote, NULL);

   // now recursively load child information
   _TreeLoadR(hFile, Dir);

} // TreeLoad


/*+-------------------------------------------------------------------------+
  |                        Routines for User Lists                          |
  +-------------------------------------------------------------------------+*/

/*+-------------------------------------------------------------------------+
  | UserListCompare()
  |
  +-------------------------------------------------------------------------+*/
int __cdecl UserListCompare(const void *arg1, const void *arg2) {
   USER_BUFFER *ULarg1, *ULarg2;

   ULarg1 = (USER_BUFFER *) arg1;
   ULarg2 = (USER_BUFFER *) arg2;

   // This works as the first item of the structure is the string
   return lstrcmpi( ULarg1->Name, ULarg2->Name);

} // UserListCompare


/*+-------------------------------------------------------------------------+
  |                        Routines for Share Lists                         |
  +-------------------------------------------------------------------------+*/

/*+-------------------------------------------------------------------------+
  | ShareListDelete()
  |
  +-------------------------------------------------------------------------+*/
void ShareListDelete(SHARE_LIST *ShareList) {
   SHARE_BUFFER *SList;
   VIRTUAL_SHARE_BUFFER *VShare;
   ULONG i;

   if (ShareList == NULL)
      return;

   SList = ShareList->SList;
   for (i = 0; i < ShareList->Count; i++) {
      if (SList[i].Root != NULL) {
         TreeDelete(SList[i].Root);
         FreeMemory(SList[i].Root);
      }

      // Note:  SList[i].Drive points to a dest server drive, so we don't
      //        free it here.
      if (!ShareList->Fixup)
         if (SList[i].Virtual) {
            VShare = (VIRTUAL_SHARE_BUFFER *) SList[i].DestShare;

            if ((VShare != NULL) && VShare->UseCount)
               VShare->UseCount--;
         }

   }

} // ShareListDelete


/*+-------------------------------------------------------------------------+
  | SourceShareListFixup()
  |
  +-------------------------------------------------------------------------+*/
void SourceShareListFixup(DEST_SERVER_BUFFER *DServ, SHARE_LIST *ShareList) {
   TCHAR tmpName[MAX_SHARE_NAME_LEN + 1];
   SHARE_BUFFER *SList;
   ULONG i;
   DWORD *VMap = NULL;

   if (ShareList == NULL)
      return;

   ShareList->Fixup = FALSE;
   // Generate Virtual Share Map
   VShareListIndexMapGet(DServ, &VMap);

   SList = ShareList->SList;
   for (i = 0; i < ShareList->Count; i++) {
      if (SList[i].DestShare != NULL)
         if (SList[i].Virtual)
            SList[i].DestShare = (SHARE_BUFFER *) VMap[(DWORD) SList[i].DestShare - 1];
         else {
            // Not a virtual share - now need to take name from path and rematch it
            // to the new destination share list (dest sharename was stored in 
            // path in the ShareListSave routine).
            lstrcpy(tmpName, SList[i].Name);
            lstrcpy(SList[i].Name, SList[i].Path);

            // clear out path and the old DestShare
            memset(SList[i].Path, 0, sizeof(SList[i].Path));
            SList[i].DestShare = NULL;

            // Now map it to a dest share
            MapShare(&SList[i], DServ);

            // Restore real name
            lstrcpy(SList[i].Name, tmpName);
         }
   }

   if (VMap != NULL)
      FreeMemory(VMap);

} // SourceShareListFixup


/*+-------------------------------------------------------------------------+
  | DestShareListFixup()
  |
  +-------------------------------------------------------------------------+*/
void DestShareListFixup(DEST_SERVER_BUFFER *DServ) {
   SHARE_BUFFER *SList, *oSList;
   SHARE_LIST *oShareList;
   ULONG i, oi;
   DRIVE_LIST *DList;
   DRIVE_BUFFER *DBuff;
   BOOL match;

   if (DServ->ShareList == NULL)
      return;

   if (DServ->ShareList->Fixup == FALSE)
      return; // do not fixup twice...

   DServ->ShareList->Fixup = FALSE;
   DList = DServ->DriveList;
   DBuff = DList->DList;

   oShareList = DServ->ShareList;
   NTSharesEnum(&DServ->ShareList, DServ->DriveList);
   if (DServ->ShareList == NULL)
      return;

   SList = DServ->ShareList->SList;
   oSList = oShareList->SList;
   for (i = 0; i < DServ->ShareList->Count; i++) {
      match = FALSE;
      oi = 0;

      while ((!match) && (oi < oShareList->Count)) {
         if (!lstrcmpi(SList[i].Name, oSList[oi].Name)) {
            SList[i].Convert = oSList[oi].Convert;
            SList[i].HiddenFiles = oSList[oi].HiddenFiles;
            SList[i].SystemFiles = oSList[oi].SystemFiles;
            match = TRUE;
         }
         
         oi++;
      }

   }

   FreeMemory(oShareList);

} // DestShareListFixup


/*+-------------------------------------------------------------------------+
  | ShareListSave()
  |
  +-------------------------------------------------------------------------+*/
void ShareListSave(HANDLE hFile, SHARE_LIST *ShareList) {
   SHARE_BUFFER *SList;
   VIRTUAL_SHARE_BUFFER *VShare;
   DWORD wrote;
   ULONG Size, i;
   DWORD *sb = NULL;

   if (ShareList == NULL)
      return;

   Size = sizeof(SHARE_LIST) + (ShareList->Count * sizeof(SHARE_BUFFER));
   WriteFile(hFile, &Size, sizeof(Size), &wrote, NULL);

   // Need to make a temp array to hold DestShare info
   sb = AllocMemory(ShareList->Count * sizeof(DWORD));

   SList = ShareList->SList;

   // Copy DestShares to temp holding place and replace them with 
   // their index
   for (i = 0; i < ShareList->Count; i++) {
      sb[i] = (DWORD) SList[i].DestShare;

      if (SList[i].DestShare != NULL)
         if (SList[i].Virtual) {
            VShare = (VIRTUAL_SHARE_BUFFER *) SList[i].DestShare;
            SList[i].DestShare = (SHARE_BUFFER *) (VShare->Index + 1);
         } else  {
            // put the dest sharename into the path (temporarily) so that on load
            // we have the name to match to the new share list.  Can't match just
            // the sharename to dest-sharename as the admin may have pointed it to
            // a new one.
            lstrcpy(SList[i].Path, SList[i].DestShare->Name);
            SList[i].DestShare = (SHARE_BUFFER *) (SList[i].DestShare->Index + 1);
         }
   }

   ShareList->Fixup = TRUE;
   WriteFile(hFile, ShareList, Size, &wrote, NULL);
   ShareList->Fixup = FALSE;

   // Restore DestShare pointers
   for (i = 0; i < ShareList->Count; i++)
      SList[i].DestShare = (SHARE_BUFFER *) sb[i];


   if (sb != NULL)
      FreeMemory(sb);

   // Share list array is saved out - now save out linked information
   for (i = 0; i < ShareList->Count; i++)
      if (SList[i].Root != NULL)
         TreeSave(hFile, SList[i].Root);

} // ShareListSave


/*+-------------------------------------------------------------------------+
  | ShareListLoad()
  |
  +-------------------------------------------------------------------------+*/
void ShareListLoad(HANDLE hFile, SHARE_LIST **lpShareList) {
   SHARE_BUFFER *SList;
   SHARE_LIST *ShareList;
   ULONG Size, i;
   DWORD wrote;

   // Get how long this record is
   ReadFile(hFile, &Size, sizeof(Size), &wrote, NULL);

   ShareList = AllocMemory(Size);
   if (ShareList == NULL)
      return;

   ReadFile(hFile, ShareList, Size, &wrote, NULL);

   // Share list array is read in - now load linked information
   SList = ShareList->SList;
   for (i = 0; i < ShareList->Count; i++)
      if (SList[i].Root != NULL) {
         SList[i].Root = NULL;
         TreeLoad(hFile, &SList[i].Root);
      }

   *lpShareList = ShareList;

#ifdef DEBUG
dprintf(TEXT("<Share List Load>\n"));
dprintf(TEXT("   Number of Entries: %lu\n\n"), ShareList->Count);

for (i = 0; i < ShareList->Count; i++) {
   dprintf(TEXT("   Name: %s\n"), SList[i].Name);
   dprintf(TEXT("   Path: %s\n"), SList[i].Path);
}
dprintf(TEXT("\n"));
#endif

} // ShareListLoad


/*+-------------------------------------------------------------------------+
  | ShareListLog()
  |
  +-------------------------------------------------------------------------+*/
void ShareListLog(SHARE_LIST *ShareList, BOOL DestServer) {
   ULONG i;

   if ((ShareList == NULL) || (ShareList->Count == 0))
      return;

   LogWriteLog(0, Lids(IDS_CRLF));
   LogWriteLog(1, Lids(IDS_L_125));

   for (i = 0; i < ShareList->Count; i++) {
      LogWriteLog(2, TEXT("%s\r\n"), ShareList->SList[i].Name);

      if (DestServer)
         LogWriteLog(3, Lids(IDS_L_8), ShareList->SList[i].Path);
   }

   LogWriteLog(0, Lids(IDS_CRLF));

} // ShareListLog


/*+-------------------------------------------------------------------------+
  |                  Routines for Source Server List                        |
  +-------------------------------------------------------------------------+*/

/*+-------------------------------------------------------------------------+
  | SServListAdd()
  |
  +-------------------------------------------------------------------------+*/
SOURCE_SERVER_BUFFER *SServListAdd(LPTSTR ServerName) {
   SOURCE_SERVER_BUFFER *tmpPtr;
   ULONG Size;

   Size = sizeof(SOURCE_SERVER_BUFFER) + ((lstrlen(ServerName) + 3) * sizeof(TCHAR));
   tmpPtr = AllocMemory(Size);
   
   if (tmpPtr != NULL) {
      // init it to NULL's
      memset(tmpPtr, 0, Size);
      tmpPtr->Name = (LPTSTR) ((BYTE *) tmpPtr + sizeof(SOURCE_SERVER_BUFFER));
      tmpPtr->LName = tmpPtr->Name;
      lstrcpy(tmpPtr->Name, TEXT("\\\\"));
      tmpPtr->Name += 2;
      lstrcpy(tmpPtr->Name, ServerName);

      // link it into the list
      if (!SServListStart)
         SServListStart = SServListEnd = tmpPtr;
      else {
         SServListEnd->next = tmpPtr;
         tmpPtr->prev = SServListEnd;
         SServListEnd = tmpPtr;
      }

      NumSServs++;
   }

   return (tmpPtr);

} // SServListAdd


/*+-------------------------------------------------------------------------+
  | SServListDelete()
  |
  +-------------------------------------------------------------------------+*/
void SServListDelete(SOURCE_SERVER_BUFFER *tmpPtr) {
   SOURCE_SERVER_BUFFER *PrevPtr;
   SOURCE_SERVER_BUFFER *NextPtr;

   if (tmpPtr == NULL)
      return;

   // Delete any attached share list first
   ShareListDelete(tmpPtr->ShareList);

   // Free any admin share we made
   NWUseDel(tmpPtr->Name);

   // Now unlink the actual server record
   PrevPtr = tmpPtr->prev;
   NextPtr = tmpPtr->next;

   if (PrevPtr)
      PrevPtr->next = NextPtr;

   if (NextPtr)
      NextPtr->prev = PrevPtr;

   // Check if at end of list
   if (SServListEnd == tmpPtr)
      SServListEnd = PrevPtr;

   // Check if at start of list
   if (SServListStart == tmpPtr)
      SServListStart = NextPtr;

   FreeMemory(tmpPtr);
   NumSServs--;

   if (!NumSServs)
      SServListStart = SServListEnd = NULL;

}  // SServListDelete


/*+-------------------------------------------------------------------------+
  | SServListDeleteAll()
  |
  +-------------------------------------------------------------------------+*/
void SServListDeleteAll() {
   SOURCE_SERVER_BUFFER *ServList;
   SOURCE_SERVER_BUFFER *ServListNext;

   // Now remove the entries from the internal list
   ServList = SServListStart;

   while (ServList) {
      ServListNext = ServList->next;
      SServListDelete(ServList);
      ServList = ServListNext;
   }

} // SServListDeleteAll


/*+-------------------------------------------------------------------------+
  | SServListFind()
  |
  +-------------------------------------------------------------------------+*/
SOURCE_SERVER_BUFFER *SServListFind(LPTSTR ServerName) {
   BOOL Found = FALSE;
   SOURCE_SERVER_BUFFER *ServList;

   ServList = SServListStart;

   while ((ServList && !Found)) {
      if (!lstrcmpi(ServList->Name, ServerName))
         Found = TRUE;
      else
         ServList = ServList->next;
   }

   if (!Found)
      ServList = NULL;

   return (ServList);

} // SServListFind


/*+-------------------------------------------------------------------------+
  | SServListIndex()
  |
  |   The index routines place an index number into each item of the list,
  |   and is called just before saving out the list.  This is so when we
  |   read them in we can reference pointer links.  In their normal state
  |   these data structures are cross referenced via pointers, but once
  |   saved/restored the pointers have no meaning, so we use the index to
  |   re-reference the pointers to the correct data items when they are
  |   read back in.
  |
  +-------------------------------------------------------------------------+*/
void SServListIndex() {
   SOURCE_SERVER_BUFFER *ServList;
   USHORT Count = 0;

   ServList = SServListStart;
   while (ServList) {
      ServList->Index = Count++;
      ServList = ServList->next;
   }

} // SServListIndex


/*+-------------------------------------------------------------------------+
  | SServListIndexMapGet()
  |
  +-------------------------------------------------------------------------+*/
void SServListIndexMapGet(DWORD **pMap) {
   DWORD *Map = NULL;
   SOURCE_SERVER_BUFFER *ServList;

   Map = AllocMemory(NumSServs * sizeof(DWORD));

   *pMap = Map;
   if (Map == NULL)
      return;

   ServList = SServListStart;
   while (ServList) {
      Map[ServList->Index] = (DWORD) ServList;
      ServList = ServList->next;
   }

} // SServListIndexMapGet


/*+-------------------------------------------------------------------------+
  | SServListFixup()
  |
  +-------------------------------------------------------------------------+*/
void SServListFixup() {

   // There is nothing to fixup in the source server list right now - the
   // share list is done later...

} // SServListFixup


/*+-------------------------------------------------------------------------+
  | SServListSave()
  |
  +-------------------------------------------------------------------------+*/
void SServListSave(HANDLE hFile) {
   DWORD wrote;
   ULONG Size;
   SOURCE_SERVER_BUFFER *ServList;

   ServList = SServListStart;

   while (ServList) {
      Size = (lstrlen(ServList->Name) + 3) * sizeof(TCHAR);
      Size += sizeof(SOURCE_SERVER_BUFFER);
      WriteFile(hFile, &Size, sizeof(Size), &wrote, NULL);
      WriteFile(hFile, ServList, Size, &wrote, NULL);

      // Now save out linked information
      ShareListSave(hFile, ServList->ShareList);

      ServList = ServList->next;
   }

} // SServListSave


/*+-------------------------------------------------------------------------+
  | SServListLoad()
  |
  +-------------------------------------------------------------------------+*/
void SServListLoad(HANDLE hFile) {
   BOOL Continue = TRUE;
   ULONG Size;
   SOURCE_SERVER_BUFFER *tmpPtr;
   DWORD wrote;

   while (Continue) {
      // Get how long this record is
      ReadFile(hFile, &Size, sizeof(Size), &wrote, NULL);

      tmpPtr = AllocMemory(Size);
      if (tmpPtr == NULL)
         return;

      // Read in the record
      ReadFile(hFile, tmpPtr, Size, &wrote, NULL);

      // See if there are more records
      if (tmpPtr->next == NULL)
         Continue = FALSE;

      // clear out the old links - and fixup new ones
      tmpPtr->next = NULL;
      tmpPtr->prev = NULL;

      tmpPtr->LName = (LPTSTR) ((BYTE *) tmpPtr + sizeof(SOURCE_SERVER_BUFFER));
      tmpPtr->Name  = tmpPtr->LName + 2;

      // link it into the list
      if (!SServListStart)
         SServListStart = SServListEnd = tmpPtr;
      else {
         SServListEnd->next = tmpPtr;
         tmpPtr->prev = SServListEnd;
         SServListEnd = tmpPtr;
      }

#ifdef DEBUG
dprintf(TEXT("<Source Server Load>\n"));
dprintf(TEXT("   Name: %s\n"), tmpPtr->Name);
dprintf(TEXT("   Version: %u.%u\n\n"), (UINT) tmpPtr->VerMaj, (UINT) tmpPtr->VerMin);
#endif

      // Now load in linked information
      if (tmpPtr->ShareList != NULL) {
         tmpPtr->ShareList = NULL;
         ShareListLoad(hFile, &tmpPtr->ShareList);
      }

      NumSServs++;
   }

} // SServListLoad



/*+-------------------------------------------------------------------------+
  |                 Routines for Destination Server List                    |
  +-------------------------------------------------------------------------+*/

/*+-------------------------------------------------------------------------+
  | DServListAdd()
  |
  +-------------------------------------------------------------------------+*/
DEST_SERVER_BUFFER *DServListAdd(LPTSTR ServerName) {
   DEST_SERVER_BUFFER *tmpPtr;
   ULONG Size, strlen1;

   strlen1 = (lstrlen(ServerName) + 3) * sizeof(TCHAR);
   Size = sizeof(DEST_SERVER_BUFFER) + strlen1;
   tmpPtr = AllocMemory(Size);
   
   if (tmpPtr != NULL) {
      // init it to NULL's
      memset(tmpPtr, 0, Size);
      tmpPtr->Name = (LPTSTR) ((BYTE *) tmpPtr + sizeof(DEST_SERVER_BUFFER));
      tmpPtr->LName = tmpPtr->Name;
      lstrcpy(tmpPtr->Name, TEXT("\\\\"));
      tmpPtr->Name += 2;
      lstrcpy(tmpPtr->Name, ServerName);

      // link it into the list
      if (!DServListStart)
         DServListStart = DServListEnd = tmpPtr;
      else {
         DServListEnd->next = tmpPtr;
         tmpPtr->prev = DServListEnd;
         DServListEnd = tmpPtr;
      }

      NumDServs++;
   }

   return (tmpPtr);

} // DServListAdd


/*+-------------------------------------------------------------------------+
  | DServListDelete()
  |
  +-------------------------------------------------------------------------+*/
void DServListDelete(DEST_SERVER_BUFFER *tmpPtr) {
   DEST_SERVER_BUFFER *PrevPtr;
   DEST_SERVER_BUFFER *NextPtr;

   if (tmpPtr == NULL)
      return;

   if (tmpPtr->UseCount) {
      // Decrement use count, only delete if actually gone.
      tmpPtr->UseCount--;
      if (tmpPtr->UseCount)
         return;
   }

   // Delete any attached share list first
   ShareListDelete(tmpPtr->ShareList);

   // ...and virtual share list
   VShareListDeleteAll(tmpPtr);

   // ...and any drive list
   if (tmpPtr->DriveList)
      FreeMemory(tmpPtr->DriveList);

   // ... domain as well
   DomainListDelete(tmpPtr->Domain);

   // -- don't free for user convenience, we will clean up at end, otherwise
   // user must enter in password if delete/add
   // Free any admin share we made
   // NTUseDel(tmpPtr->Name);

   // Now unlink the actual server record
   PrevPtr = tmpPtr->prev;
   NextPtr = tmpPtr->next;

   if (PrevPtr)
      PrevPtr->next = NextPtr;

   if (NextPtr)
      NextPtr->prev = PrevPtr;

   // Check if at end of list
   if (DServListEnd == tmpPtr)
      DServListEnd = PrevPtr;

   // Check if at start of list
   if (DServListStart == tmpPtr)
      DServListStart = NextPtr;

   FreeMemory(tmpPtr);
   NumDServs--;

   if (!NumDServs)
      DServListStart = DServListEnd = NULL;

}  // DServListDelete


/*+-------------------------------------------------------------------------+
  | DServListDeleteAll()
  |
  +-------------------------------------------------------------------------+*/
void DServListDeleteAll() {
   DEST_SERVER_BUFFER *ServList;
   DEST_SERVER_BUFFER *ServListNext;

   // Now remove the entries from the internal list
   ServList = DServListStart;

   while (ServList) {
      ServListNext = ServList->next;
      ServList->UseCount = 0;
      DServListDelete(ServList);
      ServList = ServListNext;
   }

} // DServListDeleteAll


/*+-------------------------------------------------------------------------+
  | DServListFind()
  |
  +-------------------------------------------------------------------------+*/
DEST_SERVER_BUFFER *DServListFind(LPTSTR ServerName) {
   BOOL Found = FALSE;
   DEST_SERVER_BUFFER *ServList;

   ServList = DServListStart;

   while ((ServList && !Found)) {
      if (!lstrcmpi(ServList->Name, ServerName))
         Found = TRUE;
      else
         ServList = ServList->next;
   }

   if (!Found)
      ServList = NULL;

   return (ServList);

} // DServListFind


/*+-------------------------------------------------------------------------+
  | DServListIndex()
  |
  +-------------------------------------------------------------------------+*/
void DServListIndex() {
   DEST_SERVER_BUFFER *ServList;
   USHORT Count = 0;

   ServList = DServListStart;
   while (ServList) {
      ServList->Index = Count++;

      // Now index the virtual shares for this server
      VShareListIndex(ServList);
      ServList = ServList->next;
   }

} // DServListIndex


/*+-------------------------------------------------------------------------+
  | DServListIndexMapGet()
  |
  +-------------------------------------------------------------------------+*/
void DServListIndexMapGet(DWORD **pMap) {
   DWORD *Map = NULL;
   DEST_SERVER_BUFFER *ServList;

   Map = AllocMemory(NumDServs * sizeof(DWORD));

   *pMap = Map;
   if (Map == NULL)
      return;

   ServList = DServListStart;
   while (ServList) {
      Map[ServList->Index] = (DWORD) ServList;
      ServList = ServList->next;
   }

} // DServListIndexMapGet


/*+-------------------------------------------------------------------------+
  | DServListFixup()
  |
  +-------------------------------------------------------------------------+*/
void DServListFixup() {
   DEST_SERVER_BUFFER *ServList;
   DWORD *DMap = NULL;

   DomainListIndexMapGet(&DMap);

   if (DMap == NULL)
      return;

   // Just need to fixup the domain list pointers
   ServList = DServListStart;
   while (ServList) {

      if (ServList->Domain != NULL)
         ServList->Domain = (DOMAIN_BUFFER *) DMap[(DWORD) ServList->Domain - 1];

      ServList = ServList->next;
   }

   FreeMemory(DMap);

} // DServListFixup


/*+-------------------------------------------------------------------------+
  | DServListSave()
  |
  +-------------------------------------------------------------------------+*/
void DServListSave(HANDLE hFile) {
   DWORD wrote;
   ULONG Size;
   DEST_SERVER_BUFFER *ServList;
   DOMAIN_BUFFER *db;

   ServList = DServListStart;

   while (ServList) {
      Size = (lstrlen(ServList->Name) + 3) * sizeof(TCHAR);
      Size += sizeof(DEST_SERVER_BUFFER);
      WriteFile(hFile, &Size, sizeof(Size), &wrote, NULL);

      // Need to de-reference the domain pointers to their index, and after 
      // saving restore them.
      db = ServList->Domain;
      if (ServList->Domain != NULL)
         ServList->Domain = (DOMAIN_BUFFER *) (ServList->Domain->Index + 1);

      WriteFile(hFile, ServList, Size, &wrote, NULL);
      ServList->Domain = db;

      // Now save out linked information
      ShareListSave(hFile, ServList->ShareList);
      VShareListSave(hFile, ServList);

      ServList = ServList->next;
   }

} // DServListSave


/*+-------------------------------------------------------------------------+
  | DServListLoad()
  |
  +-------------------------------------------------------------------------+*/
void DServListLoad(HANDLE hFile) {
   BOOL Continue = TRUE;
   ULONG Size;
   DEST_SERVER_BUFFER *tmpPtr;
   DWORD wrote;

   while (Continue) {
      // Get how long this record is
      ReadFile(hFile, &Size, sizeof(Size), &wrote, NULL);

      tmpPtr = AllocMemory(Size);
      if (tmpPtr == NULL)
         return;

      // Read in the record
      ReadFile(hFile, tmpPtr, Size, &wrote, NULL);

      // See if there are more records
      if (tmpPtr->next == NULL)
         Continue = FALSE;

      // clear out the old links - and fixup new ones
      tmpPtr->next = NULL;
      tmpPtr->prev = NULL;

      tmpPtr->LName = (LPTSTR) ((BYTE *) tmpPtr + sizeof(DEST_SERVER_BUFFER));
      tmpPtr->Name  = tmpPtr->LName + 2;

      // link it into the list
      if (!DServListStart)
         DServListStart = DServListEnd = tmpPtr;
      else {
         DServListEnd->next = tmpPtr;
         tmpPtr->prev = DServListEnd;
         DServListEnd = tmpPtr;
      }

      // The drive list is no longer valid - so clear it out.
      tmpPtr->DriveList = NULL;

#ifdef DEBUG
dprintf(TEXT("<Dest Server Load>\n"));
dprintf(TEXT("   Name: %s\n"), tmpPtr->Name);
dprintf(TEXT("   Version: %u.%u\n\n"), (UINT) tmpPtr->VerMaj, (UINT) tmpPtr->VerMin);
#endif

      // Now load in linked information
      if (tmpPtr->ShareList != NULL) {
         tmpPtr->ShareList = NULL;
         ShareListLoad(hFile, &tmpPtr->ShareList);
      }

      if (tmpPtr->VShareStart != NULL) {
         tmpPtr->NumVShares = 0;
         tmpPtr->VShareStart = tmpPtr->VShareEnd = NULL;
         VShareListLoad(hFile, tmpPtr);
      }

      NumDServs++;
   }

} // DServListLoad


/*+-------------------------------------------------------------------------+
  | DServListSpaceFree()
  |
  +-------------------------------------------------------------------------+*/
void DServListSpaceFree() {
   DEST_SERVER_BUFFER *ServList;
   DRIVE_BUFFER *Drive;
   DRIVE_LIST *DList;
   ULONG i;

   ServList = DServListStart;
   while (ServList) {
      DList = ServList->DriveList;

      if (DList != NULL) {
         Drive = DList->DList;
         for (i = 0; i < DList->Count; i++)
            Drive[i].AllocSpace = 0;
      }

      ServList = ServList->next;
   }

} // DServListSpaceFree



/*+-------------------------------------------------------------------------+
  |                   Routines for Virtual Share Lists                      |
  +-------------------------------------------------------------------------+*/

/*+-------------------------------------------------------------------------+
  | VShareListAdd()
  |
  +-------------------------------------------------------------------------+*/
VIRTUAL_SHARE_BUFFER *VShareListAdd(DEST_SERVER_BUFFER *DServ, LPTSTR ShareName, LPTSTR Path) {
   VIRTUAL_SHARE_BUFFER *tmpPtr;
   ULONG Size, strlen1;

   // base struct + both strings and 2 ending NULL's
   strlen1 = ((lstrlen(ShareName)+ 1) * sizeof(TCHAR));
   Size = sizeof(VIRTUAL_SHARE_BUFFER) + strlen1;
   tmpPtr = AllocMemory(Size);
   
   if (tmpPtr != NULL) {
      // init it to NULL's
      memset(tmpPtr, 0, Size);
      tmpPtr->VFlag = TRUE;
      tmpPtr->Name = (LPTSTR) ((BYTE *) tmpPtr + sizeof(VIRTUAL_SHARE_BUFFER));
      lstrcpy(tmpPtr->Name, ShareName);
      lstrcpy(tmpPtr->Path, Path);

      // link it into the list
      if (!DServ->VShareStart)
         DServ->VShareStart = DServ->VShareEnd = tmpPtr;
      else {
         DServ->VShareEnd->next = tmpPtr;
         tmpPtr->prev = DServ->VShareEnd;
         DServ->VShareEnd = tmpPtr;
      }

      DServ->NumVShares++;
   }

   return (tmpPtr);

} // VShareListAdd


/*+-------------------------------------------------------------------------+
  | VShareListDelete()
  |
  +-------------------------------------------------------------------------+*/
void VShareListDelete(DEST_SERVER_BUFFER *DServ, VIRTUAL_SHARE_BUFFER *tmpPtr) {
   VIRTUAL_SHARE_BUFFER *PrevPtr;
   VIRTUAL_SHARE_BUFFER *NextPtr;

   if (tmpPtr == NULL)
      return;

   if (tmpPtr->UseCount) {
      // Decrement use count, only delete if actually gone.
      tmpPtr->UseCount--;
      if (tmpPtr->UseCount > 0)
         return;
   }

   PrevPtr = tmpPtr->prev;
   NextPtr = tmpPtr->next;

   if (PrevPtr)
      PrevPtr->next = NextPtr;

   if (NextPtr)
      NextPtr->prev = PrevPtr;

   // Check if at end of list
   if (DServ->VShareEnd == tmpPtr)
      DServ->VShareEnd = PrevPtr;

   // Check if at start of list
   if (DServ->VShareStart == tmpPtr)
      DServ->VShareStart = NextPtr;

   FreeMemory(tmpPtr);
   DServ->NumVShares--;

   if (!DServ->NumVShares)
      DServ->VShareStart = DServ->VShareEnd = NULL;

}  // VShareListDelete


/*+-------------------------------------------------------------------------+
  | VShareListDeleteAll()
  |
  +-------------------------------------------------------------------------+*/
void VShareListDeleteAll(DEST_SERVER_BUFFER *DServ) {
   VIRTUAL_SHARE_BUFFER *ShareList;
   VIRTUAL_SHARE_BUFFER *ShareListNext;

   // Now remove the entries from the internal list
   ShareList = DServ->VShareStart;

   while (ShareList) {
      ShareListNext = ShareList->next;

      // Flag to zero to make sure destroyed
      ShareList->UseCount = 0;
      VShareListDelete(DServ, ShareList);
      ShareList = ShareListNext;
   }

} // VShareListDeleteAll


/*+-------------------------------------------------------------------------+
  | VShareListIndex()
  |
  +-------------------------------------------------------------------------+*/
void VShareListIndex(DEST_SERVER_BUFFER *DServ) {
   VIRTUAL_SHARE_BUFFER *ShareList;
   USHORT Count = 0;

   ShareList = DServ->VShareStart;
   while (ShareList) {
      ShareList->Index = Count++;
      ShareList = ShareList->next;
   }

} // VShareListIndex


/*+-------------------------------------------------------------------------+
  | VShareListIndexMapGet()
  |
  +-------------------------------------------------------------------------+*/
void VShareListIndexMapGet(DEST_SERVER_BUFFER *DServ, DWORD **pMap) {
   DWORD *Map = NULL;
   VIRTUAL_SHARE_BUFFER *ShareList;

   Map = AllocMemory( DServ->NumVShares * sizeof(DWORD) );

   *pMap = Map;
   if (Map == NULL)
      return;

   ShareList = DServ->VShareStart;
   while (ShareList) {
      Map[ShareList->Index] = (DWORD) ShareList;
      ShareList = ShareList->next;
   }

} // VShareListIndexMapGet


/*+-------------------------------------------------------------------------+
  | VShareListSave()
  |
  +-------------------------------------------------------------------------+*/
void VShareListSave(HANDLE hFile, DEST_SERVER_BUFFER *DServ) {
   DWORD wrote;
   ULONG Size;
   VIRTUAL_SHARE_BUFFER *ShareList;

   ShareList = DServ->VShareStart;

   while (ShareList) {
      Size = (lstrlen(ShareList->Name) + 1) * sizeof(TCHAR);
      Size += sizeof(VIRTUAL_SHARE_BUFFER);
      WriteFile(hFile, &Size, sizeof(Size), &wrote, NULL);
      WriteFile(hFile, ShareList, Size, &wrote, NULL);
      ShareList = ShareList->next;
   }

} // VShareListSave


/*+-------------------------------------------------------------------------+
  | VShareListLoad()
  |
  +-------------------------------------------------------------------------+*/
void VShareListLoad(HANDLE hFile, DEST_SERVER_BUFFER *DServ) {
   BOOL Continue = TRUE;
   ULONG Size;
   VIRTUAL_SHARE_BUFFER *tmpPtr;
   DWORD wrote;

   while (Continue) {
      // Get how long this record is
      ReadFile(hFile, &Size, sizeof(Size), &wrote, NULL);

      tmpPtr = AllocMemory(Size);
      if (tmpPtr == NULL)
         return;

      // Read in the record
      ReadFile(hFile, tmpPtr, Size, &wrote, NULL);

      // See if there are more records
      if (tmpPtr->next == NULL)
         Continue = FALSE;

      // clear out the old links - and fixup new ones
      tmpPtr->next = NULL;
      tmpPtr->prev = NULL;
      tmpPtr->Name = (LPTSTR) ((BYTE *) tmpPtr + sizeof(VIRTUAL_SHARE_BUFFER));
      tmpPtr->Drive = NULL;

      // link it into the list
      if (!DServ->VShareStart)
         DServ->VShareStart = DServ->VShareEnd = tmpPtr;
      else {
         DServ->VShareEnd->next = tmpPtr;
         tmpPtr->prev = DServ->VShareEnd;
         DServ->VShareEnd = tmpPtr;
      }

      DServ->NumVShares++;
   }

} // VShareListLoad


/*+-------------------------------------------------------------------------+
  | VShareListFixup()
  |
  +-------------------------------------------------------------------------+*/
void VShareListFixup(DEST_SERVER_BUFFER *DServ) {
   VIRTUAL_SHARE_BUFFER *VShare;
   USHORT Count = 0;
   DWORD di;
   DRIVE_LIST *Drives;
   DRIVE_BUFFER *DList;
   ULONG TotalDrives;
   TCHAR Drive[2];

   if (DServ->DriveList == NULL)
      return;

   TotalDrives = 0;
   Drives = DServ->DriveList;
   Drive[1] = TEXT('\0');
   DList = Drives->DList;
   TotalDrives = Drives->Count;

   VShare = DServ->VShareStart;
   while (VShare) {
      VShare->Drive = NULL;

      // Scan drive list looking for match to share path
      for (di = 0; di < TotalDrives; di++) {
         // Get first char from path - should be drive letter
         Drive[0] = *VShare->Path;
         if (!lstrcmpi(Drive, DList[di].Drive))
            VShare->Drive = &DList[di];
      }

      VShare = VShare->next;
   }

} // VShareListFixup



/*+-------------------------------------------------------------------------+
  |                       Routines for Domain Lists                         |
  +-------------------------------------------------------------------------+*/

/*+-------------------------------------------------------------------------+
  | DomainListAdd()
  |
  +-------------------------------------------------------------------------+*/
DOMAIN_BUFFER *DomainListAdd(LPTSTR DomainName, LPTSTR PDCName) {
   DOMAIN_BUFFER *tmpPtr;
   ULONG Size, strlen1, strlen2;

   // base struct + both strings and 2 ending NULL's
   strlen1 = ((lstrlen(DomainName) + 1) * sizeof(TCHAR));
   strlen2 = ((lstrlen(PDCName) + 1) * sizeof(TCHAR));
   Size = sizeof(DOMAIN_BUFFER) + strlen1 + strlen2;
   tmpPtr = AllocMemory(Size);
   
   if (tmpPtr != NULL) {
      // init it to NULL's
      memset(tmpPtr, 0, Size);
      tmpPtr->Name = (LPTSTR) ((BYTE *) tmpPtr + sizeof(DOMAIN_BUFFER));
      tmpPtr->PDCName = (LPTSTR) ((BYTE *) tmpPtr + sizeof(DOMAIN_BUFFER) + strlen1);
      lstrcpy(tmpPtr->Name, DomainName);
      lstrcpy(tmpPtr->PDCName, PDCName);

      // link it into the list
      if (!DomainListStart)
         DomainListStart = DomainListEnd = tmpPtr;
      else {
         DomainListEnd->next = tmpPtr;
         tmpPtr->prev = DomainListEnd;
         DomainListEnd = tmpPtr;
      }

      NumDomains++;
   }

   return (tmpPtr);

} // DomainListAdd


/*+-------------------------------------------------------------------------+
  | DomainListDelete()
  |
  +-------------------------------------------------------------------------+*/
void DomainListDelete(DOMAIN_BUFFER *tmpPtr) {
   DOMAIN_BUFFER *PrevPtr;
   DOMAIN_BUFFER *NextPtr;

   if (tmpPtr == NULL)
      return;

   if (tmpPtr->UseCount) {
      // Decrement use count, only delete if actually gone.
      tmpPtr->UseCount--;
      if (tmpPtr->UseCount)
         return;
   }

   PrevPtr = tmpPtr->prev;
   NextPtr = tmpPtr->next;

   if (PrevPtr)
      PrevPtr->next = NextPtr;

   if (NextPtr)
      NextPtr->prev = PrevPtr;

   // Check if at end of list
   if (DomainListEnd == tmpPtr)
      DomainListEnd = PrevPtr;

   // Check if at start of list
   if (DomainListStart == tmpPtr)
      DomainListStart = NextPtr;

   FreeMemory(tmpPtr);
   NumDomains--;

   if (!NumDomains)
      DomainListStart = DomainListEnd = NULL;

}  // DomainListDelete


/*+-------------------------------------------------------------------------+
  | DomainListDeleteAll()
  |
  +-------------------------------------------------------------------------+*/
void DomainListDeleteAll() {
   DOMAIN_BUFFER *DomList;
   DOMAIN_BUFFER *DomListNext;

   // Now remove the entries from the internal list
   DomList = DomainListStart;

   while (DomList) {
      DomListNext = DomList->next;
      DomList->UseCount = 0;
      DomainListDelete(DomList);
      DomList = DomListNext;
   }

} // DomainListDeleteAll


/*+-------------------------------------------------------------------------+
  | DomainListFind()
  |
  +-------------------------------------------------------------------------+*/
DOMAIN_BUFFER *DomainListFind(LPTSTR DomainName) {
   BOOL Found = FALSE;
   DOMAIN_BUFFER *DomainList;

   DomainList = DomainListStart;

   while ((DomainList && !Found)) {
      if (!lstrcmpi(DomainList->Name, DomainName))
         Found = TRUE;
      else
         DomainList = DomainList->next;
   }

   if (!Found)
      DomainList = NULL;

   return (DomainList);

} // DomainListFind


/*+-------------------------------------------------------------------------+
  | DomainListIndex()
  |
  +-------------------------------------------------------------------------+*/
void DomainListIndex() {
   DOMAIN_BUFFER *DomList;
   USHORT Count = 0;

   DomList = DomainListStart;
   while (DomList) {
      DomList->Index = Count++;
      DomList = DomList->next;
   }

} // DomainListIndex


/*+-------------------------------------------------------------------------+
  | DomainListIndexMapGet()
  |
  +-------------------------------------------------------------------------+*/
void DomainListIndexMapGet(DWORD **pMap) {
   DWORD *Map = NULL;
   DOMAIN_BUFFER *DomList;

   Map = AllocMemory(NumDomains * sizeof(DWORD));

   *pMap = Map;
   if (Map == NULL)
      return;

   DomList = DomainListStart;
   while (DomList) {
      Map[DomList->Index] = (DWORD) DomList;
      DomList = DomList->next;
   }

} // DomainListIndexMapGet


/*+-------------------------------------------------------------------------+
  | DomainListSave()
  |
  +-------------------------------------------------------------------------+*/
void DomainListSave(HANDLE hFile) {
   DWORD wrote;
   ULONG Size;
   DOMAIN_BUFFER *DomList;

   WriteFile(hFile, &NumDomains, sizeof(NumDomains), &wrote, NULL);

   DomList = DomainListStart;
   while (DomList) {
      Size = (lstrlen(DomList->Name) + 1) * sizeof(TCHAR);
      Size += (lstrlen(DomList->PDCName) + 1) * sizeof(TCHAR);
      Size += sizeof(DOMAIN_BUFFER);
      WriteFile(hFile, &Size, sizeof(Size), &wrote, NULL);
      WriteFile(hFile, DomList, Size, &wrote, NULL);
      DomList = DomList->next;
   }

} // DomainListSave


/*+-------------------------------------------------------------------------+
  | DomainListLoad()
  |
  +-------------------------------------------------------------------------+*/
void DomainListLoad(HANDLE hFile) {
   BOOL Continue = TRUE;
   ULONG Size, namelen;
   DOMAIN_BUFFER *tmpPtr;
   DWORD wrote;

   ReadFile(hFile, &NumDomains, sizeof(NumDomains), &wrote, NULL);
   if (NumDomains == 0)
      Continue = FALSE;
      
   NumDomains = 0;
   while (Continue) {
      // Get how long this record is
      ReadFile(hFile, &Size, sizeof(Size), &wrote, NULL);

      tmpPtr = AllocMemory(Size);
      if (tmpPtr == NULL)
         return;

      // Read in the record
      ReadFile(hFile, tmpPtr, Size, &wrote, NULL);

      // See if there are more records
      if (tmpPtr->next == NULL)
         Continue = FALSE;

      // clear out the old links - and fixup new ones
      tmpPtr->next = NULL;
      tmpPtr->prev = NULL;
      tmpPtr->Name = (LPTSTR) ((BYTE *) tmpPtr + sizeof(DOMAIN_BUFFER));
      namelen = ((lstrlen(tmpPtr->Name) + 1) * sizeof(TCHAR));
      tmpPtr->PDCName = (LPTSTR) ((BYTE *) tmpPtr + sizeof(DOMAIN_BUFFER) + namelen);

#ifdef DEBUG
dprintf(TEXT("<Domain List Load>\n"));
dprintf(TEXT("   Name: %s\n"), tmpPtr->Name);
dprintf(TEXT("   PDC Name: %s\n\n"), tmpPtr->PDCName);
#endif

      // link it into the list
      if (!DomainListStart)
         DomainListStart = DomainListEnd = tmpPtr;
      else {
         DomainListEnd->next = tmpPtr;
         tmpPtr->prev = DomainListEnd;
         DomainListEnd = tmpPtr;
      }

      NumDomains++;
   }

} // DomainListLoad



/*+-------------------------------------------------------------------------+
  |                      Routines for Convert Lists                         |
  +-------------------------------------------------------------------------+*/

/*+-------------------------------------------------------------------------+
  | ConvertListAdd()
  |
  |    Allocates and inserts a new record for holding a server pair and
  |    associated conversion options.
  |
  | Comments:
  |    The convert list is a doubly linked list of records.  Each record
  |    contains the source and destination server (server-pair) and a
  |    pointer to the conversion specific information.  The exact info
  |    is specific to the platform being converted from (source server type)
  |
  +-------------------------------------------------------------------------+*/
CONVERT_LIST *ConvertListAdd(SOURCE_SERVER_BUFFER *SourceServer, DEST_SERVER_BUFFER *DestServer) {
   CONVERT_OPTIONS *cvo;
   CONVERT_LIST *tmpPtr;
   CONVERT_LIST *cPtr;
   BOOL match = FALSE;

   tmpPtr = AllocMemory(sizeof(CONVERT_LIST));

   if (tmpPtr != NULL) {
      // zero it out
      memset(tmpPtr, 0, sizeof(CONVERT_LIST));

      tmpPtr->SourceServ = SourceServer;
      tmpPtr->FileServ = DestServer;

      // initialize the conversion options
      UserOptionsInit(&tmpPtr->ConvertOptions);

      // Set NetWareInfo based on current FPNW setting...
      cvo = (CONVERT_OPTIONS *) tmpPtr->ConvertOptions;
      cvo->NetWareInfo = DestServer->IsFPNW;

      FileOptionsInit(&tmpPtr->FileOptions);

      // link it into the list - we want to link right after another
      // convert to this same server, or to the same domain. otherwise
      // tag it onto the end of the list.
      if (!ConvertListStart)
         ConvertListStart = ConvertListEnd = tmpPtr;
      else {
         // Have some files in the list - find out if destination server
         // is already in the list and if so append after it.
         if (DestServer->UseCount > 1) {
            // should be in the list so find it.
            cPtr = ConvertListStart;
            while (cPtr && !match) {
               if (!lstrcmpi(DestServer->Name, cPtr->FileServ->Name))
                  match = TRUE;
               else
                  cPtr = cPtr->next;
            }

            if (match) {
               // have a match - so go to the end of the matching pairs...
               while (cPtr && match) {
                  if (lstrcmpi(DestServer->Name, cPtr->FileServ->Name))
                     match = FALSE;
                  else
                     cPtr = cPtr->next;
               }

               match = !match;
            }
         }

         // if didn't find a server match - look for a domain match
         if (!match) {
            if (DestServer->InDomain && DestServer->Domain) {
               // should be in the list so find it.
               cPtr = ConvertListStart;
               while (cPtr && !match) {
                  if (cPtr->FileServ->InDomain && cPtr->FileServ->Domain)
                     if (!lstrcmpi(DestServer->Domain->Name, cPtr->FileServ->Domain->Name))
                        match = TRUE;

                  if (!match)
                     cPtr = cPtr->next;
               }

               if (match) {
                  // have a match - so go to the end of the matching pairs...
                  while (cPtr && match) {
                     if (cPtr->FileServ->InDomain && cPtr->FileServ->Domain) {
                        if (lstrcmpi(DestServer->Domain->Name, cPtr->FileServ->Domain->Name))
                           match = FALSE;
                     } else
                        match = FALSE;

                     if (match)
                        cPtr = cPtr->next;
                  }

                  match = !match;
               }
            }
         }

         // if match then in middle of buffer, else use end
         if (match && (cPtr != ConvertListEnd)) {
            tmpPtr->prev = cPtr->prev;
            tmpPtr->next = cPtr;
            cPtr->prev->next = tmpPtr;
         } else {
            // only one in list so add at end
            ConvertListEnd->next = tmpPtr;
            tmpPtr->prev = ConvertListEnd;
            ConvertListEnd = tmpPtr;
         }

      }

      NumServerPairs++;
   }

   return (tmpPtr);

} // ConvertListAdd


/*+-------------------------------------------------------------------------+
  | ConvertListDelete()
  |
  |    Removes and deallocates a convert list entry from the conversion
  |    list.
  |
  +-------------------------------------------------------------------------+*/
void ConvertListDelete(CONVERT_LIST *tmpPtr) {
   CONVERT_LIST *PrevPtr;
   CONVERT_LIST *NextPtr;

   // First get rid of the source and destination server this is pointing to -
   // those routines take care of freeing up chained data structures. Also
   // DServList will only be delete if it's UseCount goes to 0.
   SServListDelete(tmpPtr->SourceServ);
   DServListDelete(tmpPtr->FileServ);

   // Now unlink the actual convert list record
   PrevPtr = tmpPtr->prev;
   NextPtr = tmpPtr->next;

   if (PrevPtr)
      PrevPtr->next = NextPtr;

   if (NextPtr)
      NextPtr->prev = PrevPtr;

   // Check if at end of list
   if (ConvertListEnd == tmpPtr)
      ConvertListEnd = PrevPtr;

   // Check if at start of list
   if (ConvertListStart == tmpPtr)
      ConvertListStart = NextPtr;

   FreeMemory(tmpPtr->ConvertOptions);
   FreeMemory(tmpPtr);
   NumServerPairs--;

   if (!NumServerPairs)
      ConvertListStart = ConvertListEnd = NULL;

}  // ConvertListDelete


/*+-------------------------------------------------------------------------+
  | ConvertListDeleteAll()
  |
  |    Removes and deallocates all the convert list entrys and removes them
  |    from the listbox.
  |
  +-------------------------------------------------------------------------+*/
void ConvertListDeleteAll() {
   CONVERT_LIST *ConvList;
   CONVERT_LIST *ConvListNext;

   // Now remove the entries from the internal list
   ConvList = ConvertListStart;

   while (ConvList) {
      ConvListNext = ConvList->next;
      ConvertListDelete(ConvList);
      ConvList = ConvListNext;
   }

} // ConvertListDeleteAll


/*+-------------------------------------------------------------------------+
  | ConvertListSaveAll()
  |
  +-------------------------------------------------------------------------+*/
void ConvertListSaveAll(HANDLE hFile) {
   DWORD wrote;
   SOURCE_SERVER_BUFFER *ss;
   DEST_SERVER_BUFFER *ds;

   // First need to walk source and dest server lists and re-synch the 
   // index numbers as we can't use pointers loading them back in.
   SServListIndex();
   DServListIndex();       // Takes care of the VShares
   DomainListIndex();

   // Done with re-synch of indexes - do actual saving.
   CurrentConvertList = ConvertListStart;
   while (CurrentConvertList) {
      // Need to de-reference the server pointers to their index, and after 
      // saving restore them.
      ss = CurrentConvertList->SourceServ;
      ds = CurrentConvertList->FileServ;
      CurrentConvertList->SourceServ = (SOURCE_SERVER_BUFFER *) CurrentConvertList->SourceServ->Index;
      CurrentConvertList->FileServ = (DEST_SERVER_BUFFER *) CurrentConvertList->FileServ->Index;

      WriteFile(hFile, CurrentConvertList, sizeof(CONVERT_LIST), &wrote, NULL);

      CurrentConvertList->SourceServ = ss;
      CurrentConvertList->FileServ = ds;

      // Now the options
      UserOptionsSave(hFile, CurrentConvertList->ConvertOptions);
      FileOptionsSave(hFile, CurrentConvertList->FileOptions);

      CurrentConvertList = CurrentConvertList->next;
   }

   // Saved out the convert list - now need to save out the linked
   // information (these routines save their linked info as well).
   DomainListSave(hFile);
   DServListSave(hFile);
   SServListSave(hFile);

} // ConvertListSaveAll


/*+-------------------------------------------------------------------------+
  | ConvertListLoadAll()
  |
  +-------------------------------------------------------------------------+*/
void ConvertListLoadAll(HANDLE hFile) {
   CONVERT_LIST *tmpPtr;
   BOOL Continue = TRUE;
   DWORD wrote;

   while (Continue) {
      tmpPtr = AllocMemory(sizeof(CONVERT_LIST));
      if (tmpPtr == NULL)
         return;

      // Read in the record
      ReadFile(hFile, tmpPtr, sizeof(CONVERT_LIST), &wrote, NULL);

      // See if there are more records
      if (tmpPtr->next == NULL)
         Continue = FALSE;

      // clear out the old links - and fixup new ones
      tmpPtr->next = NULL;
      tmpPtr->prev = NULL;
      tmpPtr->ConvertOptions = NULL;
      tmpPtr->FileOptions = NULL;

      // Read in options - note the trusted domain must be fixed up later
      // after the domain list is read in
      UserOptionsLoad(hFile, &tmpPtr->ConvertOptions);
      FileOptionsLoad(hFile, &tmpPtr->FileOptions);

      // link it into the list
      if (!ConvertListStart)
         ConvertListStart = ConvertListEnd = tmpPtr;
      else {
         ConvertListEnd->next = tmpPtr;
         tmpPtr->prev = ConvertListEnd;
         ConvertListEnd = tmpPtr;
      }

      NumServerPairs++;
   }

   // Loaded the convert list - now need to bring in the linked
   // information (these routines load their linked info as well).
   DomainListLoad(hFile);
   DServListLoad(hFile);
   SServListLoad(hFile);

} // ConvertListLoadAll


/*+-------------------------------------------------------------------------+
  | ConvertListFixup()
  |
  +-------------------------------------------------------------------------+*/
void ConvertListFixup(HWND hWnd) {
   BOOL ok = TRUE;
   DWORD *SMap = NULL;
   DWORD *DMap = NULL;
   CONVERT_LIST *NextList;
   CONVERT_OPTIONS *cvto;

   // Generate Source and Destination server Index -> pointer maps
   DServListIndexMapGet(&DMap);
   SServListIndexMapGet(&SMap);

   if ((DMap == NULL) || (SMap == NULL))
      return;

   CurrentConvertList = ConvertListStart;
   while (CurrentConvertList) {
      CurrentConvertList->FileServ = (DEST_SERVER_BUFFER *) DMap[(DWORD) CurrentConvertList->FileServ];
      CurrentConvertList->SourceServ = (SOURCE_SERVER_BUFFER *) SMap[(DWORD) CurrentConvertList->SourceServ];

      CurrentConvertList = CurrentConvertList->next;
   }

   // Free up the index maps
   FreeMemory(DMap);
   FreeMemory(SMap);

   // Fixed the convert list - now need to fix the linked information 
   // (these routines fix-up their linked info as well).
   DServListFixup();
   SServListFixup();

   // For the user options later on
   DomainListIndexMapGet(&DMap);

   // Now validate each of the machines
   CurrentConvertList = ConvertListStart;
   while (CurrentConvertList) {
      ok = TRUE;
      if (!NTServerValidate(hWnd, CurrentConvertList->FileServ->Name))
         ok = FALSE;

      if (ok)
         if (!NWServerValidate(hWnd, CurrentConvertList->SourceServ->Name, FALSE))
            ok = FALSE;

      NextList = CurrentConvertList->next;

      if (!ok) {
         ConvertListDelete(CurrentConvertList);
      } else {
         // The connections were okay to these so resynch their information
         NWServerInfoReset(CurrentConvertList->SourceServ);
         NTServerInfoReset(hWnd, CurrentConvertList->FileServ, TRUE);
         DestShareListFixup(CurrentConvertList->FileServ);
         VShareListFixup(CurrentConvertList->FileServ);
         SourceShareListFixup(CurrentConvertList->FileServ, CurrentConvertList->SourceServ->ShareList);

         // need to fixup the trusted domain in the user options to the new 
         // domain list...
         cvto = (CONVERT_OPTIONS *) CurrentConvertList->ConvertOptions;

         if (cvto->UseTrustedDomain)
            cvto->TrustedDomain = (DOMAIN_BUFFER *) DMap[(DWORD) cvto->TrustedDomain];
         else
            cvto->TrustedDomain = NULL;

      }

      CurrentConvertList = NextList;
   }

   // Free up the domain index map
   FreeMemory(DMap);

} // ConvertListFixup


/*+-------------------------------------------------------------------------+
  | ConvertListLog()
  |
  +-------------------------------------------------------------------------+*/
void ConvertListLog() {
   DEST_SERVER_BUFFER *DServ = NULL;
   SOURCE_SERVER_BUFFER *SServ = NULL;
   ULONG i;

   CurrentConvertList = ConvertListStart;

   // Log format is:
   //
   // Number of Servers = 1
   //
   // [Servers]
   //     From:  Source1      To: Dest1
   //     From:  Source2      To: Dest2
   LogWriteLog(0, Lids(IDS_L_126), NumServerPairs);
   LogWriteLog(0, Lids(IDS_CRLF));
   LogWriteLog(0, Lids(IDS_L_127));

   LogWriteSummary(0, Lids(IDS_L_126), NumServerPairs);
   LogWriteSummary(0, Lids(IDS_CRLF));
   LogWriteSummary(0, Lids(IDS_L_127));

   // Loop through the conversion pairs (they are already in order)
   while (CurrentConvertList) {
      LogWriteLog(1, Lids(IDS_L_128), CurrentConvertList->SourceServ->Name, CurrentConvertList->FileServ->Name);
      LogWriteSummary(1, Lids(IDS_L_128), CurrentConvertList->SourceServ->Name, CurrentConvertList->FileServ->Name);
      CurrentConvertList = CurrentConvertList->next;
   }

   LogWriteLog(0, Lids(IDS_CRLF));
   LogWriteSummary(0, Lids(IDS_CRLF));

   // Now write detailed info on each server
   CurrentConvertList = ConvertListStart;

   // header for this section
   LogWriteLog(0, Lids(IDS_LINE));
   LogWriteLog(0, Lids(IDS_BRACE), Lids(IDS_L_129));
   LogWriteLog(0, Lids(IDS_LINE));
   LogWriteLog(0, Lids(IDS_CRLF));

   while (CurrentConvertList) {
      // Make sure to only log each source server once
      if (DServ != CurrentConvertList->FileServ) {
         // remember this new server
         DServ = CurrentConvertList->FileServ;

         LogWriteLog(0, TEXT("[%s]\r\n"), CurrentConvertList->FileServ->Name);
         LogWriteLog(1, Lids(IDS_L_130));
         LogWriteLog(1, Lids(IDS_L_131), DServ->VerMaj, DServ->VerMin);

         if (DServ->DriveList) {
            LogWriteLog(0, Lids(IDS_CRLF));
            LogWriteLog(1, Lids(IDS_L_132));

            for (i = 0; i < DServ->DriveList->Count; i++) {
               LogWriteLog(2, TEXT("%s: [%4s] %s\r\n"), DServ->DriveList->DList[i].Drive, DServ->DriveList->DList[i].DriveType, DServ->DriveList->DList[i].Name);
               LogWriteLog(3, Lids(IDS_L_133), lToStr(DServ->DriveList->DList[i].FreeSpace));
            }
         }

         // Log Shares
         ShareListLog(DServ->ShareList, TRUE);
      }

      // Now for the source server
      SServ = CurrentConvertList->SourceServ;
      LogWriteLog(0, TEXT("[%s]\r\n"), CurrentConvertList->SourceServ->Name);
      LogWriteLog(1, Lids(IDS_L_134));
      LogWriteLog(1, Lids(IDS_L_135), (UINT) SServ->VerMaj, (UINT) SServ->VerMin);

      ShareListLog(SServ->ShareList, FALSE);

      CurrentConvertList = CurrentConvertList->next;
   }

} // ConvertListLog


/*+-------------------------------------------------------------------------+
  | UserServerNameGet()
  |
  +-------------------------------------------------------------------------+*/
LPTSTR UserServerNameGet(DEST_SERVER_BUFFER *DServ, void *COpt) {
   CONVERT_OPTIONS *ConvOpt;
   LPTSTR ServName = NULL;

   ConvOpt = (CONVERT_OPTIONS *) COpt;
   // If going to a trusted domain then point to it's PDC for user transfers
   if (ConvOpt->UseTrustedDomain && (ConvOpt->TrustedDomain != NULL) && (ConvOpt->TrustedDomain->PDCName != NULL)) {
      ServName = ConvOpt->TrustedDomain->PDCName;
   } else
      // If in a domain then point to the PDC for user transfers
      if (DServ->InDomain && DServ->Domain) {
         ServName = DServ->Domain->PDCName;
      } else {
         ServName = DServ->Name;
      }

   return ServName;
} // UserServerNameGet