Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

775 lines
24 KiB

  1. //****************************************************************************
  2. //
  3. // Module: ISIGNUP.EXE
  4. // File: import.c
  5. // Content: This file contains all the functions that handle importing
  6. // connection information.
  7. // History:
  8. // Sat 10-Mar-1996 23:50:40 -by- Mark MacLin [mmaclin]
  9. // this code started its life as ixport.c in RNAUI.DLL
  10. // my thanks to viroont
  11. //
  12. // Copyright (c) Microsoft Corporation 1991-1996
  13. //
  14. //****************************************************************************
  15. #include "isignup.h"
  16. #define MAXNAME 80
  17. #define MAXIPADDRLEN 20
  18. #define SIZE_ReadBuf 0x00008000 // 32K buffer size
  19. //#pragma data_seg(".rdata")
  20. static const TCHAR cszEntrySection[] = TEXT("Entry");
  21. static const TCHAR cszEntryName[] = TEXT("Entry_Name");
  22. static const TCHAR cszAlias[] = TEXT("Import_Name");
  23. static const TCHAR cszML[] = TEXT("Multilink");
  24. static const TCHAR cszPhoneSection[] = TEXT("Phone");
  25. static const TCHAR cszDialAsIs[] = TEXT("Dial_As_Is");
  26. static const TCHAR cszPhone[] = TEXT("Phone_Number");
  27. static const TCHAR cszAreaCode[] = TEXT("Area_Code");
  28. static const TCHAR cszCountryCode[] = TEXT("Country_Code");
  29. static const TCHAR cszCountryID[] = TEXT("Country_ID");
  30. static const TCHAR cszDeviceSection[] = TEXT("Device");
  31. static const TCHAR cszDeviceType[] = TEXT("Type");
  32. static const TCHAR cszDeviceName[] = TEXT("Name");
  33. static const TCHAR cszDevCfgSize[] = TEXT("Settings_Size");
  34. static const TCHAR cszDevCfg[] = TEXT("Settings");
  35. static const TCHAR cszServerSection[] = TEXT("Server");
  36. static const TCHAR cszServerType[] = TEXT("Type");
  37. static const TCHAR cszSWCompress[] = TEXT("SW_Compress");
  38. static const TCHAR cszPWEncrypt[] = TEXT("PW_Encrypt");
  39. static const TCHAR cszNetLogon[] = TEXT("Network_Logon");
  40. static const TCHAR cszSWEncrypt[] = TEXT("SW_Encrypt");
  41. static const TCHAR cszNetBEUI[] = TEXT("Negotiate_NetBEUI");
  42. static const TCHAR cszIPX[] = TEXT("Negotiate_IPX/SPX");
  43. static const TCHAR cszIP[] = TEXT("Negotiate_TCP/IP");
  44. static TCHAR cszDisableLcp[] = TEXT("Disable_LCP");
  45. static const TCHAR cszIPSection[] = TEXT("TCP/IP");
  46. static const TCHAR cszIPSpec[] = TEXT("Specify_IP_Address");
  47. static const TCHAR cszIPAddress[] = TEXT("IP_address");
  48. static const TCHAR cszServerSpec[] = TEXT("Specify_Server_Address");
  49. static const TCHAR cszDNSAddress[] = TEXT("DNS_address");
  50. static const TCHAR cszDNSAltAddress[] = TEXT("DNS_Alt_address");
  51. static const TCHAR cszWINSAddress[] = TEXT("WINS_address");
  52. static const TCHAR cszWINSAltAddress[]= TEXT("WINS_Alt_address");
  53. static const TCHAR cszIPCompress[] = TEXT("IP_Header_Compress");
  54. static const TCHAR cszWanPri[] = TEXT("Gateway_On_Remote");
  55. static const TCHAR cszMLSection[] = TEXT("Multilink");
  56. static const TCHAR cszLinkIndex[] = TEXT("Line_%s");
  57. static const TCHAR cszScriptingSection[] = TEXT("Scripting");
  58. static const TCHAR cszScriptName[] = TEXT("Name");
  59. static const TCHAR cszScriptSection[] = TEXT("Script_File");
  60. #if !defined(WIN16)
  61. static const TCHAR cszCustomDialerSection[] = TEXT("Custom_Dialer");
  62. static const TCHAR cszAutoDialDLL[] = TEXT("Auto_Dial_DLL");
  63. static const TCHAR cszAutoDialFunc[] = TEXT("Auto_Dial_Function");
  64. #endif //!WIN16
  65. static const TCHAR cszYes[] = TEXT("yes");
  66. static const TCHAR cszNo[] = TEXT("no");
  67. static const TCHAR cszUserSection[] = TEXT("User");
  68. static const TCHAR cszUserName[] = TEXT("Name");
  69. static const TCHAR cszPassword[] = TEXT("Password");
  70. static const TCHAR cszNull[] = TEXT("");
  71. struct {
  72. TCHAR *szType;
  73. DWORD dwType;
  74. DWORD dwfOptions;
  75. } aServerTypes[] =
  76. {
  77. {TEXT("PPP"), RASFP_Ppp, 0},
  78. {TEXT("SLIP"), RASFP_Slip, 0},
  79. {TEXT("CSLIP"), RASFP_Slip, RASEO_IpHeaderCompression},
  80. {TEXT("RAS"), RASFP_Ras, 0}
  81. };
  82. //#pragma data_seg()
  83. #define myisdigit(ch) (((ch) >= '0') && ((ch) <= '9'))
  84. #if !defined(WIN16)
  85. //+----------------------------------------------------------------------------
  86. //
  87. // Function: ImportCustomDialer
  88. //
  89. // Synopsis: Import custom dialer information from the specified file
  90. // and save the information in the RASENTRY
  91. //
  92. // Arguments: lpRasEntry - pointer to a valid RASENTRY structure
  93. // szFileName - text file (in .ini file format) containing the
  94. // Custom Dialer information
  95. //
  96. // Returns: ERROR_SUCCESS - success otherwise a Win32 error
  97. //
  98. // History: ChrisK Created 7/11/96
  99. // 8/12/96 ChrisK Ported from \\trango
  100. //
  101. //-----------------------------------------------------------------------------
  102. DWORD ImportCustomDialer(LPRASENTRY lpRasEntry, LPCTSTR szFileName)
  103. {
  104. // If there is an error reading the information from the file, or the entry
  105. // missing or blank, the default value (cszNull) will be used.
  106. GetPrivateProfileString(cszCustomDialerSection,
  107. cszAutoDialDLL,
  108. cszNull,
  109. lpRasEntry->szAutodialDll,
  110. MAX_PATH,
  111. szFileName);
  112. GetPrivateProfileString(cszCustomDialerSection,
  113. cszAutoDialFunc,
  114. cszNull,
  115. lpRasEntry->szAutodialFunc,
  116. MAX_PATH,
  117. szFileName);
  118. return ERROR_SUCCESS;
  119. }
  120. #endif //!WIN16
  121. //****************************************************************************
  122. // DWORD NEAR PASCAL StrToip (LPTSTR szIPAddress, LPDWORD lpdwAddr)
  123. //
  124. // This function converts a IP address string to an IP address structure.
  125. //
  126. // History:
  127. // Mon 18-Dec-1995 10:07:02 -by- Viroon Touranachun [viroont]
  128. // Cloned from SMMSCRPT.
  129. //****************************************************************************
  130. LPCTSTR NEAR PASCAL StrToSubip (LPCTSTR szIPAddress, LPBYTE pVal)
  131. {
  132. LPCTSTR pszIP = szIPAddress;
  133. BYTE val = 0;
  134. // skip separators (non digits)
  135. while (*pszIP && !myisdigit(*pszIP))
  136. {
  137. ++pszIP;
  138. }
  139. while (myisdigit(*pszIP))
  140. {
  141. val = (val * 10) + (BYTE)(*pszIP - '0');
  142. ++pszIP;
  143. }
  144. *pVal = val;
  145. return pszIP;
  146. }
  147. DWORD NEAR PASCAL StrToip (LPCTSTR szIPAddress, RASIPADDR *ipAddr)
  148. {
  149. LPCTSTR pszIP = szIPAddress;
  150. pszIP = StrToSubip(pszIP, &ipAddr->a);
  151. pszIP = StrToSubip(pszIP, &ipAddr->b);
  152. pszIP = StrToSubip(pszIP, &ipAddr->c);
  153. pszIP = StrToSubip(pszIP, &ipAddr->d);
  154. return ERROR_SUCCESS;
  155. }
  156. //****************************************************************************
  157. // DWORD NEAR PASCAL ImportPhoneInfo(PPHONENUM ppn, LPCTSTR szFileName)
  158. //
  159. // This function imports the phone number.
  160. //
  161. // History:
  162. // Mon 18-Dec-1995 10:07:02 -by- Viroon Touranachun [viroont]
  163. // Created.
  164. //****************************************************************************
  165. DWORD NEAR PASCAL ImportPhoneInfo(LPRASENTRY lpRasEntry, LPCTSTR szFileName)
  166. {
  167. TCHAR szYesNo[MAXNAME];
  168. if (GetPrivateProfileString(cszPhoneSection,
  169. cszPhone,
  170. cszNull,
  171. lpRasEntry->szLocalPhoneNumber,
  172. RAS_MaxPhoneNumber,
  173. szFileName) == 0)
  174. {
  175. return ERROR_BAD_PHONE_NUMBER;
  176. };
  177. lpRasEntry->dwfOptions &= ~RASEO_UseCountryAndAreaCodes;
  178. GetPrivateProfileString(cszPhoneSection,
  179. cszDialAsIs,
  180. cszNo,
  181. szYesNo,
  182. MAXNAME,
  183. szFileName);
  184. // Do we have to get country code and area code?
  185. //
  186. if (!lstrcmpi(szYesNo, cszNo))
  187. {
  188. // If we cannot get the country ID or it is zero, default to dial as is
  189. //
  190. if ((lpRasEntry->dwCountryID = GetPrivateProfileInt(cszPhoneSection,
  191. cszCountryID,
  192. 0,
  193. szFileName)) != 0)
  194. {
  195. lpRasEntry->dwCountryCode = GetPrivateProfileInt(cszPhoneSection,
  196. cszCountryCode,
  197. 1,
  198. szFileName);
  199. GetPrivateProfileString(cszPhoneSection,
  200. cszAreaCode,
  201. cszNull,
  202. lpRasEntry->szAreaCode,
  203. RAS_MaxAreaCode,
  204. szFileName);
  205. lpRasEntry->dwfOptions |= RASEO_UseCountryAndAreaCodes;
  206. }
  207. }
  208. #ifdef WIN32
  209. else
  210. {
  211. // bug in RasSetEntryProperties still checks area codes
  212. // even when RASEO_UseCountryAndAreaCodes is not set
  213. lstrcpy(lpRasEntry->szAreaCode, TEXT("805"));
  214. lpRasEntry->dwCountryID = 1;
  215. lpRasEntry->dwCountryCode = 1;
  216. }
  217. #endif
  218. return ERROR_SUCCESS;
  219. }
  220. //****************************************************************************
  221. // DWORD NEAR PASCAL ImportServerInfo(PSMMINFO psmmi, LPTSTR szFileName)
  222. //
  223. // This function imports the server type name and settings.
  224. //
  225. // History:
  226. // Mon 18-Dec-1995 10:07:02 -by- Viroon Touranachun [viroont]
  227. // Created.
  228. //****************************************************************************
  229. DWORD NEAR PASCAL ImportServerInfo(LPRASENTRY lpRasEntry, LPCTSTR szFileName)
  230. {
  231. TCHAR szYesNo[MAXNAME];
  232. TCHAR szType[MAXNAME];
  233. DWORD i;
  234. // Get the server type name
  235. //
  236. GetPrivateProfileString(cszServerSection,
  237. cszServerType,
  238. cszNull,
  239. szType,
  240. MAXNAME,
  241. szFileName);
  242. // need to convert the string into
  243. // one of the following values
  244. // RASFP_Ppp
  245. // RASFP_Slip Note CSLIP is SLIP with IP compression on
  246. // RASFP_Ras
  247. for (i = 0; i < sizeof(aServerTypes)/sizeof(aServerTypes[0]); ++i)
  248. {
  249. if (!lstrcmpi(aServerTypes[i].szType, szType))
  250. {
  251. lpRasEntry->dwFramingProtocol = aServerTypes[i].dwType;
  252. lpRasEntry->dwfOptions |= aServerTypes[i].dwfOptions;
  253. break;
  254. }
  255. }
  256. // Get the server type settings
  257. //
  258. if (GetPrivateProfileString(cszServerSection,
  259. cszSWCompress,
  260. cszYes,
  261. szYesNo,
  262. MAXNAME,
  263. szFileName))
  264. {
  265. if (!lstrcmpi(szYesNo, cszNo))
  266. {
  267. lpRasEntry->dwfOptions &= ~RASEO_SwCompression;
  268. }
  269. else
  270. {
  271. lpRasEntry->dwfOptions |= RASEO_SwCompression;
  272. };
  273. };
  274. if (GetPrivateProfileString(cszServerSection,
  275. cszPWEncrypt,
  276. cszNull,
  277. szYesNo,
  278. MAXNAME,
  279. szFileName))
  280. {
  281. if (!lstrcmpi(szYesNo, cszNo))
  282. {
  283. lpRasEntry->dwfOptions &= ~RASEO_RequireEncryptedPw;
  284. }
  285. else
  286. {
  287. lpRasEntry->dwfOptions |= RASEO_RequireEncryptedPw;
  288. };
  289. };
  290. if (GetPrivateProfileString(cszServerSection,
  291. cszNetLogon,
  292. cszNo,
  293. szYesNo,
  294. MAXNAME,
  295. szFileName))
  296. {
  297. if (!lstrcmpi(szYesNo, cszNo))
  298. {
  299. lpRasEntry->dwfOptions &= ~RASEO_NetworkLogon;
  300. }
  301. else
  302. {
  303. lpRasEntry->dwfOptions |= RASEO_NetworkLogon;
  304. };
  305. };
  306. if (GetPrivateProfileString(cszServerSection,
  307. cszSWEncrypt,
  308. cszNo,
  309. szYesNo,
  310. MAXNAME,
  311. szFileName))
  312. {
  313. if (!lstrcmpi(szYesNo, cszNo))
  314. {
  315. lpRasEntry->dwfOptions &= ~RASEO_RequireDataEncryption;
  316. }
  317. else
  318. {
  319. lpRasEntry->dwfOptions |= RASEO_RequireDataEncryption;
  320. };
  321. };
  322. // Get the protocol settings
  323. //
  324. if (GetPrivateProfileString(cszServerSection,
  325. cszNetBEUI,
  326. cszNo,
  327. szYesNo,
  328. MAXNAME,
  329. szFileName))
  330. {
  331. if (!lstrcmpi(szYesNo, cszNo))
  332. {
  333. lpRasEntry->dwfNetProtocols &= ~RASNP_NetBEUI;
  334. }
  335. else
  336. {
  337. lpRasEntry->dwfNetProtocols |= RASNP_NetBEUI;
  338. };
  339. };
  340. if (GetPrivateProfileString(cszServerSection,
  341. cszIPX,
  342. cszNo,
  343. szYesNo,
  344. MAXNAME,
  345. szFileName))
  346. {
  347. if (!lstrcmpi(szYesNo, cszNo))
  348. {
  349. lpRasEntry->dwfNetProtocols &= ~RASNP_Ipx;
  350. }
  351. else
  352. {
  353. lpRasEntry->dwfNetProtocols |= RASNP_Ipx;
  354. };
  355. };
  356. if (GetPrivateProfileString(cszServerSection,
  357. cszIP,
  358. cszYes,
  359. szYesNo,
  360. MAXNAME,
  361. szFileName))
  362. {
  363. if (!lstrcmpi(szYesNo, cszNo))
  364. {
  365. lpRasEntry->dwfNetProtocols &= ~RASNP_Ip;
  366. }
  367. else
  368. {
  369. lpRasEntry->dwfNetProtocols |= RASNP_Ip;
  370. };
  371. };
  372. if (GetPrivateProfileString(cszServerSection,
  373. cszDisableLcp,
  374. cszNull,
  375. szYesNo,
  376. MAXNAME,
  377. szFileName))
  378. {
  379. if (!lstrcmpi(szYesNo, cszYes))
  380. {
  381. lpRasEntry->dwfOptions |= RASEO_DisableLcpExtensions;
  382. }
  383. else
  384. {
  385. lpRasEntry->dwfOptions &= ~RASEO_DisableLcpExtensions;
  386. }
  387. };
  388. return ERROR_SUCCESS;
  389. }
  390. //****************************************************************************
  391. // DWORD NEAR PASCAL ImportIPInfo(LPTSTR szEntryName, LPTSTR szFileName)
  392. //
  393. // This function imports the TCP/IP information
  394. //
  395. // History:
  396. // Mon 18-Dec-1995 10:07:02 -by- Viroon Touranachun [viroont]
  397. // Created.
  398. //****************************************************************************
  399. DWORD NEAR PASCAL ImportIPInfo(LPRASENTRY lpRasEntry, LPCTSTR szFileName)
  400. {
  401. TCHAR szIPAddr[MAXIPADDRLEN];
  402. TCHAR szYesNo[MAXNAME];
  403. // Import IP address information
  404. //
  405. if (GetPrivateProfileString(cszIPSection,
  406. cszIPSpec,
  407. cszNo,
  408. szYesNo,
  409. MAXNAME,
  410. szFileName))
  411. {
  412. if (!lstrcmpi(szYesNo, cszYes))
  413. {
  414. // The import file has IP address specified, get the IP address
  415. //
  416. lpRasEntry->dwfOptions |= RASEO_SpecificIpAddr;
  417. if (GetPrivateProfileString(cszIPSection,
  418. cszIPAddress,
  419. cszNull,
  420. szIPAddr,
  421. MAXIPADDRLEN,
  422. szFileName))
  423. {
  424. StrToip (szIPAddr, &lpRasEntry->ipaddr);
  425. };
  426. }
  427. else
  428. {
  429. lpRasEntry->dwfOptions &= ~RASEO_SpecificIpAddr;
  430. };
  431. };
  432. // Import Server address information
  433. //
  434. if (GetPrivateProfileString(cszIPSection,
  435. cszServerSpec,
  436. cszNo,
  437. szYesNo,
  438. MAXNAME,
  439. szFileName))
  440. {
  441. if (!lstrcmpi(szYesNo, cszYes))
  442. {
  443. // The import file has server address specified, get the server address
  444. //
  445. lpRasEntry->dwfOptions |= RASEO_SpecificNameServers;
  446. if (GetPrivateProfileString(cszIPSection,
  447. cszDNSAddress,
  448. cszNull,
  449. szIPAddr,
  450. MAXIPADDRLEN,
  451. szFileName))
  452. {
  453. StrToip (szIPAddr, &lpRasEntry->ipaddrDns);
  454. };
  455. if (GetPrivateProfileString(cszIPSection,
  456. cszDNSAltAddress,
  457. cszNull,
  458. szIPAddr,
  459. MAXIPADDRLEN,
  460. szFileName))
  461. {
  462. StrToip (szIPAddr, &lpRasEntry->ipaddrDnsAlt);
  463. };
  464. if (GetPrivateProfileString(cszIPSection,
  465. cszWINSAddress,
  466. cszNull,
  467. szIPAddr,
  468. MAXIPADDRLEN,
  469. szFileName))
  470. {
  471. StrToip (szIPAddr, &lpRasEntry->ipaddrWins);
  472. };
  473. if (GetPrivateProfileString(cszIPSection,
  474. cszWINSAltAddress,
  475. cszNull,
  476. szIPAddr,
  477. MAXIPADDRLEN,
  478. szFileName))
  479. {
  480. StrToip (szIPAddr, &lpRasEntry->ipaddrWinsAlt);
  481. };
  482. }
  483. else
  484. {
  485. lpRasEntry->dwfOptions &= ~RASEO_SpecificNameServers;
  486. };
  487. };
  488. // Header compression and the gateway settings
  489. //
  490. if (GetPrivateProfileString(cszIPSection,
  491. cszIPCompress,
  492. cszYes,
  493. szYesNo,
  494. MAXNAME,
  495. szFileName))
  496. {
  497. if (!lstrcmpi(szYesNo, cszNo))
  498. {
  499. lpRasEntry->dwfOptions &= ~RASEO_IpHeaderCompression;
  500. }
  501. else
  502. {
  503. lpRasEntry->dwfOptions |= RASEO_IpHeaderCompression;
  504. };
  505. };
  506. if (GetPrivateProfileString(cszIPSection,
  507. cszWanPri,
  508. cszYes,
  509. szYesNo,
  510. MAXNAME,
  511. szFileName))
  512. {
  513. if (!lstrcmpi(szYesNo, cszNo))
  514. {
  515. lpRasEntry->dwfOptions &= ~RASEO_RemoteDefaultGateway;
  516. }
  517. else
  518. {
  519. lpRasEntry->dwfOptions |= RASEO_RemoteDefaultGateway;
  520. };
  521. };
  522. return ERROR_SUCCESS;
  523. }
  524. DWORD NEAR PASCAL ImportScriptFile(
  525. LPCTSTR lpszImportFile,
  526. LPTSTR szScriptFile,
  527. UINT cbScriptFile)
  528. {
  529. TCHAR szTemp[_MAX_PATH];
  530. DWORD dwRet = ERROR_SUCCESS;
  531. // Get the script filename
  532. //
  533. if (GetPrivateProfileString(cszScriptingSection,
  534. cszScriptName,
  535. cszNull,
  536. szTemp,
  537. _MAX_PATH,
  538. lpszImportFile) != 0)
  539. {
  540. //!!! commonize this code
  541. //!!! make it DBCS compatible
  542. //!!! check for overruns
  543. //!!! check for absolute path name
  544. GetWindowsDirectory(szScriptFile, cbScriptFile);
  545. if (*CharPrev(szScriptFile, szScriptFile + lstrlen(szScriptFile)) != '\\')
  546. {
  547. lstrcat(szScriptFile, TEXT("\\"));
  548. }
  549. lstrcat(szScriptFile, szTemp);
  550. dwRet =ImportFile(lpszImportFile, cszScriptSection, szScriptFile);
  551. }
  552. return dwRet;
  553. }
  554. //****************************************************************************
  555. // DWORD WINAPI RnaValidateImportEntry (LPTSTR)
  556. //
  557. // This function is called to validate an importable file
  558. //
  559. // History:
  560. // Wed 03-Jan-1996 09:45:01 -by- Viroon Touranachun [viroont]
  561. // Created.
  562. //****************************************************************************
  563. DWORD WINAPI RnaValidateImportEntry (LPCTSTR szFileName)
  564. {
  565. TCHAR szTmp[MAX_PATH+1];
  566. // Get the alias entry name
  567. //
  568. // 12/4/96 jmazner Normandy #12373
  569. // If no such key, don't return ERROR_INVALID_PHONEBOOK_ENTRY,
  570. // since ConfigureClient always ignores that error code.
  571. return (GetPrivateProfileString(cszEntrySection,
  572. cszEntryName,
  573. cszNull,
  574. szTmp,
  575. MAX_PATH,
  576. szFileName) > 0 ?
  577. ERROR_SUCCESS : ERROR_NO_MATCH);
  578. }
  579. //****************************************************************************
  580. // DWORD WINAPI RnaImportEntry (LPTSTR, LPBYTE, DWORD)
  581. //
  582. // This function is called to import an entry from a specified file
  583. //
  584. // History:
  585. // Mon 18-Dec-1995 10:07:02 -by- Viroon Touranachun [viroont]
  586. // Created.
  587. //****************************************************************************
  588. DWORD ImportRasEntry (LPCTSTR szFileName, LPRASENTRY lpRasEntry)
  589. {
  590. DWORD dwRet;
  591. dwRet = ImportPhoneInfo(lpRasEntry, szFileName);
  592. if (ERROR_SUCCESS == dwRet)
  593. {
  594. // Get device type
  595. //
  596. GetPrivateProfileString(cszDeviceSection,
  597. cszDeviceType,
  598. cszNull,
  599. lpRasEntry->szDeviceType,
  600. RAS_MaxDeviceType,
  601. szFileName);
  602. // Get Server Type settings
  603. //
  604. dwRet = ImportServerInfo(lpRasEntry, szFileName);
  605. if (ERROR_SUCCESS == dwRet)
  606. {
  607. // Get IP address
  608. //
  609. dwRet = ImportIPInfo(lpRasEntry, szFileName);
  610. }
  611. }
  612. return dwRet;
  613. }
  614. //****************************************************************************
  615. // DWORD WINAPI RnaImportEntry (LPTSTR, LPBYTE, DWORD)
  616. //
  617. // This function is called to import an entry from a specified file
  618. //
  619. // History:
  620. // Mon 18-Dec-1995 10:07:02 -by- Viroon Touranachun [viroont]
  621. // Created.
  622. //****************************************************************************
  623. DWORD ImportConnection (LPCTSTR szFileName, LPICONNECTION lpConn)
  624. {
  625. DWORD dwRet;
  626. lpConn->RasEntry.dwSize = sizeof(RASENTRY);
  627. dwRet = RnaValidateImportEntry(szFileName);
  628. if (ERROR_SUCCESS != dwRet)
  629. {
  630. return dwRet;
  631. }
  632. GetPrivateProfileString(cszEntrySection,
  633. cszEntryName,
  634. cszNull,
  635. lpConn->szEntryName,
  636. RAS_MaxEntryName,
  637. szFileName);
  638. GetPrivateProfileString(cszUserSection,
  639. cszUserName,
  640. cszNull,
  641. lpConn->szUserName,
  642. UNLEN,
  643. szFileName);
  644. GetPrivateProfileString(cszUserSection,
  645. cszPassword,
  646. cszNull,
  647. lpConn->szPassword,
  648. PWLEN,
  649. szFileName);
  650. dwRet = ImportRasEntry(szFileName, &lpConn->RasEntry);
  651. #if !defined(WIN16)
  652. if (ERROR_SUCCESS == dwRet)
  653. {
  654. dwRet = ImportCustomDialer(&lpConn->RasEntry, szFileName);
  655. }
  656. #endif //!WIN16
  657. if (ERROR_SUCCESS == dwRet)
  658. {
  659. // Import the script file
  660. //
  661. dwRet = ImportScriptFile(szFileName,
  662. lpConn->RasEntry.szScript,
  663. sizeof(lpConn->RasEntry.szScript)/sizeof(TCHAR));
  664. }
  665. #if !defined(WIN16)
  666. dwRet = ConfigRasEntryDevice(&lpConn->RasEntry);
  667. switch( dwRet )
  668. {
  669. case ERROR_SUCCESS:
  670. break;
  671. case ERROR_CANCELLED:
  672. InfoMsg(NULL, IDS_SIGNUPCANCELLED);
  673. // Fall through
  674. default:
  675. goto ImportConnectionExit;
  676. }
  677. #endif
  678. ImportConnectionExit:
  679. return dwRet;
  680. }