home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / vlmkt6.exe / WS_CONF.CPF < prev    next >
Text File  |  1993-09-28  |  13KB  |  448 lines

  1. /*
  2. **      Copyright (c) 1992 Novell, Inc.  All Rights Reserved.
  3. **
  4. **      THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS 
  5. **      AND TREATIES. NO PART OF THIS WORK MAY BE USED, PRACTICED, 
  6. **      PERFORMED COPIED, DISTRIBUTED, REVISED, MODIFIED, TRANSLATED, 
  7. **      ABRIDGED, CONDENSED, EXPANDED, COLLECTED, COMPILED, LINKED, 
  8. **      RECAST, TRANSFORMED OR ADAPTED WITHOUT THE PRIOR WRITTEN CONSENT
  9. **      OF NOVELL, INC.  ANY USE OR EXPLOITATION OF THIS WORK WITHOUT 
  10. **      AUTHORIZATION COULD SUBJECT THE PERPETRATOR TO CRIMINAL AND CIVIL
  11. **      LIABILITY.
  12. */
  13.  
  14. syntax (1.1); 
  15.  
  16. component (
  17.     /* CompID     */    WS_CONF,
  18.     /* CompVer    */    4.1,
  19.     /* CompStatus */    Retail
  20. );
  21.  
  22.  
  23. static    string    windowsDirectory;
  24. static    string    targetDrive;    /* Drive LWP is installed to */
  25. static    int    bootType;    /* How the workstation boots up */
  26. static    string    bootDrive;    /* Where ODI and Netware for DOS are placed */
  27. static    int    updateSystemFiles;    /* 0 = make another copy with changes */
  28. static    string    pathAUTOEXEC_BAT;    /* Path to system file to edit */
  29. static    string    pathCONFIG_SYS;    /* Path to system file to edit */
  30. static    string    pathNET_CFG;    /* Path to system file to edit */
  31. static    string    pathPROGMAN_INI;    /* Path to system file to edit */
  32. static    string    pathSYSTEM_INI;    /* Path to system file to edit */
  33. static    string    pathWIN_INI;    /* Path to system file to edit */
  34. static    string    targetPath;    /* Destination tree directory names */
  35. static    string    bootSourceFile[10];
  36. static    string    bootTargetFile[10];
  37. static    int    bootIndex;
  38.     int    found;        /* Flag for testing in loops */
  39.     int    width;        /* Width of list window */
  40.     string    savePath;
  41.     int    rc;        /* Return value from various functions */
  42.     int    requiredDiskSpace;
  43.     string    targetName[10];
  44.     int    i;        /* Loop control variable */
  45.     string    targetDirectory;
  46.     int    limit;        /* Number of system files to process */
  47.     int    f;        /* Loop control variable */
  48.     string    sourceFile;    /* Temporary variable */
  49.     string    targetFile;    /* Temporary variable */
  50.     string    editFile;    /* Temporary variable */
  51.     int    fh;        /* File handle index */
  52. static    int    req40;        /* flag indicating whether is 4.0 requester */
  53. static    string    req40PATH;
  54.     int    fc;
  55.     string    inputLine;
  56.     string    scanLine;
  57.     string    ch;
  58. static    string    MLIDbasename;
  59.  
  60. /*
  61. =================================================
  62. =  Check to see if LSL is loaded (required)     =
  63. =================================================
  64. */
  65. if (!GetMLIDList (MLIDbasename)) {
  66.     DisplayErrorText (ODI_NOT_PRESENT, FATAL);
  67.     exit(0);
  68. }
  69.  
  70. /* Initialization */
  71.  
  72. DisplayHelp (NWC_WELCOME_HELP);  
  73. PushHelpContext (IN_PROGRESS_HELP);
  74.  
  75. bootIndex = 0;
  76.  
  77. /*
  78. =================================================
  79. =  Check to see if Windows is in the DOS PATH.  =
  80. =================================================
  81. */
  82. windowsDirectory = which ("win.ini");
  83. TrimPath (windowsDirectory);
  84. if (windowsDirectory == "") {
  85.     /*
  86.     =================================
  87.     =  Windows is not in the path.  =
  88.     =================================
  89.     */
  90.     WS_LWP_W = 0;
  91.     found = 0;
  92. } else {
  93.     if (IsFile (windowsDirectory + "\\system.ini")) {
  94.         /*
  95.         =============================
  96.         =  Windows has been found.  =
  97.         =============================
  98.         */
  99.         WS_LWP_W = 1;
  100.         found = 1;
  101.     } else {
  102.         /*
  103.         ==============================================================
  104.         =  If this is a windows directory, it is a pre-3.0 Windows.  =
  105.         =  Since  a pre-3.0  Windows is not supported, we don't not  =
  106.         =  normally load the Windows applications.             =
  107.         ==============================================================
  108.         */
  109.         WS_LWP_W = 0;
  110.         found = 0;
  111.     } /* end if */
  112. } /* end if */
  113.  
  114. /*
  115. =================================================
  116. =  Get information about Windows installation.  =
  117. =================================================
  118. */
  119. while (!found && (WS_LWP_W)) {
  120.     PushHelpContext (WIN_DIR_PATH_HELP);
  121.     EditString (17,                /* Center Line */
  122.             0,                /* Center Column */
  123.             1,                /* Height */
  124.             70,                /* Width */
  125.             WINDOWS_DIR_HEADER,        /* Header */
  126.             WINDOWS_DIR_PROMPT,        /* Prompt */
  127.             windowsDirectory,        /* String Value */
  128.             EF_UPPER | EF_NOSPACES);    /* Edit Flags */
  129.     PopHelpContext();
  130.  
  131.     if (IsFile (windowsDirectory + "\\win.ini") &&
  132.         IsFile (windowsDirectory + "\\system.ini")) {
  133.         found = 1;
  134.     } else {
  135.         found = 0;
  136.         Alert (WINDOWS_DIR_NOT_FOUND, 18, 0);
  137.  
  138.         PushInformationText (2, YOU_MAY_WIN_DIR_MSG);
  139.  
  140.         InitList();
  141.         width = AppendToList (CONTINUE_WITHOUT_WINDOWS, FATAL);
  142.         rc = AppendToList (SPECIFY_A_NEW_PATH, FATAL);
  143.         if (width < rc) width = rc;
  144.         rc = AppendToList (EXIT_TO_DOS, FATAL);
  145.         if (width < rc) width = rc;
  146.         List (YOU_MAY,            /* headerText */
  147.               18,            /* centerLine */
  148.               0,            /* centerColumn */
  149.               YOU_MAY_WIN_DIR_HELP,    /* helpText */
  150.               3,            /* visibleHeight */
  151.               width,            /* visibleWidth */
  152.               0,            /* multipleSelectFlag */
  153.               rc);            /* result */
  154.         DestroyList();
  155.  
  156.         PopInformationText();
  157.  
  158.         if (rc == CONTINUE_WITHOUT_WINDOWS) {
  159.             WS_LWP_W = 0;
  160.         } else if (rc == EXIT_TO_DOS) {
  161.             rc = VerifyProgramExit();
  162.             if (rc) exit (2);
  163.         } /* end if */
  164.     } /* end if */
  165. } /* end while */
  166.  
  167.  
  168. /*
  169. =================================================
  170. =  Figure out how much disk space is required.  =
  171. =================================================
  172. */
  173. requiredDiskSpace = 1500;
  174.  
  175.  
  176. /*
  177. ==========================
  178. =  Find a target drive.  =
  179. ==========================
  180. */
  181. PushHelpContext (DEST_DRIVE_HELP);
  182. PushInformationText (2, DEST_DRIVE_INFO);
  183. targetDrive = GetDestDrive (DEST_DRIVE_HEADER,    /* Header */
  184.                 17, 0,        /* Location */
  185.                 requiredDiskSpace,    /* Minimum free space */
  186.                 0,            /* Server only flag */
  187.                 DEST_DRIVE_HELP,    /* Help message */
  188.                 WS_NO_SPACE_HELP);    /* Insuficient space help */
  189. PopInformationText();
  190. PopHelpContext();
  191.  
  192. /*
  193. ===================================================
  194. =  Set the default path and ask user to edit it.  =
  195. ===================================================
  196. */
  197. rc = GetDriveType (targetDrive);
  198. if (rc == 9) {
  199.     savePath = getcwd();            /* Network drive */
  200.     chdir (targetDrive);
  201.     targetPath = getcwd();
  202.     chdir (savePath);
  203. } else {
  204.     targetPath = targetDrive;        /* Local drive */
  205. } /* end if */
  206.  
  207. AppendPath (targetPath, "NET");
  208.  
  209. PushInformationText (2, TARGET_DIR_INFO);
  210. PushHelpContext (TARGET_DIR_HELP);
  211. EditString (17,                /* Center Line */
  212.         0,                /* Center Column */
  213.         1,                /* Height */
  214.         70,                /* Width */
  215.         SELECT_DIRECTORY,        /* Header */
  216.         TARGET_DIR_PROMPT,        /* Prompt */
  217.         targetPath,            /* String Value */
  218.         EF_UPPER | EF_NOSPACES);    /* Edit Flags */
  219. PopHelpContext();
  220. PopInformationText();
  221.  
  222. /*
  223. ======================================================
  224. =  Make sure that no extra '\' appended to the path  =
  225. ======================================================
  226. */
  227. strupr (targetPath);
  228. i = strlen (targetPath);
  229. if (substr(targetPath,i,1) == "\\") {
  230.     targetPath = substr(targetPath, 1, i-1);
  231. }
  232.  
  233. /*
  234. ==================================
  235. =  Make the target directories.  =
  236. ==================================
  237. */
  238. if (mkdir (targetPath)) {
  239.     DisplayErrorCondition (FATAL);
  240. } /* end if */
  241.  
  242. targetName[0] = "\\BIN";
  243. targetName[1] = "\\INSTALL";
  244. targetName[2] = "\\SAMPLE";
  245. targetName[3] = "\\TCP";
  246.  
  247. i = 0;
  248. do {
  249.     targetDirectory = targetPath + targetName[i];
  250.  
  251.     if (mkdir (targetDirectory)) {
  252.         DisplayErrorCondition (FATAL);
  253.     } /* end if */
  254.  
  255.     i = i + 1;
  256. } while (i <= 3);
  257.  
  258.  
  259. /*
  260. ==============================================================================
  261. =  The system message and overlay files are used by the  product,  so  copy  =
  262. =  them into the bin directory.                             =
  263. ==============================================================================
  264. */
  265. targetName[0] = "$run.ovl";        /* Do not reorder elements 0 - 4 */
  266. targetName[1] = "ibm$run.ovl";
  267. targetName[2] = "sys$err.dat";
  268. targetName[3] = "sys$help.dat";
  269. targetName[4] = "sys$msg.dat";
  270.  
  271. targetDirectory = targetPath + "\\BIN";
  272. i = 0;
  273. do {
  274.     if (copy (GetSourcePath() + targetName[i], targetDirectory)) {
  275.         DisplayErrorCondition (FATAL);
  276.     } /* end if */
  277.  
  278.     i = i + 1;
  279. } while (i <= 4);
  280.  
  281.  
  282. /*
  283. =============================================================
  284. =  Find out what kind of boot is done on this workstation.  =
  285. =============================================================
  286. */
  287. PushHelpContext (RPL_BOOT_HELP);
  288. PushInformationText (2, RPL_BOOT_INFO);
  289. bootType = Confirm (RPL_BOOT_QUESTION, 18, 0, 0);
  290. PopInformationText();
  291. PopHelpContext();
  292.  
  293. if (bootType) bootType = BOOT_BY_RPL;
  294.  
  295. /*
  296. =================================
  297. =  Get boot drive information.  =
  298. =================================
  299. */
  300. if (bootType == BOOT_BY_RPL) {
  301.     WS_ODI = 0;
  302.     bootDrive = targetDrive;
  303. } else {
  304.     bootDrive = GetBootDrive (17,            /* Center line */
  305.                   0,            /* Center column */
  306.                   BOOT_DRIVE_HEADER,    /* Header */
  307.                   BOOT_DRIVE_HELP);    /* Help */
  308.  
  309.     rc = GetDriveType (bootDrive);
  310.     if (rc == 6) {
  311.         bootType = BOOT_BY_HDU;
  312.     } else {
  313.         bootType = BOOT_BY_FDU;
  314.     } /* end if */
  315. } /* end if */
  316.  
  317.  
  318. /*
  319. ==============================================================================
  320. =  Ask if system files should be updated or not.  Make backups  and  choose  =
  321. =  which file to edit as appropriate to the answer.                 =
  322. ==============================================================================
  323. */
  324. PushHelpContext (UPDATE_SYSTEM_FILES_HELP);
  325. PushInformationText (2, UPDATE_SYSTEM_FILES_MSG);
  326. updateSystemFiles = Confirm (UPDATE_SYSTEM_FILES_PROMPT, 18, 0, 1);
  327. PopInformationText();
  328. PopHelpContext();
  329.  
  330. if (updateSystemFiles) {
  331.     DisplayHelp (WS_SYS_FILE_EDIT_HELP);
  332. } else {
  333.     DisplayHelp (WS_SYS_FILE_BACKUP_HELP);
  334. } /* end if */
  335.  
  336.  
  337. /*
  338. ========================
  339. =  Get the boot disk.  =
  340. ========================
  341. */
  342. if (bootType == BOOT_BY_FDU) {
  343.     found = 0;
  344.     do {
  345.         PushHelpContext (INSERT_BOOT_DISK_HELP);
  346.         DisplayInformation (NO_MESSAGE, 18, 0, INSERT_BOOT_DISKETTE);
  347.         PopHelpContext();
  348.  
  349.         if (IsFile (bootDrive + "\\IO.SYS") &&
  350.             IsFile (bootDrive + "\\MSDOS.SYS")) {
  351.             found = 1;
  352.         } /* end if */
  353.         if (IsFile (bootDrive + "\\IBMBIO.COM") &&
  354.             IsFile (bootDrive + "\\IBMDOS.COM")) {
  355.             found = 1;
  356.         } /* end if */
  357.     } while (!found);
  358. } /* end if */
  359.  
  360.  
  361. /*
  362. ==================================================================
  363. =  Copy system files to the NET\INSTALL directory to be edited.  =
  364. ==================================================================
  365. */
  366. targetName[0] = bootDrive + "\\AUTOEXEC.BAT";
  367. /*
  368. ==============================================================
  369. =  Find out whether NetWare 4.0/4.01 requester is installed  =
  370. ==============================================================
  371. */
  372. req40 = 0;
  373. if (IsFile (targetName[0])) {
  374.     fh = fopen (targetName[0], "r");
  375.     fc = fgets (inputLine, fh);
  376.     while (fc) {
  377.         scanLine = inputLine;
  378.         strupr (scanLine);
  379.         rc = 0;
  380.         do {
  381.             rc = rc + 1;
  382.             ch = substr (scanLine, rc, 1); 
  383.         } while ((ch == " ") || (ch == "\t"));
  384.         scanLine = substr (scanLine, rc, 255);
  385.         if ( (1 != searchstr (scanLine, "REM")) &&
  386.               (f = searchstr (scanLine, "STARTNET")) ) {
  387.             i = searchstr (scanLine, "CALL");
  388.             rc = 0;
  389.             if ( i ) rc = i + 4 - 1;
  390.             do {
  391.                 rc = rc + 1;
  392.                 ch = substr (scanLine, rc, 1); 
  393.             } while ((ch == " ") || (ch == "\t"));
  394.             req40PATH = substr (scanLine, rc, f - rc);
  395.             req40 = 1;
  396.             fc = 0;        /* force to terminate while loop */
  397.         } else {
  398.             fc = fgets (inputLine, fh);
  399.         }
  400.     }
  401.     fclose (fh);
  402. }
  403.  
  404. if (IsLSLPresent (targetName[1])) {
  405.     if (!IsFile (targetName[1])) targetName[1] = bootDrive + "\\NET.CFG";
  406. } else {
  407.     targetName[1] = bootDrive + "\\NET.CFG";
  408. } /* end if */
  409. if (req40) targetName[1] = req40PATH + "NET.CFG";
  410. targetName[2] = windowsDirectory + "\\SYSTEM.INI";
  411.  
  412. pathAUTOEXEC_BAT = targetPath + "\\INSTALL\\autoexec.bat";
  413. pathNET_CFG      = targetPath + "\\INSTALL\\net.cfg";
  414. pathSYSTEM_INI   = targetPath + "\\INSTALL\\system.ini";
  415.  
  416. i = (bootType == BOOT_BY_RPL) ? 1 : 0;
  417. limit = (WS_LWP_W) ? 2 : 1;
  418. do {
  419.     if (IsFile (targetName[i])) {
  420.         if (copy (targetName[i], targetPath + "\\INSTALL")) {
  421.             DisplayErrorCondition (FATAL);
  422.         } /* end if */
  423.     } else {
  424.         if (i == 0) {            /* Create the file */
  425.             fh = fopen (pathAUTOEXEC_BAT, "w");
  426.         } else if (i == 1) {
  427.             fh = fopen (pathNET_CFG, "w");
  428.         } else if (i == 2) {
  429.             fh = fopen (pathSYSTEM_INI, "w");
  430.         } /* end if */
  431.  
  432.         rc = fputs ("", fh);
  433.         rc = fclose (fh);
  434.     } /* end if */
  435.  
  436.     i = i + 1;
  437. } while (i <= limit);
  438.  
  439.  
  440. /*
  441. ================================
  442. =  Get the install disk back.  =
  443. ================================
  444. */
  445. if (bootType == BOOT_BY_FDU) {
  446.     GetCurrentDiskette (GetSourcePath() + "$run.ovl");
  447. } /* end if */
  448.