]> git.saurik.com Git - wxWidgets.git/blob - utils/Install/packace/uac_sys.c
Added possibility of 2-step initialisation, and wxWIZARD_EX_HELPBUTTON style.
[wxWidgets.git] / utils / Install / packace / uac_sys.c
1 /* ------------------------------------------------------------------------ */
2 /* */
3 /* Some basic things. */
4 /* */
5 /* ------------------------------------------------------------------------ */
6
7 #include "os.h"
8
9 #include <signal.h> // signal()
10 #include <stdio.h> // fprintf() fflush() getch() putc()
11
12 #if defined(DOS) || defined(WINNT) || defined(WIN16)
13 #if !defined(__CYGWIN__)
14 #include <conio.h> // getch()
15 #endif
16 #endif
17 #if defined(DOS)
18 #include <dos.h> // delay() sound()
19 #endif
20
21 #include "globals.h"
22 #include "uac_sys.h"
23
24
25 void memset16(USHORT * dest, SHORT val, INT len) // fills short-array with
26 { // value
27 while (len--)
28 *(dest++) = val;
29 }
30
31 INT cancel(void) // checks whether to interrupt the program
32 {
33 #ifdef DOS
34 while (kbhit())
35 {
36 if (getch() == 27)
37 f_err = ERR_USER;
38 }
39 #endif
40 return (f_err);
41 }
42
43 INT wrask(CHAR * s) // prompt-routine
44 {
45 CHAR ch = 0;
46
47 fprintf(stderr, "\n %s (Yes,Always,No,Cancel) ", s);
48 fflush(stderr);
49 do
50 {
51 /*ch = getch();
52 ch = upcase(ch);*/
53 }
54 while (ch != 'Y' && ch != 'A' && ch != 'N' && ch != 'C' && ch != 27);
55 fprintf(stderr, "%s", ch == 'Y' ? "Yes" : (ch == 'A' ? "Always" : (ch == 'N' ? "No" : "Cancel")));
56 fflush(stderr);
57 return (ch == 'Y' ? 0 : (ch == 'A' ? 1 : (ch == 'N' ? 2 : 3)));
58 }
59
60 void beep(void) // makes some noise
61 {
62 #ifdef DOS
63 sound(800);
64 delay(250);
65 nosound();
66 #endif
67 #ifdef AMIGA
68 putc(0x07, stderr);
69 #endif
70 }
71
72 void my_signalhandler(INT sig_number) // sets f_err if ctrl+c or ctrl+brk
73 {
74 f_err = ERR_USER;
75 pipeit("\nUser break\n");
76 }
77
78 #ifdef DOS // handles hardware errors
79 #ifdef __BORLANDC__
80 INT harderrhandler(UINT deverr, UINT errc, UINT * devhdr)
81 #else
82 INT __far harderrhandler(UINT deverr, UINT errc, UINT * devhdr)
83 #endif
84 {
85 f_criterr = 'A' + deverr & 0xff;
86 f_err = ERR_OTHER;
87 return (0x3);
88 }
89 #endif
90
91 void set_handler(void) // initializes handlers
92 {
93 #if defined(DOS) && !defined(__BORLANDC__)
94 signal(SIGBREAK, my_signalhandler); // set ctrl-break/-c handlers
95 #endif
96 signal(SIGINT, my_signalhandler);
97 #if defined(DOS) && !defined(__CONSOLE__) // set hardware error handler
98 #ifdef __BORLANDC__
99 harderr(harderrhandler);
100 #else
101 _harderr(harderrhandler);
102 #endif
103 #endif
104 }
105