1 | /* Running commands on Amiga
|
---|
2 | Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
---|
3 | 2005, 2006 Free Software Foundation, Inc.
|
---|
4 | This file is part of GNU Make.
|
---|
5 |
|
---|
6 | GNU Make is free software; you can redistribute it and/or modify it under the
|
---|
7 | terms of the GNU General Public License as published by the Free Software
|
---|
8 | Foundation; either version 2, or (at your option) any later 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 | GNU Make; see the file COPYING. If not, write to the Free Software
|
---|
16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */
|
---|
17 |
|
---|
18 | #include "make.h"
|
---|
19 | #include "variable.h"
|
---|
20 | #include "amiga.h"
|
---|
21 | #include <assert.h>
|
---|
22 | #include <exec/memory.h>
|
---|
23 | #include <dos/dostags.h>
|
---|
24 | #include <proto/exec.h>
|
---|
25 | #include <proto/dos.h>
|
---|
26 |
|
---|
27 | static const char Amiga_version[] = "$VER: Make 3.74.3 (12.05.96) \n"
|
---|
28 | "Amiga Port by A. Digulla ([email protected])";
|
---|
29 |
|
---|
30 | int
|
---|
31 | MyExecute (char **argv)
|
---|
32 | {
|
---|
33 | char * buffer, * ptr;
|
---|
34 | char ** aptr;
|
---|
35 | int len = 0;
|
---|
36 | int status;
|
---|
37 |
|
---|
38 | for (aptr=argv; *aptr; aptr++)
|
---|
39 | {
|
---|
40 | len += strlen (*aptr) + 4;
|
---|
41 | }
|
---|
42 |
|
---|
43 | buffer = AllocMem (len, MEMF_ANY);
|
---|
44 |
|
---|
45 | if (!buffer)
|
---|
46 | fatal (NILF, "MyExecute: Cannot allocate space for calling a command");
|
---|
47 |
|
---|
48 | ptr = buffer;
|
---|
49 |
|
---|
50 | for (aptr=argv; *aptr; aptr++)
|
---|
51 | {
|
---|
52 | if (((*aptr)[0] == ';' && !(*aptr)[1]))
|
---|
53 | {
|
---|
54 | *ptr ++ = '"';
|
---|
55 | strcpy (ptr, *aptr);
|
---|
56 | ptr += strlen (ptr);
|
---|
57 | *ptr ++ = '"';
|
---|
58 | }
|
---|
59 | else if ((*aptr)[0] == '@' && (*aptr)[1] == '@' && !(*aptr)[2])
|
---|
60 | {
|
---|
61 | *ptr ++ = '\n';
|
---|
62 | continue;
|
---|
63 | }
|
---|
64 | else
|
---|
65 | {
|
---|
66 | strcpy (ptr, *aptr);
|
---|
67 | ptr += strlen (ptr);
|
---|
68 | }
|
---|
69 | *ptr ++ = ' ';
|
---|
70 | *ptr = 0;
|
---|
71 | }
|
---|
72 |
|
---|
73 | ptr[-1] = '\n';
|
---|
74 |
|
---|
75 | status = SystemTags (buffer,
|
---|
76 | SYS_UserShell, TRUE,
|
---|
77 | TAG_END);
|
---|
78 |
|
---|
79 | FreeMem (buffer, len);
|
---|
80 |
|
---|
81 | if (SetSignal(0L,0L) & SIGBREAKF_CTRL_C)
|
---|
82 | status = 20;
|
---|
83 |
|
---|
84 | /* Warnings don't count */
|
---|
85 | if (status == 5)
|
---|
86 | status = 0;
|
---|
87 |
|
---|
88 | return status;
|
---|
89 | }
|
---|
90 |
|
---|
91 | char *
|
---|
92 | wildcard_expansion (char *wc, char *o)
|
---|
93 | {
|
---|
94 | # define PATH_SIZE 1024
|
---|
95 | struct AnchorPath * apath;
|
---|
96 |
|
---|
97 | if ( (apath = AllocMem (sizeof (struct AnchorPath) + PATH_SIZE,
|
---|
98 | MEMF_CLEAR))
|
---|
99 | )
|
---|
100 | {
|
---|
101 | apath->ap_Strlen = PATH_SIZE;
|
---|
102 |
|
---|
103 | if (MatchFirst (wc, apath) == 0)
|
---|
104 | {
|
---|
105 | do
|
---|
106 | {
|
---|
107 | o = variable_buffer_output (o, apath->ap_Buf,
|
---|
108 | strlen (apath->ap_Buf));
|
---|
109 | o = variable_buffer_output (o, " ",1);
|
---|
110 | } while (MatchNext (apath) == 0);
|
---|
111 | }
|
---|
112 |
|
---|
113 | MatchEnd (apath);
|
---|
114 | FreeMem (apath, sizeof (struct AnchorPath) + PATH_SIZE);
|
---|
115 | }
|
---|
116 |
|
---|
117 | return o;
|
---|
118 | }
|
---|
119 |
|
---|