summaryrefslogtreecommitdiff
path: root/amiga.c
blob: 26fd3abf348f3d5f1f3df4c5133abdcd40ef75d6 (plain)
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
/* Running commands on Amiga
Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
This file is part of GNU Make.

GNU Make is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

GNU Make is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Make; see the file COPYING.  If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */

#include "make.h"
#include <assert.h>
#include <exec/memory.h>
#include <dos/dostags.h>
#include <proto/exec.h>
#include <proto/dos.h>

int
MyExecute (argv)
char ** argv;
{
    char * buffer, * ptr;
    char ** aptr;
    int len = 0;
    int status;

    for (aptr=argv; *aptr; aptr++)
    {
	len += strlen (*aptr) + 4;
    }

    buffer = AllocMem (len, MEMF_ANY);

    if (!buffer)
      fatal ("MyExecute: Cannot allocate space for calling a command");

    ptr = buffer;

    for (aptr=argv; *aptr; aptr++)
    {
	if (((*aptr)[0] == ';' && !(*aptr)[1]))
	{
	    *ptr ++ = '"';
	    strcpy (ptr, *aptr);
	    ptr += strlen (ptr);
	    *ptr ++ = '"';
	}
	else if ((*aptr)[0] == '@' && (*aptr)[1] == '@' && !(*aptr)[2])
	{
	    *ptr ++ = '\n';
	    continue;
	}
	else
	{
	    strcpy (ptr, *aptr);
	    ptr += strlen (ptr);
	}
	*ptr ++ = ' ';
	*ptr = 0;
    }

    ptr[-1] = '\n';

    status = SystemTags (buffer,
	SYS_UserShell, TRUE,
	TAG_END);

    FreeMem (buffer, len);

    if (SetSignal(0L,0L) & SIGBREAKF_CTRL_C)
	status = 20;

    /* Warnings don't count */
    if (status == 5)
	status = 0;

    return status;
}