1 | //
|
---|
2 | // MINSTALL.DLL (c) Copyright 2002-2005 Martin Kiewitz
|
---|
3 | //
|
---|
4 | // This file is part of MINSTALL.DLL for OS/2 / eComStation
|
---|
5 | //
|
---|
6 | // MINSTALL.DLL is free software: you can redistribute it and/or modify
|
---|
7 | // it under the terms of the GNU General Public License as published by
|
---|
8 | // the Free Software Foundation, either version 3 of the License, or
|
---|
9 | // (at your option) any later version.
|
---|
10 | //
|
---|
11 | // MINSTALL.DLL is distributed in the hope that it will be useful,
|
---|
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | // GNU General Public License for more details.
|
---|
15 | //
|
---|
16 | // You should have received a copy of the GNU General Public License
|
---|
17 | // along with MINSTALL.DLL. If not, see <http://www.gnu.org/licenses/>.
|
---|
18 | //
|
---|
19 |
|
---|
20 | #define INCL_NOPMAPI
|
---|
21 | #define INCL_BASE
|
---|
22 | #define INCL_DOSMODULEMGR
|
---|
23 | #include <os2.h>
|
---|
24 | #include <malloc.h>
|
---|
25 |
|
---|
26 | #include <global.h>
|
---|
27 | #include <cfgsys.h>
|
---|
28 | #include <crcs.h>
|
---|
29 | #include <dll.h>
|
---|
30 | #include <file.h>
|
---|
31 | #include <globstr.h>
|
---|
32 | #include <msg.h>
|
---|
33 | #include <mmi_public.h>
|
---|
34 | #include <mmi_types.h>
|
---|
35 | #include <mmi_main.h>
|
---|
36 | #include <mmi_helper.h>
|
---|
37 | #include <mmi_cardinfo.h>
|
---|
38 | #include <mmi_ctrlprc.h>
|
---|
39 | #include <mmi_msg.h>
|
---|
40 |
|
---|
41 | VOID MINSTALL_SelectFiles (VOID) {
|
---|
42 | PMINSTFILE CurFilePtr = FCF_FileArrayPtr;
|
---|
43 | PMINSTGRP CurGroupPtr = MCF_GroupArrayPtr;
|
---|
44 | USHORT CurNo = 0;
|
---|
45 |
|
---|
46 | MINSTCID_FileCount = 0;
|
---|
47 | MINSTCID_GroupCount = 0;
|
---|
48 |
|
---|
49 | // Count selected groups...
|
---|
50 | while (CurNo<MCF_GroupCount) {
|
---|
51 | if (CurGroupPtr->Flags & MINSTGRP_Flags_Selected)
|
---|
52 | MINSTCID_GroupCount++;
|
---|
53 | CurGroupPtr++; CurNo++;
|
---|
54 | }
|
---|
55 |
|
---|
56 | // Select files & Directories depending on selected groups...
|
---|
57 | CurNo = 0;
|
---|
58 | while (CurNo<FCF_FileCount) {
|
---|
59 | if (CurFilePtr->GroupPtr->Flags & MINSTGRP_Flags_Selected) {
|
---|
60 | CurFilePtr->Flags |= MINSTFILE_Flags_Selected;
|
---|
61 | CurFilePtr->SourcePtr->Flags |= MINSTDIR_Flags_Selected;
|
---|
62 | CurFilePtr->DestinPtr->Flags |= MINSTDIR_Flags_Selected;
|
---|
63 |
|
---|
64 | // We count all MINSTCID-DLLs together...
|
---|
65 | if ((CurFilePtr->Flags & MINSTFILE_Flags_INSTDLL) || (CurFilePtr->Flags & MINSTFILE_Flags_INSTTermDLL))
|
---|
66 | MINSTCID_FileCount++;
|
---|
67 | }
|
---|
68 | CurFilePtr++; CurNo++;
|
---|
69 | }
|
---|
70 | }
|
---|
71 |
|
---|
72 | // Will create destination directories...
|
---|
73 | BOOL MINSTALL_CreateDestinDirectories (VOID) {
|
---|
74 | PMINSTDIR CurDirPtr = MCF_DestinDirArrayPtr;
|
---|
75 | USHORT CurDirNo = 0;
|
---|
76 |
|
---|
77 | while (CurDirNo<MCF_DestinDirCount) {
|
---|
78 | if (CurDirPtr->Flags & MINSTDIR_Flags_Selected) {
|
---|
79 | if (CurDirPtr->FQName[0]!=0) {
|
---|
80 | if (!FILE_CreateDirectory ((PCHAR)CurDirPtr->FQName)) {
|
---|
81 | MSG_SetInsertViaPSZ (1, CurDirPtr->FQName);
|
---|
82 | MINSTALL_TrappedError (MINSTMSG_CouldNotCreateDirectory);
|
---|
83 | return FALSE; // If no success
|
---|
84 | }
|
---|
85 | }
|
---|
86 | }
|
---|
87 | CurDirPtr++; CurDirNo++;
|
---|
88 | }
|
---|
89 | return TRUE;
|
---|
90 | }
|
---|
91 |
|
---|
92 | // Will copy source files to destination...
|
---|
93 | BOOL MINSTALL_CopyFiles (VOID) {
|
---|
94 | PMINSTFILE CurFilePtr = FCF_FileArrayPtr;
|
---|
95 | USHORT CurNo = 0;
|
---|
96 | PMINSTDIR CurSourceDirPtr = 0;
|
---|
97 | PMINSTGRP CurGroupPtr = 0;
|
---|
98 | CHAR ChangeControlFile[13];
|
---|
99 | CHAR TempSourceFile[MINSTMAX_PATHLENGTH];
|
---|
100 | CHAR TempDestinFile[MINSTMAX_PATHLENGTH];
|
---|
101 | BOOL AnythingDelayed = FALSE;
|
---|
102 | APIRET rc;
|
---|
103 | CFGSYSRET CfgSysRC;
|
---|
104 |
|
---|
105 | while (CurNo<FCF_FileCount) {
|
---|
106 | if (CurFilePtr->Flags & MINSTFILE_Flags_Selected) {
|
---|
107 | // This file is selected, so process it...
|
---|
108 | if (!STRING_CombinePSZ ((PCHAR)&TempSourceFile, MINSTMAX_PATHLENGTH, CurFilePtr->SourcePtr->FQName, CurFilePtr->Name))
|
---|
109 | return FALSE;
|
---|
110 |
|
---|
111 | if (CurFilePtr->Flags & MINSTFILE_Flags_Included) {
|
---|
112 | // Is Included, so copy this file to its desired destination...
|
---|
113 | if (!STRING_CombinePSZ ((PCHAR)&TempDestinFile, MINSTMAX_PATHLENGTH, CurFilePtr->DestinPtr->FQName, CurFilePtr->Name))
|
---|
114 | return FALSE;
|
---|
115 | MINSTLOG_ToAll (" -> %s\n", TempDestinFile);
|
---|
116 | // Remove R/O attribute, if currently set
|
---|
117 | FILE_ResetAttributes (TempDestinFile);
|
---|
118 | // Copy file and replace if already there...
|
---|
119 | rc = FILE_Replace (TempSourceFile, TempDestinFile);
|
---|
120 | switch (rc) {
|
---|
121 | case ERROR_SHARING_VIOLATION:
|
---|
122 | CfgSysRC = CONFIGSYS_DelayCopyFile (TempSourceFile, TempDestinFile);
|
---|
123 | MINSTLOG_ToFile ("Delaying RC %d\n", CfgSysRC);
|
---|
124 | if (CfgSysRC!=CONFIGSYS_DONE) {
|
---|
125 | MSG_SetInsertViaPSZ (1, TempDestinFile);
|
---|
126 | MINSTALL_TrappedError (MINSTMSG_CouldNotCopyToFile);
|
---|
127 | return FALSE; // Problem during Copying
|
---|
128 | }
|
---|
129 | AnythingDelayed = TRUE;
|
---|
130 | break;
|
---|
131 | case ERROR_DISK_FULL:
|
---|
132 | MINSTALL_TrappedError (MINSTMSG_DiskFull);
|
---|
133 | return FALSE; // Problem during Copying
|
---|
134 | case 0:
|
---|
135 | break;
|
---|
136 | default:
|
---|
137 | MSG_SetInsertViaPSZ (1, TempSourceFile);
|
---|
138 | MINSTALL_TrappedError (MINSTMSG_CouldNotAccessFile);
|
---|
139 | return FALSE; // Problem during Copy
|
---|
140 | }
|
---|
141 | }
|
---|
142 | }
|
---|
143 | CurFilePtr++; CurNo++;
|
---|
144 | }
|
---|
145 |
|
---|
146 | if (AnythingDelayed) {
|
---|
147 | if (CONFIGSYS_DelayFinalize()!=CONFIGSYS_DONE)
|
---|
148 | return FALSE;
|
---|
149 | MINSTLOG_ToAll ("Files got delayed. System should reboot.\n");
|
---|
150 | }
|
---|
151 | return TRUE;
|
---|
152 | }
|
---|