-
Notifications
You must be signed in to change notification settings - Fork 1
/
Utility.c
622 lines (600 loc) · 29.6 KB
/
Utility.c
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
/***********************************************************************\
* Utiltiy.c *
* Copyright (C) by Stangl Roman, 1993 *
* *
* Utility.c Additional utility procedures for ShutDown/2 *
* *
\***********************************************************************/
static char RCSID[]="@(#) $Header: Utility.c Version 1.00 06,1993 $ (LBL)";
#include "ShutDown.h" /* User include files */
/*--------------------------------------------------------------------------------------*\
* Procedure to initialize a window and its message queue. *
* Req: *
* pHab .......... A pointer to be filled with the anchor block of the window *
* pHmq .......... A pointer to be filled with the message queue of the window *
* Returns: *
* TRUE/FALSE .... If called sucessfully/unsucessfully *
\*--------------------------------------------------------------------------------------*/
BOOL WinStartUp(HAB *pHab, HMQ *pHmq)
{
/* Initialize handle of anchor block */
if((*pHab=WinInitialize(0))==NULLHANDLE)
return(FALSE);
/* Initialize handle of message queue */
if((*pHmq=WinCreateMsgQueue(*pHab, 0))==NULLHANDLE)
return(FALSE);
return(TRUE);
}
/*--------------------------------------------------------------------------------------*\
* Procedure to initialize HELP. *
* Req: *
* hab ........... Anchor block handle *
* pHelpFile ..... A pointer to helppanel filename in SD/2 directory *
* pHwndHelp .... A pointer to a HWND structure *
* Returns: *
* pHwndHelp ..... If called sucessfully/unsucessfully hwnd/NULL *
\*--------------------------------------------------------------------------------------*/
BOOL WinStartHelp(HAB hab, UCHAR *pHelpFile, HWND *pHwndHelp)
{
HELPINIT HelpInit;
HelpInit.cb=sizeof(HELPINIT); /* Size of HELPINIT structure */
HelpInit.ulReturnCode=0; /* Returnvalue from HelpManager */
HelpInit.pszTutorialName=NULL; /* No tutorial */
/* Ressource of Helptable */
HelpInit.phtHelpTable=(PHELPTABLE)MAKEULONG(MAIN_HELP_TABLE, 0xffff);
/* Ressource in .EXE */
HelpInit.hmodHelpTableModule=NULLHANDLE;
/* No handle */
HelpInit.hmodAccelActionBarModule=NULLHANDLE;
HelpInit.idAccelTable=0; /* None */
HelpInit.idActionBar=0; /* None */
/* Window title of help window */
HelpInit.pszHelpWindowTitle="SD/2 - ShutDown/2 Help";
HelpInit.pszHelpLibraryName=pHelpFile; /* Library name of help panel via SD/2 directory */
HelpInit.fShowPanelId=0; /* Panel ID not displayed */
/* *\
* First assume ShutDown.HLP in HELP path and try to create it from there. *
\* */
*pHwndHelp=WinCreateHelpInstance( /* Create help */
hab, /* Anchor block */
&HelpInit);
/* Test for successful help creation */
if((*pHwndHelp) && (!HelpInit.ulReturnCode))
/* Associate HELP with frame window */
if(WinAssociateHelpInstance(*pHwndHelp, hwndFrame)!=FALSE)
return(TRUE);
/* *\
* Second assume ShutDown.HLP in SD/2's directory and try to create it from there. *
\* */
HelpInit.ulReturnCode=0; /* Returnvalue from HelpManager */
/* Library name of help panel via HELP path */
HelpInit.pszHelpLibraryName="ShutDown.hlp";
*pHwndHelp=WinCreateHelpInstance(hab, &HelpInit);
if((*pHwndHelp) && (!HelpInit.ulReturnCode))
if(WinAssociateHelpInstance(*pHwndHelp, hwndFrame)!=FALSE)
return(TRUE);
*pHwndHelp=NULLHANDLE;
return(FALSE);
}
/*--------------------------------------------------------------------------------------*\
* Procedure to close a window and its message queue. *
* Req: *
* pHwndHelp ..... A pointer to HELP window handle *
* pHab .......... A pointer to extract the anchor block of the window *
* pHmq .......... A pointer to extract message queue of the window *
* Returns: *
* TRUE/FALSE .... If called sucessfully/unsucessfully *
\*--------------------------------------------------------------------------------------*/
BOOL WinCloseDown(HWND *pHwndHelp, HAB *pHab, HMQ *pHmq)
{
if(!*pHwndHelp) /* Release HELP */
WinDestroyHelpInstance(*pHwndHelp);
if(*pHmq!=NULLHANDLE) /* Release handle of message queue */
WinDestroyMsgQueue(*pHmq);
if(*pHab!=NULLHANDLE) /* Release handle of anchor block */
WinTerminate(*pHab);
/* Any error during WinStartUp */
if((*pHab==NULLHANDLE) || (*pHmq==NULLHANDLE)) return(FALSE);
else return(TRUE);
}
/*--------------------------------------------------------------------------------------*\
* Procedure opens the profile and writes the UPS structure into. *
* Req: *
* pHini ......... A pointer to the handle of the profile *
* pHab .......... A pointer to extract the anchor block of the window *
* pUps .......... A pointer to the UPS structure *
* Returns: *
* TRUE/FALSE .... If called sucessfully/unsucessfully *
\*--------------------------------------------------------------------------------------*/
BOOL Write_Profile(HINI *pHini, HAB *pHab, UPS *pUps)
{
/* First open the profile */
*pHini=PrfOpenProfile(*pHab, pucSD2Profile);
if(*pHini!=NULLHANDLE)
{
PrfWriteProfileData( /* Write binary data to profile */
*pHini, /* Handle of profile */
SD2_CLASSNAME, /* Application name */
"IDUBC_Hours", /* Key name */
&pUps->IDUBC_Hours, /* Value data */
sizeof(UCHAR)); /* Size of value data */
PrfWriteProfileData(
*pHini,
SD2_CLASSNAME,
"IDUBC_Minutes",
&pUps->IDUBC_Minutes,
sizeof(UCHAR));
PrfWriteProfileData(
*pHini,
SD2_CLASSNAME,
"IDUAS_Hours",
&pUps->IDUAS_Hours,
sizeof(UCHAR));
PrfWriteProfileData(
*pHini,
SD2_CLASSNAME,
"IDUAS_Minutes",
&pUps->IDUAS_Minutes,
sizeof(UCHAR));
PrfWriteProfileData(
*pHini,
SD2_CLASSNAME,
"IDUASD_Hours",
&pUps->IDUASD_Hours,
sizeof(UCHAR));
PrfWriteProfileData(
*pHini,
SD2_CLASSNAME,
"IDUASD_Minutes",
&pUps->IDUASD_Minutes,
sizeof(UCHAR));
PrfWriteProfileData(
*pHini,
SD2_CLASSNAME,
"IDUS_Hours",
&pUps->IDUS_Hours,
sizeof(UCHAR));
PrfWriteProfileData(
*pHini,
SD2_CLASSNAME,
"IDUS_Minutes",
&pUps->IDUS_Minutes,
sizeof(UCHAR));
PrfWriteProfileString(
*pHini,
SD2_CLASSNAME,
"IDS_PgmName",
pUps->IDS_PgmName);
PrfWriteProfileString(
*pHini,
SD2_CLASSNAME,
"IDS_PgmDirectory",
pUps->IDS_PgmDirectory);
PrfWriteProfileString(
*pHini,
SD2_CLASSNAME,
"IDS_PgmInputs",
pUps->IDS_PgmInputs);
PrfWriteProfileData(
*pHini,
SD2_CLASSNAME,
"GRP_Mode",
&pUps->GRP_Mode,
sizeof(ULONG));
PrfWriteProfileString(
*pHini,
SD2_CLASSNAME,
"IDS_UserInfo",
pUps->IDS_UserInfo);
return(PrfCloseProfile(*pHini)); /* Close and return result */
}
else
{ /* Profile couldn't be opened successfully */
/* SHUTDOWN.INI defective logging into logfile */
DosGetDateTime(&UPS_Current);
UPS_LogfileIO(LF_INIFILE_PROBLEM, MPFROMP(&UPS_Current));
return(FALSE);
}
}
/*--------------------------------------------------------------------------------------*\
* Procedure opens the profile and reads the UPS structure from. *
* Req: *
* pHini ......... A pointer to the handle of the profile *
* pHab .......... A pointer to extract the anchor block of the window *
* pUps .......... A pointer to the UPS structure *
* Returns: *
* TRUE/FALSE .... If called sucessfully/unsucessfully *
\*--------------------------------------------------------------------------------------*/
BOOL Read_Profile(HINI *pHini, HAB *pHab, UPS *pUps)
{
ULONG ulSize;
UCHAR *uc='\0';
/* First open the profile */
*pHini=PrfOpenProfile(*pHab, pucSD2Profile);
while(TRUE)
{
ulSize=sizeof(UCHAR);
if(PrfQueryProfileData( /* Query binary data from profile */
*pHini, /* Handle of profile */
SD2_CLASSNAME, /* Application name */
"IDUBC_Hours", /* Key name */
&pUps->IDUBC_Hours, /* Value data */
&ulSize)==FALSE) /* Size of value data */
{ *pHini=NULLHANDLE; break; }
if(PrfQueryProfileData(
*pHini,
SD2_CLASSNAME,
"IDUBC_Minutes",
&pUps->IDUBC_Minutes,
&ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
if(PrfQueryProfileData(
*pHini,
SD2_CLASSNAME,
"IDUAS_Hours",
&pUps->IDUAS_Hours,
&ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
if(PrfQueryProfileData(
*pHini,
SD2_CLASSNAME,
"IDUAS_Minutes",
&pUps->IDUAS_Minutes,
&ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
if(PrfQueryProfileData(
*pHini,
SD2_CLASSNAME,
"IDUASD_Hours",
&pUps->IDUASD_Hours,
&ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
if(PrfQueryProfileData(
*pHini,
SD2_CLASSNAME,
"IDUASD_Minutes",
&pUps->IDUASD_Minutes,
&ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
if(PrfQueryProfileData(
*pHini,
SD2_CLASSNAME,
"IDUS_Hours",
&pUps->IDUS_Hours,
&ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
if(PrfQueryProfileData(
*pHini,
SD2_CLASSNAME,
"IDUS_Minutes",
&pUps->IDUS_Minutes,
&ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
ulSize=sizeof(ULONG);
if(PrfQueryProfileData(
*pHini,
SD2_CLASSNAME,
"GRP_Mode",
&pUps->GRP_Mode,
&ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
ulSize=sizeof(Ups.IDS_PgmName);
if(PrfQueryProfileString(
*pHini,
SD2_CLASSNAME,
"IDS_PgmName",
uc,
pUps->IDS_PgmName,
ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
if(PrfQueryProfileString(
*pHini,
SD2_CLASSNAME,
"IDS_PgmDirectory",
uc,
pUps->IDS_PgmDirectory,
ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
if(PrfQueryProfileString(
*pHini,
SD2_CLASSNAME,
"IDS_PgmInputs",
uc,
pUps->IDS_PgmInputs,
ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
ulSize=sizeof(Ups.IDS_UserInfo);
if(PrfQueryProfileString(
*pHini,
SD2_CLASSNAME,
"IDS_UserInfo",
uc,
pUps->IDS_UserInfo,
ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
return(PrfCloseProfile(*pHini)); /* Close and return result */
}
if(*pHini==NULLHANDLE)
{
/* SHUTDOWN.INI missing logging into logfile */
DosGetDateTime(&UPS_Current);
UPS_LogfileIO(LF_INIFILE_MISSING, MPFROMP(&UPS_Current));
pUps->IDUBC_Hours=0; /* Assume default values */
pUps->IDUBC_Minutes=10;
pUps->IDUAS_Hours=0;
pUps->IDUAS_Minutes=1;
pUps->IDUASD_Hours=0;
pUps->IDUASD_Minutes=4;
pUps->IDUS_Hours=0;
pUps->IDUS_Minutes=7;
pUps->GRP_Mode=IDM_LPT1;
strcpy(pUps->IDS_PgmName, "CMD.EXE");
strcpy(pUps->IDS_PgmDirectory, "");
strcpy(pUps->IDS_PgmInputs, "");
strcpy(pUps->IDS_UserInfo, "An error occured accessing SHUTDOWN.INI, please correct "\
"as soon as possible!");
return(FALSE);
}
}
/*--------------------------------------------------------------------------------------*\
* Procedure to copy a DATETIME structure to another. *
* Req: *
* pDestination .. A pointer to the destination DATETIME structure *
* pSource ....... A pointer to the source DATETIME structure *
* Returns: *
* TRUE/FALSE .... If pDestination>=pSource/pDestination<pSource *
\*--------------------------------------------------------------------------------------*/
BOOL Copy_DateTime(DATETIME *pDestination, DATETIME *pSource)
{
pDestination->seconds=pSource->seconds;
pDestination->minutes=pSource->minutes;
pDestination->hours=pSource->hours;
pDestination->day=pSource->day;
pDestination->month=pSource->month;
pDestination->year=pSource->year;
return(TRUE);
}
/*--------------------------------------------------------------------------------------*\
* Procedure to add hours/minutes to a DATETIME structure. *
* Req: *
* pDestination .. A pointer to the destination DATETIME structure *
* pucHours ...... Hours to add *
* pucMinutes .... Minutes to add
* Returns: *
* TRUE/FALSE .... If called sucessfully/unsucessfully *
\*--------------------------------------------------------------------------------------*/
BOOL Add_DateTime(DATETIME *pDestination, UCHAR *pucHours, UCHAR *pucMinutes)
{
ULONG Days_Month[]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
if((pDestination->minutes+=*pucMinutes)>=60)
{ /* Adjust minutes */
pDestination->minutes-=60;
pDestination->hours++;
}
if((pDestination->hours+=*pucHours)>=24)
{ /* Adjust hours */
pDestination->hours-=24;
pDestination->day++;
}
/* Adjust for calendar adjustments */
if((pDestination->year%4==0) && (pDestination->year%100)!=0) Days_Month[1]=29;
if(pDestination->day>Days_Month[(pDestination->month)-1])
{ /* Adjust days, beware of 0-based months */
pDestination->day-=Days_Month[(pDestination->month)-1];
pDestination->month++;
}
if(pDestination->month>12)
{ /* Adjust months */
pDestination->month-=12;
pDestination->year++;
}
return(TRUE);
}
/*--------------------------------------------------------------------------------------*\
* Procedure to compare a DATETIME structure with another DATETIME structure. *
* Req: *
* pDestination .. A pointer to the destination DATETIME structure *
* pSource ....... A pointer to the DATETIME structure to compare *
* Returns: *
* TRUE/FALSE .... If pDestination>=pSource/pDestination<pSource *
\*--------------------------------------------------------------------------------------*/
BOOL Cmp_DateTime(DATETIME *pDestination, DATETIME *pSource)
{
if(pDestination->year>pSource->year) return(TRUE);
if(pDestination->year<pSource->year) return(FALSE);
if(pDestination->month>pSource->month) return(TRUE);
if(pDestination->month<pSource->month) return(FALSE);
if(pDestination->day>pSource->day) return(TRUE);
if(pDestination->day<pSource->day) return(FALSE);
if(pDestination->hours>pSource->hours) return(TRUE);
if(pDestination->hours<pSource->hours) return(FALSE);
if(pDestination->minutes>pSource->minutes) return(TRUE);
if(pDestination->minutes<pSource->minutes) return(FALSE);
if(pDestination->seconds>pSource->seconds) return(TRUE);
if(pDestination->seconds<pSource->seconds) return(FALSE);
return(TRUE); /* Both structures are exactly the same */
}
/*--------------------------------------------------------------------------------------*\
* Procedure to calculate the difference between two DATETIME structures in seconds. *
* Req: *
* pPrevious .. .. A pointer to the destination DATETIME structure *
* pLater ........ A pointer to the DATETIME structure to compare *
* Returns: *
* ulDiff ........ Difference in seconds *
\*--------------------------------------------------------------------------------------*/
ULONG Diff_DateTime(DATETIME *pPrevious, DATETIME *pLater)
{
ULONG ulPrevious;
ULONG ulLater;
/* First date/time */
ulPrevious=pPrevious->hours*60*60+pPrevious->minutes*60+pPrevious->seconds;
/* Last date/time */
ulLater=pLater->hours*60*60+pLater->minutes*60+pLater->seconds;
/* On day wrap around add one day */
if(ulLater<ulPrevious) ulLater+=24*60*60;
return(ulLater-ulPrevious);
}
/*--------------------------------------------------------------------------------------*\
* Procedure to display a message box to the user. *
* Req: *
* pucError ...... Pointer to an error string *
* Returns: *
* usResponse .... Response of the user (the button pressed) *
\*--------------------------------------------------------------------------------------*/
USHORT User_Error(UCHAR *pucError)
{
return(WinMessageBox( /* Display the error on the screen */
HWND_DESKTOP, /* Handle of parent-window */
HWND_DESKTOP, /* Handle of owner-window */
pucError, /* Message-box window message */
/* Message-box window title */
"SD/2 - ShutDown/2 Error Information",
ID_SHUTDOWN, /* ID passed to HK_HELP and WM_HELP */
/* Message-box window style */
MB_OK | MB_ICONEXCLAMATION | MB_DEFBUTTON1));
}
/*--------------------------------------------------------------------------------------*\
* Procedure to create/close a secondary thread. *
* Req: *
* bCreate ....... Create/close a thread *
* pUPS_Thread ... Pointer to a function implementing the thread *
* Returns: *
* TRUE/FALSE .... If called sucessfully/unsucessfully *
\*--------------------------------------------------------------------------------------*/
BOOL UPS_ThreadCreate(BOOL bCreate, PFNTHREAD pUPS_Thread)
{
static ULONG ulThreadArg=0;
static ULONG ulThreadFlag=0;
static ULONG ulStackSize=8192;
static TID tidThread;
if(bCreate==TRUE)
{
DosCreateThread( /* Create a secondary thread */
&tidThread, /* Thread ID of created thread */
pUPS_Thread, /* Pointer to thread */
ulThreadArg, /* Thread arguments */
ulThreadFlag, /* Thread flags */
ulStackSize); /* Thread's stack size */
return(TRUE);
}
else
{
DosKillThread( /* Kill the secondary thread */
tidThread); /* Thread ID of thread to be killed */
return(TRUE);
}
}
/*--------------------------------------------------------------------------------------*\
* Procedure to write to logfile. *
* Req: *
* ulMsg ......... Message ID *
* mpParam ....... Pointer to parameter *
* Ref: *
* pucSD2Logfile . Pointer to name of logfile *
* Returns: *
* TRUE/FALSE .... If called sucessfully/unsucessfully *
\*--------------------------------------------------------------------------------------*/
BOOL UPS_LogfileIO(ULONG ulMsg, MPARAM mpParam)
{
FILE *Logfile;
DATETIME *pDT=PVOIDFROMMP(mpParam);
if((Logfile=fopen(pucSD2Logfile, "a"))==NULL)
return(FALSE); /* Error, couldn't open logfile */
switch(ulMsg)
{
case LF_POWERFAILED:
{ /* Line power failed */
fprintf(Logfile, "*********************************************************************\n");
fprintf(Logfile, "*** SD/2 detected: Line power failed at: %4d/%02d/%02d at %02d:%02d:%02d ***\n",
pDT->year, pDT->month, pDT->day, pDT->hours, pDT->minutes, pDT->seconds);
fprintf(Logfile, "*********************************************************************\n");
break;
}
case LF_POWERRETURNED:
{ /* Line power returned */
fprintf(Logfile, "*********************************************************************\n");
fprintf(Logfile, "*** SD/2 detected: Line power returned at: %4d/%02d/%02d at %02d:%02d:%02d ***\n",
pDT->year, pDT->month, pDT->day, pDT->hours, pDT->minutes, pDT->seconds);
fprintf(Logfile, "*********************************************************************\n\n");
break;
}
case LF_UPS_ALERTSTARTTIME:
{ /* Planned Alert will start at... */
fprintf(Logfile, " Planning Alert start at: %4d/%02d/%02d at %02d:%02d:%02d\n",
pDT->year, pDT->month, pDT->day, pDT->hours, pDT->minutes, pDT->seconds);
break;
}
case LF_UPS_ALERTSHUTDOWNTIME:
{ /* Planned user configurable program will be started at...*/
fprintf(Logfile, " Planning User-Application start at: %4d/%02d/%02d at %02d:%02d:%02d\n",
pDT->year, pDT->month, pDT->day, pDT->hours, pDT->minutes, pDT->seconds);
break;
}
case LF_UPS_SHUTDOWNTIME:
{ /* Planned OS/2 DosShutdown will be called at...*/
fprintf(Logfile, " Planning OS/2 ShutDown at: %4d/%02d/%02d at %02d:%02d:%02d\n",
pDT->year, pDT->month, pDT->day, pDT->hours, pDT->minutes, pDT->seconds);
break;
}
case LF_UPS_ALERTSTART:
{ /* Alert will start at...*/
fprintf(Logfile, " Alert started at: %4d/%02d/%02d at %02d:%02d:%02d\n",
pDT->year, pDT->month, pDT->day, pDT->hours, pDT->minutes, pDT->seconds);
break;
}
case LF_UPS_ALERTSHUTDOWN:
{ /* The user configurable program will be started at...*/
fprintf(Logfile, " User-Application started at: %4d/%02d/%02d at %02d:%02d:%02d\n",
pDT->year, pDT->month, pDT->day, pDT->hours, pDT->minutes, pDT->seconds);
break;
}
case LF_UPS_SHUTDOWN:
{ /* OS/2 DosShutdown will be called at...*/
fprintf(Logfile, " OS/2 ShutDown started at: %4d/%02d/%02d at %02d:%02d:%02d\n",
pDT->year, pDT->month, pDT->day, pDT->hours, pDT->minutes, pDT->seconds);
break;
}
case LF_INIFILE_MISSING:
{ /* SD/2 profile is missing or defective */
fprintf(Logfile, "\n+-------------------------------------------------------------------+\n");
fprintf(Logfile, "| ! SD/2 detected: Profile defective at: %4d/%02d/%02d at %02d:%02d:%02d ! |\n",
pDT->year, pDT->month, pDT->day, pDT->hours, pDT->minutes, pDT->seconds);
fprintf(Logfile, "| ! Creating default SHUTDOWN.INI - please adjust immediately! ! |\n");
fprintf(Logfile, "+-------------------------------------------------------------------+\n\n");
break;
}
case LF_INIFILE_PROBLEM:
{ /* SD/2 profile can't be accessed */
fprintf(Logfile, "\n+-------------------------------------------------------------------+\n");
fprintf(Logfile, "| ! SD/2 detected: Profile defective at: %4d/%02d/%02d at %02d:%02d:%02d ! |\n",
pDT->year, pDT->month, pDT->day, pDT->hours, pDT->minutes, pDT->seconds);
fprintf(Logfile, "| ! Can't access SHUTDOWN.INI - Serious problem, please correct! ! |\n");
fprintf(Logfile, "+-------------------------------------------------------------------+\n\n");
break;
}
case LF_PARALLEL_INITIALIZED:
{ /* UPS <-> SD/2 interface at parallel port */
fprintf(Logfile, "\n*********************************************************************\n");
fprintf(Logfile, "*** Parallel port initialized for UPS <-> SD/2 communication ***\n");
fprintf(Logfile, "*** Current System Date & Time is: %4d/%02d/%02d at %02d:%02d:%02d ***\n",
pDT->year, pDT->month, pDT->day, pDT->hours, pDT->minutes, pDT->seconds);
fprintf(Logfile, "*********************************************************************\n\n");
break;
}
case LF_SERIAL_INITIALIZED:
{ /* UPS <-> SD/2 interface at serial port */
fprintf(Logfile, "\n*********************************************************************\n");
fprintf(Logfile, "*** Serial port initialized for UPS <-> SD/2 communication ***\n");
fprintf(Logfile, "*** Current System Date & Time is: %4d/%02d/%02d at %02d:%02d:%02d ***\n",
pDT->year, pDT->month, pDT->day, pDT->hours, pDT->minutes, pDT->seconds);
fprintf(Logfile, "*********************************************************************\n\n");
break;
}
case LF_UPS_PASSWORD_USED:
{ /* The program was invoked with the undocumented
commandline option [-|/]IBMSERVICE */
fprintf(Logfile, "\n+-------------------------------------------------------------------+\n");
fprintf(Logfile, "| ! SD/2 detected: Service applied at: %4d/%02d/%02d at %02d:%02d:%02d ! |\n",
pDT->year, pDT->month, pDT->day, pDT->hours, pDT->minutes, pDT->seconds);
fprintf(Logfile, "| ! ! |\n");
fprintf(Logfile, "| ! The configuration service option is used. Please be sure that ! |\n");
fprintf(Logfile, "| ! all changes of the configuration correspond to their equiva- ! |\n");
fprintf(Logfile, "| ! lent settings of the UPS control logic. ! |\n");
fprintf(Logfile, "| ! Warning! SD/2 and the UPS control logic may not operate ! |\n");
fprintf(Logfile, "| ! correctly, if this service isn't performed by IBM! ! |\n");
fprintf(Logfile, "+-------------------------------------------------------------------+\n\n");
break;
}
}
fclose(Logfile);
return(TRUE);
}