Variables removed (see discussion "buildsystem curiosity" on mailing list).
[AROS-Contrib.git] / regina / regutil / regwin.c
blob2083409a9790e80a421668e1b1fe61eb4cf93ea9
1 /* NT Message Box and Exec functions for regutil
3 * The contents of this file are subject to the Mozilla Public License
4 * Version 1.0 (the "License"); you may not use this file except in
5 * compliance with the License. You may obtain a copy of the License at
6 * http://www.mozilla.org/MPL/
8 * Software distributed under the License is distributed on an "AS IS"
9 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
10 * License for the specific language governing rights and limitations
11 * under the License.
13 * The Original Code is regutil.
15 * The Initial Developer of the Original Code is Patrick TJ McPhee.
16 * Portions created by Patrick McPhee are Copyright © 2001
17 * Patrick TJ McPhee. All Rights Reserved.
19 * Contributors:
21 * $Header: /opt/cvs/Regina/regutil/regwin.c,v 1.1 2009/10/07 07:52:21 mark Exp $
24 #include "rxproto.h"
26 /* rxmessagebox(text, [title], [button], [icon]) */
28 rxfunc(rxmessagebox)
30 char * text, *but = NULL, *ic = NULL;
31 char * title = "Error!";
32 int button = MB_OK;
33 int icon = MB_ICONHAND;
34 register int i;
35 static const struct {
36 char * text;
37 int value;
38 } bs[] = {
39 "OK", MB_OK,
40 "OKCANCEL", MB_OKCANCEL,
41 "ABORTRETRYIGNORE", MB_ABORTRETRYIGNORE,
42 "YESNOCANCEL", MB_YESNOCANCEL,
43 "YESNO", MB_YESNO,
44 "RETRYCANCEL", MB_RETRYCANCEL,
45 }, is[] = {
46 "HAND", MB_ICONHAND,
47 "QUESTION", MB_ICONQUESTION,
48 "EXCLAMATION", MB_ICONEXCLAMATION,
49 "ASTERISK", MB_ICONASTERISK,
50 "INFORMATION", MB_ICONINFORMATION,
51 "STOP", MB_ICONSTOP,
54 checkparam(1,4);
56 rxstrdup(text, argv[0]);
57 if (argc > 1 && argv[1].strptr) {
58 rxstrdup(title, argv[1]);
60 if (argc > 2 && argv[2].strptr) {
61 rxstrdup(but, argv[2]);
63 if (argc > 3 && argv[3].strptr) {
64 rxstrdup(ic, argv[3]);
67 if (ic) {
68 strupr(ic);
69 for (i = 0; i < DIM(is); i++) {
70 if (!strcmp(ic, is[i].text)) {
71 icon = is[i].value;
72 break;
77 if (but) {
78 strupr(but);
79 for (i = 0; i < DIM(bs); i++) {
80 if (!strcmp(but, bs[i].text)) {
81 button = bs[i].value;
82 break;
87 result->strlength = sprintf(result->strptr, "%d",
88 MessageBox(NULL, text, title, icon|button));
90 return 0;
94 /* call winexec with the specified arguments. The same effect can be had
95 * using the start command
96 * rc = rxwinexec(cmd[, flags])
98 rxfunc(rxwinexec)
100 char * cmd, *sflags = NULL;
101 int flags = SW_SHOWNORMAL;
102 register int i;
103 static const struct {
104 char * text;
105 int value;
106 } fs[] = {
107 "SHOWNORMAL", SW_SHOWNORMAL,
108 "SHOWNOACTIVATE", SW_SHOWNOACTIVATE,
109 "SHOWMINNOACTIVE", SW_SHOWMINNOACTIVE,
110 "SHOWMINIMIZED", SW_SHOWMINIMIZED,
111 "SHOWMAXIMIZED", SW_SHOWMAXIMIZED,
112 "HIDE", SW_HIDE,
113 "MINIMIZE", SW_MINIMIZE
116 checkparam(1,2);
118 rxstrdup(cmd, argv[0]);
119 if (argc > 1 && argv[1].strptr) {
120 rxstrdup(sflags, argv[1]);
123 if (sflags) {
124 strupr(sflags);
125 for (i = 0; i < DIM(fs); i++) {
126 if (!strcmp(sflags, fs[i].text)) {
127 flags = fs[i].value;
128 break;
133 /* return the rc of winexec */
134 result->strlength = sprintf(result->strptr, "%d", WinExec(cmd, flags));
136 return 0;