1 /* Running commands on Amiga
2 Copyright (C) 1995-2022 Free Software Foundation, Inc.
3 This file is part of GNU Make.
4
5 GNU Make is free software; you can redistribute it and/or modify it under the
6 terms of the GNU General Public License as published by the Free Software
7 Foundation; either version 3 of the License, or (at your option) any later
8 version.
9
10 GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License along with
15 this program. If not, see <https://www.gnu.org/licenses/>. */
16
17 #include "makeint.h"
18 #include "variable.h"
19 #include "amiga.h"
20 #include <assert.h>
21 #include <exec/memory.h>
22 #include <dos/dostags.h>
23 #include <proto/exec.h>
24 #include <proto/dos.h>
25
26 static const char Amiga_version[] = "$VER: Make 3.74.3 (12.05.96) \n"
27 "Amiga Port by A. Digulla (digulla@home.lake.de)";
28
29 int
30 MyExecute (char **argv)
31 {
32 char * buffer, * ptr;
33 char ** aptr;
34 int len = 0;
35 int status;
36
37 for (aptr=argv; *aptr; aptr++)
38 {
39 len += strlen (*aptr) + 4;
40 }
41
42 buffer = AllocMem (len, MEMF_ANY);
43
44 if (!buffer)
45 O (fatal, NILF, "MyExecute: Cannot allocate space for calling a command");
46
47 ptr = buffer;
48
49 for (aptr=argv; *aptr; aptr++)
50 {
51 if (((*aptr)[0] == ';' && !(*aptr)[1]))
52 {
53 *ptr ++ = '"';
54 ptr = stpcpy (ptr, *aptr);
55 *(ptr++) = '"';
56 }
57 else if ((*aptr)[0] == '@' && (*aptr)[1] == '@' && !(*aptr)[2])
58 {
59 *ptr ++ = '\n';
60 continue;
61 }
62 else
63 ptr = stpcpy (ptr, *aptr);
64 *ptr ++ = ' ';
65 *ptr = 0;
66 }
67
68 ptr[-1] = '\n';
69
70 status = SystemTags (buffer,
71 SYS_UserShell, TRUE,
72 TAG_END);
73
74 FreeMem (buffer, len);
75
76 if (SetSignal (0L,0L) & SIGBREAKF_CTRL_C)
77 status = 20;
78
79 /* Warnings don't count */
80 if (status == 5)
81 status = 0;
82
83 return status;
84 }
85
86 char *
87 wildcard_expansion (char *wc, char *o)
88 {
89 # define PATH_SIZE 1024
90 struct AnchorPath * apath;
91
92 if ( (apath = AllocMem (sizeof (struct AnchorPath) + PATH_SIZE,
93 MEMF_CLEAR))
94 )
95 {
96 apath->ap_Strlen = PATH_SIZE;
97
98 if (MatchFirst (wc, apath) == 0)
99 {
100 do
101 {
102 o = variable_buffer_output (o, apath->ap_Buf,
103 strlen (apath->ap_Buf));
104 o = variable_buffer_output (o, " ",1);
105 } while (MatchNext (apath) == 0);
106 }
107
108 MatchEnd (apath);
109 FreeMem (apath, sizeof (struct AnchorPath) + PATH_SIZE);
110 }
111
112 return o;
113 }